M
Martin Herbert Dietze
Hello,
consider this code:
| /* warning613.c */
| #include <assert.h>
| #include <string.h>
|
| size_t
| myStrLen(char const* s)
| {
| assert (s != NULL);
| return strlen (s);
| }
Now when I run flexelint like this:
| lint +v -i`pwd`/flint/ansi -u warning613.c
(./flint/ansi contains the ansi headers provided with flint,
the -u suppresses the warning about myStrLen() not being
referenced)
I now get this diagnosis message:
| FlexeLint for C/C++ (Unix) Vers. 8.00v, Copyright Gimpel Software 1985-2006
|
| --- Module: warning613.c (C)--- Module: warning613.c (C)
|
| _
| return strlen (s);
| warning613.c 8 Warning 668: Possibly passing a null pointer to function
| 'strlen(const char *)', arg. no. 1 [Reference: file
| warning613.c: line 7]
| warning613.c 7 Info 831: Reference cited in prior message
Of course I could put an "if (s != NULL)" into the code, but
since this example is taken from some larger piece of code and
s not being NULL is actually a precondition to the real
function, this would seem an unnecessary "lint-happy". When
checking the code with splint this error is not reported.
Any idea?
Cheers,
Martin
consider this code:
| /* warning613.c */
| #include <assert.h>
| #include <string.h>
|
| size_t
| myStrLen(char const* s)
| {
| assert (s != NULL);
| return strlen (s);
| }
Now when I run flexelint like this:
| lint +v -i`pwd`/flint/ansi -u warning613.c
(./flint/ansi contains the ansi headers provided with flint,
the -u suppresses the warning about myStrLen() not being
referenced)
I now get this diagnosis message:
| FlexeLint for C/C++ (Unix) Vers. 8.00v, Copyright Gimpel Software 1985-2006
|
| --- Module: warning613.c (C)--- Module: warning613.c (C)
|
| _
| return strlen (s);
| warning613.c 8 Warning 668: Possibly passing a null pointer to function
| 'strlen(const char *)', arg. no. 1 [Reference: file
| warning613.c: line 7]
| warning613.c 7 Info 831: Reference cited in prior message
Of course I could put an "if (s != NULL)" into the code, but
since this example is taken from some larger piece of code and
s not being NULL is actually a precondition to the real
function, this would seem an unnecessary "lint-happy". When
checking the code with splint this error is not reported.
Any idea?
Cheers,
Martin