lclint-interest message 136
From: Peter Holm [pho@login.dknet.dk]
Sent: Monday, March 17, 1997 6:31 PM
To: lclint-interest@larch.lcs.mit.edu
Subject: List problem
I have a problem with comma separated lists of statements. It seems as
thou lclint doesn't recognise that xSysPanic will exit, if p == NULL.
If I replace "sysPanic" in line 17 with "xSysPanic" all is fine.
1 #include
2
3 extern /*@observer@*/ const char *FileName;
4 extern int LineNumber;
5
6 extern /*@notnull@*/ /*@out @*/ /*@only@*/ void *myMalloc(size_t size);
7
8 #define sysPanic FileName = __FILE__, LineNumber = __LINE__, xSysPanic
9
10 extern /*@exits@*/ void xSysPanic(char *format, ...);
11
12 void *
13 myMalloc(size_t size) {
14 void *p;
15
16 p = malloc(size);
17 if (p == NULL) sysPanic("malloc(%d) failed", size);
18 return p;
19 }
LCLint 2.2a --- 04 Sep 96
x.c: (in function myMalloc) x.c:18,16: Possibly null storage p returned as non-null: p Function returns a possibly null pointer, but is not declared using /*@null@*/ annotation of result. If function may
return NULL, add /*@null@*/ annotation to the return value declaration. (-nullret will suppress message)
x.c:16,13: Storage p may become null
Finished LCLint checking --- 1 code error found
Am I doing some thing wrong?
Regards,
Peter Holm
David
Evans
University of Virginia, Computer Science
evans@cs.virginia.edu