[splint-discuss] Using /*@null@*/

Charles Johnson charles.johnson at accre.vanderbilt.edu
Tue Apr 22 13:48:14 PDT 2008


I need a little help in using the /*@null@*/ annotation. I can't seem  
to find usage in the documentation. Here is the code snippet:

typedef struct {
   FILE *logfp;
   int   Threshold;
   int   FacilityList;
   } mlog_t;

mlog_t mlog = { (FILE *)NULL,0,0xffffffff };


splint produces this information:

null.c:8:17: Global mlog.logfp initialized to null value:
                 mlog.logfp = (FILE *)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)

If I alter the typdef like so:

typedef struct {
   /*@null@*/ FILE *logfp;
   int   Threshold;
   int   FacilityList;
   } mlog_t;

does not make splint happy. Making this change:

mlog_t mlog = { /*@null@*/ (FILE *)NULL,0,0xffffffff };

gives a parse error, and splint stops.

How should I be doing this, and where in the docs should I have found  
this? (splint -help annotations doesn't help either.)

TIA

Cheers--
Charles
---
Charles Johnson
Advanced Computing Center for Research and Education
Vanderbilt University
charles.johnson at accre.vanderbilt.edu
Office: 615-343-2776
Cell: 615-478-8799


More information about the splint-discuss mailing list