CS 3733 Operating Systems, Fall 2005 Assignment 0 Comments
This assignment was graded on the basis of 20 points.
If you sent me an email with code for serialize3 you received
at least 10 points for this assignment.
You got an additional 5 points if your code was close to being correct.
You got full credit if I could not find anything incorrect about your code.
That does not mean that it was correct.
If you sent me more than one version, I only looked at the latest one.
You should have received and email from me with comments about your program.
Notes refer to items below, which are in no particular order. After each note
below is the number of points I generally took off for this issue.
I did not generally take off points for those items with an asterisk,
but they must be corrected by the time you turn in assignment 1.
Comments on serialize3
- * Eschew obfuscation!
- * You were not asked to print anything in this function,
so don't print error messages. This is the responsibility of the
calling program.
- * Do not put more than one statement on a line.
- * Make sure all constants are defined.
- snprintf cannot return a negative value since it does not do any output.
- pointers must be initialized to a non-null value before they are used.
(2-5 points).
- * if possible, avoid programs whose correctness involves counting
the number of things you left out.
- Avoid unnecessary loops
- Avoid #define ONE 1
- You don't need to use snprintf if you know the result will fit.
- Integer parameters to serialize3 are allowed to be negative. (1 point)
- Program should not crash when integer parameters are negative. (5 points)
- snprintf return value does not include the space for the string terminator. (2 points)
- * serailize3 does not need any arbitrary hard-coded buffer sizes.
- serialize3 should not directly modify errno.
- It is wrong to compare an integer to NULL. (5 points)
- You should not modify string literals. The C standard states that when you
attempt to do so, the behavior is undefined. (2 points)
- Do not call exit from serialize3 when an error occurs. (5 points)
- Don't do something in multiple steps when one will suffice.
- You must check for malloc return of NULL (5 points)
- It is probably not a good idea to call snprintf with a count of 0
since the Solaris man page tells you not to. However, this is in
contradiction to the C and POSIX standards.
- If you write a function that returns a value, tell me what it does,
especially if it is not related to the name of the function.
- sizeof(int) is not the same as the number of digits in an integer. (5 points)
- Don't fill a buffer with 0's for no apparent reason.
- Don't use a variable when you mean the constant 1.
- sizeof(char *) is not the same as sizeof(char).
- * Avoid memory leaks.
- * handle NULL parameter by returning NULL.
- It is rarely necessary to call strlen(" ");
- Don't you malloc to alloce small amounts of memory of known size:
char s[1];
is better than:
s = (char *)malloc(1);
- Some students used this code. It is a very bad example of C programming.
An outline of a solution can be found here.