10
votes
Toggle 2 LEDs using a timer XMEGA-A3BU Xplained
The optimizer has a habit of optimizing out my timing loops.
This is (a) a non-surprise, and (b) somewhat of a red flag when it comes to coding practice. If you're writing timing loops that attempt ...
7
votes
Toggle 2 LEDs using a timer XMEGA-A3BU Xplained
Portable Register Addressing to allow the code using this file to port to
other devices.
I seriously doubt that. Other devices may have (and will have) completely different mapping. What's worse, the ...
6
votes
Accepted
Arbitrary Length Input in C
End-of-file
When nothing is read, code returns an allocated "". That is indistinguishable from reading only a '\n' as ...
5
votes
CSV to TSV converter in C+yacc+lex and a Makefile
Overview
Code Review
Starting at the bottom and working up:
Lexer
This looks like it should work.
The only thing I would do differently is the . match at the end.
...
4
votes
Toggle 2 LEDs using a timer XMEGA-A3BU Xplained
Use a standard library
It looks like you have written a lot of code to deal with AVR registers. Maybe it was required that you wrote everything from scratch, but it would be much better if you could ...
3
votes
tee: copy standard input to both stdout and a file
Disclaimer: My C is a little rusty, as I don't write it regularly.
Your code is clear and straightforward and I'm happy with your variable names (which is not always the case), but there are some ...
3
votes
Convert from decimal to binary and octal
The global variables make it harder to reuse your code. They seem to be unnecessary anyway: the integer variables are used only in main(), and ...
3
votes
Accepted
Simple tokenizer in C
Apparent uniform formatting - good
Hope OP is using an auto-formatter.
Bug?
mem_free(rv) is suspicious. Is a free needed on successful re-allocation?
...
3
votes
Accepted
Stack implementation in C programming Language
Advice 1
time.h is not used. Remove it. Same for string.h.
Advice 2
...
2
votes
change file attributes on a Linux file system with chattr
General Overview
The code is fairly well written and a good start. I'm sorry but I can't help out on the POSIX part of the question.
Possible Bug
The current parsing of the command line has been over ...
2
votes
CSV to TSV converter in C+yacc+lex and a Makefile
Makefile
The Makefile looks generally good.
We shouldn't need to write a .c.o rule - the built-in one is likely better.
I recommend adding some suitable warning/...
2
votes
Accepted
C lang CGI form/string handle
Some bugs:
malloc() can fail. When it does, it returns a null pointer, which we must not use as destination for strcpy().
The ...
2
votes
Convert from decimal to binary and octal
The code presented could be more readable.
Starting with comments telling what "everything" is there for.
Naming: integers/numbers are not decimal.
Representations are, unless specified ...
2
votes
tee: copy standard input to both stdout and a file
I'm going to mostly take one part of the code to make some points, but it applies throughout.
I have to say that I dislike side effects on the right of logical expressions. Whilst I appreciate that ...
2
votes
tee: copy standard input to both stdout and a file
sizeof (what)
read(0, buf, sizeof(buf)) is a nice way to determine the size of buf. Code used the size of the object.
Better to ...
2
votes
another attempt to implement the tee command
I see no reason to use system calls. Here it on;y hurts portability. After all, a conforming implementation is not required to provide open, read, write, etc. ...
2
votes
display processes children
Limit the responsibilites of createChild()
The function createChild() does many things; it resizes an array, forks a new process,...
1
vote
Longest Increasing Subsequence of Rectangles
General Observations
Overall a well structure program, but it could be more readable. The program is not completely portable since it uses variable array size and older versions of C or versions of C ...
1
vote
Case-insensitive sort in C
Bug: String handling is unsigned
For all functions in this subclause, each character shall be interpreted as if it had the type unsigned char (and therefore every possible object representation is ...
1
vote
Accepted
OAuth implementation for Puredata
Almost certainly, Coverity is simply looking for all uses of strcat, strcpy, sprintf, etc., ...
1
vote
change file attributes on a Linux file system with chattr
Sentinels on troublesome output
When open fails, something is wrong. Sometimes a formed filename is amiss. Using sentinels like "\"%s\"" helps ...
1
vote
1
vote
n an array of N elements calculate its mean and count the number sub array of N-2 elements that have same mean
The single-letter variable names make the code hard to read. Use more informative names to help readers understand what your code is doing.
Always assume input is erroneous or even hostile - never ...
1
vote
Accepted
AES implementation in C
There's a lot of stuff in the header file that looks like implementation detail, which could be private to aes.c.
The header should just have the public types and ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
c × 3660beginner × 516
performance × 508
strings × 379
algorithm × 301
linked-list × 237
memory-management × 166
array × 164
programming-challenge × 147
io × 124
linux × 122
reinventing-the-wheel × 118
file × 115
parsing × 113
pointers × 98
sorting × 93
homework × 88
multithreading × 79
c++ × 75
integer × 71
formatting × 70
bitwise × 69
matrix × 67
console × 66
game × 65