[splint-discuss] Splint usage help

Brian Quinlan brian.quinlan at iolfree.ie
Sun Apr 19 14:15:08 PDT 2009


On Sat, 2009-04-18 at 20:48 -0400, Marcus Martin wrote:
> Brian's suggestion worked perfectly.
> 
> typedef /*@null@*/ const char *StringListElement;
> StringListElement subCmds[] = { "-file", "-stream", NULL };
> 
> Results in no errors.
> 
> When I tried Chuck's suggestion, I still got one warning.
> const char *subCmds[] = { "-file", "-stream", (const char*)NULL };
> 
> test.c: (in function TestMethod)
> test.c:103:51: Local subCmds[2] initialized to null value:
>                   subCmds[2] = (const char *)NULL
>   A reference with no null annotation is assigned or initialized to 
> NULL.  Use
>   /*@null@*/ to declare the reference as a possibly null pointer. (Use
>   -nullassign to inhibit warning)
> 
> Any ideas on how I misunderstood chuck?
> 
> Marcus
> 
The original problem indicated by splint was not that NULL is not char*,
so casting won't have an effect. Rather, the problem was that subCmds[2]
defaults to /*@notnull@*/ and therefore you can't assign null to it. I'm
not convinced that the problem can be solved in a single line. However,
I am convinced that, if it is possible, then the /*@null@*/ annotation
will be required.

BQ



More information about the splint-discuss mailing list