Wireshark-bugs: [Wireshark-bugs] [Bug 7770] Failure to check for return values after calls to ca
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7770
--- Comment #1 from Guy Harris <guy@xxxxxxxxxxxx> 2012-09-29 12:23:11 PDT ---
(In reply to comment #0)
> Several of the checks also test the return value against 0, but this is not
> quite correct (compiler/OS compatibility),
That could be true if the compiler and/or OS do not correctly implement the
programming language ANSI X3.159-1989 "Programming Language C", ISO/IEC
9899:1990, ISO/IEC 9899:1999, or ISO/IEC 9899:2011, but anything correctly
implementing them will allow either
char *p;
...
if (p == 0)
...
or
char *p;
...
if (p == NULL)
...
or
char *p;
...
if (!p)
...
and treat all three of them as meaning the same thing. See, for example, C90:
6.2.2.3 Pointers
An integral constant expression with the value 0, or such an expression
cast to type void *,[33]
is called a "null pointer constant". If a null pointer constant is assigned to
or compared for equality to a pointer, the constant is converted to a pointer
of that type. Such a pointer, called a "null pointer", is guaranteed to compare
unequal to a pointer to any object or function.
...
33 The macro NULL is defined in <stddef.h> as a null pointer constant; see
7.1.6.
My personal *stylistic* preference is for "if (p == NULL)", but all three of
them are valid C and mean the same thing.
--
Configure bugmail: https://bugs.wireshark.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all bug changes.