redsocks.c: In function 'redsocks_read_expected':
redsocks.c:407: warning: unused variable 'read'
http-relay.c: In function 'httpr_client_read_cb':
http-relay.c:520: warning: unused variable 'written_wo_null'
These variables are used in asserts and if asserts are not compiled,
e.g. by defining NDEBUG (usually in CFLAGS via -DNDEBUG), then we have
misleading warnings.
Add in utils.h UNUSED() macro for creating null statement with result
casted to void. Use it to fix above warnings.
scan-build result for socks5.c:256:
Function call argument is an uninitialized value
nextstate can be undefined reply's addrtype field has unexpected value.
Fix by adding else case before to report error, drop client and return
from socks5_read_reply() function.
scan-build result for main.c:144, parser.c:193:
Result of operation is garbage or undefined
If there is early error in main() in second FOREACH block, then
terminators array is not itialized before access in shutdown path.
Fix by moving memset() to precede this block.
gettoken() does not initialize copytype enum value, so can have a
garbage value at some point. Add else case to the chain of **iter tests
to report error and return from the function.
scan-build result for http-auth.c:181:
Argument with 'nonnull' attribute passed null
The bug it found is spurious, because requires impossible execution path
(visible to static analyzer due to omitted elses in code and tool's
stupidity), but it actually helped in finding real bug.
Many rules were applied to make Makefile better:
- Use all capitals for variable names. (readability)
- Introduce new variables, such as LIBS. (reusability)
- Use immediate values instead of deferred ones. (performance)
- Remove reimplemented implicit rules. (size)
- Prevent part of CFLAGS from being overwritten. (correctness)
- Create file w/ dependencies even if there is no gcc. (portability)
- Improve main output rule by respecting LDFLAGS. (correctness)
- Improve main output rule by respecting CFLAGS. (convenience)
- Remove error-prone -MP switch from gcc invocation listing dependencies.
- Use $^ instead of $+, as there is no need for duplication support yet.
- Use -include to prevent warnings if included file does not exist.
Remove warning regarding optlen being size_t.
BTW:
- size_t is at least 16-bit unsigned integral type,
- socklen_t is at least 32-bit signed integral type.
It obviously doesn't matter here, because sizeof(int) fits in 4 bits.
Remove warnings in archs using LP64 by dealing with [s]size_t arguments.
There is a special length modifier 'z' that should precede integer
conversion specifier in format strings using [s]size_t arguments.