[splint-discuss] Splint usage help

cbfalconer@maineline.net cbfalconer at att.net
Sat Apr 18 16:36:31 PDT 2009


Brian Quinlan wrote:
> Marcus Martin wrote:
>
>> I am a new splint user and am having some difficutly with the
>> annotations. I read the documentation and looked at the examples
>> and still have some trouble.  
>>
>> I have the source code line:
>> const char *subCmds[] = { "-file", "-stream", NULL };
> 
> typedef /*@null@*/ const char *StringListElement;
> StringListElement subCmds[] = { "-file", "-stream", NULL };
> 
> The basic problem is that splint (reasonably) assumes const char*
> is non-null. In this case, you need to change this assumption by
> using the the /*@null@*/ annotation. Adding it directly to your
> line doesn't work. I think this is because this tells splint the
> array, rather than each array element, can be null. There might
> be a way of achieving the same effect without the two line hack,
> but I don't see it myself.

I'm not using splint now, but I suspect you can handle it by
controlling your source.  subCmds has been declared to be an array
of pointers to char.  Simply ensure that you initialize it with
such.  Try "(char*)NULL".  Some headers define NULL as 0, rather
than as "(void*) 0", which is fine as the default conversion
converts a zero to a pointer.  You don't need the typedef.

-- 
 [mail]: Chuck F (cbfalconer at maineline dot net) 
 [page]: <http://cbfalconer.home.att.net>
            Try the download section.




More information about the splint-discuss mailing list