<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:'times new roman', 'new york', times, serif;font-size:12pt"><div>For routines from external libraries, I created a single file I called splintdefs.h, which was included from my source files:</div><div><br></div><div>#ifdef S_SPLINT_S</div><div>#include "splintdefs.h"</div><div>#endif</div><div><br></div><div>so that it doesn't affect normal compilation. I then copy the prototypes from the external headers into that file and annotate them.</div><div><br></div><div>Phil</div><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><br><div style="font-family:arial, helvetica, sans-serif;font-size:10pt"><font size="2" face="Tahoma"><hr size="1"><b><span style="font-weight: bold;">From:</span></b> Marcus Martin <nymaen@yahoo.com><br><b><span style="font-weight: bold;">To:</span></b>
splint-discuss@mail.cs.virginia.edu<br><b><span style="font-weight: bold;">Sent:</span></b> Saturday, April 18, 2009 9:38:33 AM<br><b><span style="font-weight: bold;">Subject:</span></b> [splint-discuss] Splint usage help<br></font><br><br><Please ignore the first message, this one is in plain text.><br><br><br>I<br>am a new splint user and am having some difficutly with the<br>annotations. I read the documentation and looked at the examples and<br>still have some trouble. Can someone please help me get started?<br><br>I have the source code line:<br>const char *subCmds[] = { "-file", "-stream", NULL }; <br><br>This<br>array needs to have the last element be NULL so when used a parameter<br>in a method, the method knows when to stop reading the array. Splint<br>produces the following errors.<br><br>test.c:94:68: Index of possibly null pointer subCmds: subCmds<br> A possibly null pointer is dereferenced. Value is either the result of a<br>
function which may return null (in which case, code should check it is not<br> null), or a global, parameter or structure field declared with the null<br> qualifier. (Use -nullderef to inhibit warning)<br> test.c:94:27: Storage subCmds may become null<br>test.c:94:61: Local subCmds[2] initialized to null value: subCmds[2] = NULL<br> A reference with no null annotation is assigned or initialized to NULL. Use<br> /*@null@*/ to declare the reference as a possibly null pointer. (Use<br> -nullassign to inhibit warning)<br><br>After reading the warnings I tried changing the source line in the following ways, none of which worked for me.<br><br>/*@-nullderef@*/ const char *subCmds[] = { "-file", "-stream", NULL }; /*@=nullderef@*/ <br>/*@-nullassign@*/ const char *subCmds[] = { "-file", "-stream", NULL }; /*@=nullassign@*/<br>const char *subCmds[] = { "-file", "-stream", /*@null@*/ NULL }; <br><br>The<br>second problem I encountered is
that splint wants me to annotate the<br>header files of exeternal packages I call to indicate out parameters<br>and parameters that can be NULL. Since I don't own that source code,I<br>really don't want to change it. How do I indicate to splint where I<br>invoked the method that my parameters are correct and the method is<br>used correctly.<br><br>The third issue is that I am creating a shared<br>library that implements the interface. At no place in my code base<br>will I call these public interface methods. How can I tell splint that<br>these methods are exported and not called directly, but that is okay.<br><br>Can<br>someone tell me what I am doing wrong? Once I understand these three<br>problems, I should be able to fix the rest of my module.<br><br>Marcus<br><br><br> <br>_______________________________________________<br>splint-discuss mailing list<br><a ymailto="mailto:splint-discuss@mail.cs.virginia.edu"
href="mailto:splint-discuss@mail.cs.virginia.edu">splint-discuss@mail.cs.virginia.edu</a><br><a href="http://www.cs.virginia.edu/mailman/listinfo/splint-discuss" target="_blank">http://www.cs.virginia.edu/mailman/listinfo/splint-discuss</a><br></div></div><div style="position:fixed"></div></div></body></html>