Various minor fixes for compiler/linter (other then splint itself) warnings.
[splint-patched.git] / test / null6.c
blob0a848ed404cee99a23354e22c997329c605ba285
1 # include "bool.h"
3 typedef /*@null@*/ int *mnull;
5 extern /*@notnull@*/ mnull mnull_create (void);
7 extern int f1 (/*@notnull@*/ mnull x); /* 1. Function f1 declared with notnull ... */
9 int f (mnull x)
11 return *x; /* 2. Possible dereference of null pointer: *x */
14 static /*@unused@*/ int f2 (/*@notnull@*/ mnull x)
16 return *x;
19 extern /*@falsenull@*/ bool isThree (mnull x);
21 static /*@unused@*/ int f3 (/*@notnull@*/ mnull x)
23 if (isThree (x)) /* the parameter was missing before 2.4! */
25 *x = 4;
27 else
29 *x = 5;
32 return (*x);
35 /*@notnull@*/ mnull f4 (void)
37 mnull x = NULL;
39 if (x == NULL)
41 x = mnull_create ();
44 return x;
47 /*@notnull@*/ mnull f5 (void)
49 static /*@only@*/ mnull x = NULL;
51 if (x == NULL)
53 x = mnull_create ();
56 return x;
59 /*@notnull@*/ mnull f6 (void)
61 static /*@only@*/ mnull x = NULL;
63 if (x != NULL)
65 x = mnull_create ();
68 return x; /* 3. Possibly null storage returned as non-null */
71 /*@notnull@*/ mnull f7 (void)
73 static /*@only@*/ mnull x = NULL;
75 if (x == NULL)
77 x = mnull_create ();
79 else
81 x = NULL;
84 return x; /* 4. Possibly null storage returned as non-null */