-
Notifications
You must be signed in to change notification settings - Fork 291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve static and const correctness. #97
Conversation
0d7532f
to
7eb80c0
Compare
Reviewed 38 of 38 files at r1. toxav/msi.c, line 685 [r1] (raw file):
Comments from Reviewable |
Reviewed 36 of 38 files at r1. testing/DHT_test.c, line 157 [r1] (raw file):
wouldn't this be better in an toxav/msi.c, line 685 [r1] (raw file):
|
Review status: 19 of 38 files reviewed at latest revision, 3 unresolved discussions. testing/DHT_test.c, line 157 [r1] (raw file):
|
- Any non-externally-visible declarations should be `static`. - Casting away the `const` qualifier from pointers-to-const is dangerous. All but one instance of this are now correct. The one instance where we can't keep `const` is one where toxav code actually writes to a chunk of memory marked as `const`. This code also assumes 4 byte alignment of data packets. I don't know whether that is a valid assumption, but it's likely unportable, and *not* obviously correct. - Replaced empty parameter lists with `(void)` to avoid passing parameters to it. Empty parameter lists are old style declarations for unknown number and type of arguments. - Commented out (as `#if DHT_HARDENING` block) the hardening code that was never executed. - Minor style fix: don't use `default` in enum-switches unless the number of enumerators in the default case is very large. In this case, it was 2, so we want to list them both explicitly to be warned about missing one if we add one in the future. - Removed the only two function declarations from nTox.h and put them into nTox.c. They are not used outside and nTox is not a library.
Reviewed 19 of 19 files at r2. Comments from Reviewable |
Reviewed 19 of 38 files at r1, 19 of 19 files at r2. Comments from Reviewable |
Reviewed 19 of 19 files at r2. toxav/msi.c, line 685 [r1] (raw file): Oh well, too bad it's all or nothing.
Use of curly braces is entirely optional though, they are not required for multi-line case. Unless irungentoo always uses them like that, the "no curely braces" = "fall through" is a rather questionable oracle. Comments from Reviewable |
Review status: all files reviewed at latest revision, 1 unresolved discussion. toxav/msi.c, line 685 [r1] (raw file):
|
static
.const
qualifier from pointers-to-const isdangerous. All but one instance of this are now correct. The one
instance where we can't keep
const
is one where toxav code actuallywrites to a chunk of memory marked as
const
. This code also assumes4 byte alignment of data packets. I don't know whether that is a valid
assumption, but it's likely unportable, and not obviously correct.
(void)
to avoid passingparameters to it. Empty parameter lists are old style declarations for
unknown number and type of arguments.
#if DHT_HARDENING
block) the hardening code thatwas never executed.
default
in enum-switches unless the numberof enumerators in the default case is very large. In this case, it was
2, so we want to list them both explicitly to be warned about missing
one if we add one in the future.
into nTox.c. They are not used outside and nTox is not a library.
This change is