On Feb 15, 2011, at 5:33 PM, Gerald Combs wrote:
> The trunk buildbot now has two additional buildslaves: one that runs the
> C/C++ code analyzer in Visual Studio 10 Premium and one that runs the
> Clang Static Analyzer. They are scheduled to run once a day at 9:00 PM
> PST (5:00 AM UTC) for the time being.
The following change:
> http://anonsvn.wireshark.org/viewvc/viewvc.cgi?view=rev&revision=35973
>
> User: guy
> Date: 2011/02/16 08:35 PM
>
> Log:
> Use "XXX != NULL" rather than "XXX" to test for a null pointer; either
> I'm missing something or the MSVC++ code analyzer doesn't realize that
> in
>
> if (XXX)
> dereference XXX
>
> will not dereference XXX if it's null - maybe "if (XXX != NULL)" will do
> the trick (if so, the code analyzer is buggy, because "if (XXX !=
> NULL)", "if (XXX != 0)", and "if (XXX)" mean the exact same thing if XXX
> is a pointer-valued expression, really, truly, even if a null pointer
> isn't represented as all zero bits or if it's wider than an int).
>
> Clean up indentation.
>
> Directory: /trunk/
> Changes Path Action
> +31 -32 capture_ui_utils.c Modified
which, other than the indentation change, was:
Index: capture_ui_utils.c
===================================================================
230d229
<
241c240
< if (if_info && if_info->description != NULL) {
---
> if (if_info != NULL && if_info->description != NULL) {
caused the output of the VC++ 10 code analyzer to go from
...
c:\buildbot\wireshark\trunk-vs-eca\vscodeanalysis\build\capture_ui_utils.c(241) : warning C6011: Dereferencing NULL pointer 'if_info': Lines: 226, 227, 228, 232, 233, 240, 241
c:\buildbot\wireshark\trunk-vs-eca\vscodeanalysis\build\capture_ui_utils.c(367) : warning C6328: 'const char' passed as parameter '1' when 'unsigned char' is required in call to 'isdigit'
...
to
...
c:\buildbot\wireshark\trunk-vs-eca\vscodeanalysis\build\capture_ui_utils.c(366) : warning C6328: 'const char' passed as parameter '1' when 'unsigned char' is required in call to 'isdigit'
...
the fact that "if (if_info && if_info->description != NULL)" and "if (if_info != NULL && if_info->description != NULL)" mean exactly the same thing according to ANSI X3.159-1989, "Programming Language - C." (Language lawyery available upon request - it's been a while since I last did that, so I can't do it from memory any more. :-))
I'll try a few more fixes of that sort and, if they squelch the bogus complaints, I'll add an item about it to README.developer.