Hello, I wanted to share the output of a static code analysis tool that a user mentioned on IRC.
Philipp claimed that these were found using cppcheck, version 1.75 dev, with with --inconclusive --enable=all http://cppcheck.sourceforge.net/ >From http://codepad.org/2oAAx6OX [F:\serf\auth\auth.c:219]: (style) The scope of the variable 'hdrs' can be reduced. [F:\serf\auth\auth_digest.c:290]: (style) Redundant condition: If 'EXPR == ' '', the comparison 'EXPR' is always true. [F:\serf\auth\auth_spnego.c:476] -> [F:\serf\auth\auth_spnego.c:458]: (warning) Either the condition 'gss_info' is redundant or there is possible null pointer dereference: gss_info. [F:\serf\auth\auth_spnego_gss.c:71]: (style) Variable 'maj_stat' is assigned a value that is never used. [F:\serf\auth\auth_digest.c:507]: (style) Redundant condition: If 'EXPR == ' '', the comparison 'EXPR' is always true. [F:\serf\buckets\aggregate_buckets.c:504]: (style) The scope of the variable 'found_bucket' can be reduced. [F:\serf\buckets\allocator.c:87]: (style) struct member 'read_status_t::bucket' is never used. [F:\serf\buckets\chunk_buckets.c:66]: (style) The scope of the variable 'simple_bkt' can be reduced. [F:\serf\buckets\fcgi_buckets.c:513]: (style) The scope of the variable 'tmp' can be reduced. [F:\serf\buckets\hpack_buckets.c:1479]: (style) Variable 'status' is assigned a value that is never used. [F:\serf\protocols\fcgi_protocol.c:65]: (warning) Redundant assignment of 'fcgi' to itself. [F:\serf\protocols\fcgi_protocol.c:65]: (style) Variable 'fcgi' is assigned a value that is never used. [F:\serf\buckets\ssl_buckets.c:2469] -> [F:\serf\buckets\ssl_buckets.c:2475]: (warning) Either the condition 'if(ssl_ctx)' is redundant or there is possible null pointer dereference: ssl_ctx. [F:\serf\buckets\ssl_buckets.c:2472] -> [F:\serf\buckets\ssl_buckets.c:2475]: (warning) Either the condition 'if(ssl_ctx)' is redundant or there is possible null pointer dereference: ssl_ctx. [F:\serf\buckets\ssl_buckets.c:2040]: (style, inconclusive) Consecutive return, break, continue, goto or throw statements are unnecessary. [F:\serf\buckets\ssl_buckets.c:738]: (style) The scope of the variable 'buf' can be reduced. [F:\serf\buckets\ssl_buckets.c:739]: (style) The scope of the variable 'length' can be reduced. [F:\serf\buckets\ssl_buckets.c:1835]: (style) Variable 'raw_header' is assigned a value that is never used. [F:\serf\src\logging.c:109]: (style) The scope of the variable 'argp' can be reduced. [F:\serf\src\logging.c:141]: (style) The scope of the variable 'argp' can be reduced. [F:\serf\src\outgoing.c:75]: (style) Redundant condition: !conn.pipelining. 'A || (!A && B)' is equivalent to 'A || B' [F:\serf\test\CuTest.c:388]: (style) The scope of the variable 'i' can be reduced. [F:\serf\test\CuTest.c:389]: (style) The scope of the variable 'failCount' can be reduced. [F:\serf\test\CuTest.c:167]: (error, inconclusive) Address of local auto-variable assigned to a function parameter. [F:\serf\test\serf_get.c:869]: (style) The scope of the variable 'buf' can be reduced. [F:\serf\test\serf_httpd.c:489]: (style) The scope of the variable 'buf' can be reduced. [F:\serf\test\serf_response.c:82]: (style) The scope of the variable 's' can be reduced. I might look at some of these when I find some idle time, or maybe someone else is interested or has comments on the above. Andreas