home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lclint.zip / lclint-2_3h-os2-bin.zip / test / null6.c < prev    next >
C/C++ Source or Header  |  1997-09-03  |  1KB  |  84 lines

  1. typedef /*@null@*/ int *mnull;
  2.  
  3. extern /*@notnull@*/ mnull mnull_create (void);
  4.  
  5. extern int f1 (/*@notnull@*/ mnull x); /* 1. Function f1 declared with notnull ... */
  6.  
  7. int f (mnull x)
  8. {
  9.   return *x; /* 2. Possible dereference of null pointer: *x */
  10. }
  11.  
  12. static /*@unused@*/ int f2 (/*@notnull@*/ mnull x)
  13. {
  14.   return *x;
  15. }
  16.  
  17. extern /*@falsenull@*/ bool isThree (mnull x);
  18.  
  19. static /*@unused@*/ int f3 (/*@notnull@*/ mnull x)
  20. {
  21.   if (isThree)
  22.     {
  23.       *x = 4;
  24.     }
  25.   else
  26.     {
  27.       *x = 5;
  28.     }
  29.  
  30.   return (*x);
  31. }
  32.  
  33. /*@notnull@*/ mnull f4 (void)
  34. {
  35.   mnull x = NULL;
  36.  
  37.   if (x == NULL)
  38.     {
  39.       x = mnull_create ();
  40.     } 
  41.  
  42.   return x;
  43. }
  44.  
  45. /*@notnull@*/ mnull f5 (void)
  46. {
  47.   static /*@only@*/ mnull x = NULL;
  48.  
  49.   if (x == NULL)
  50.     {
  51.       x = mnull_create ();
  52.     } 
  53.  
  54.   return x;
  55. }
  56.  
  57. /*@notnull@*/ mnull f6 (void)
  58. {
  59.   static /*@only@*/ mnull x = NULL;
  60.  
  61.   if (x != NULL)
  62.     {
  63.       x = mnull_create ();
  64.     } 
  65.  
  66.   return x; /* 3. Possibly null storage returned as non-null */
  67. }
  68.  
  69. /*@notnull@*/ mnull f7 (void)
  70. {
  71.   static /*@only@*/ mnull x = NULL;
  72.  
  73.   if (x == NULL)
  74.     {
  75.       x = mnull_create ();
  76.     } 
  77.   else
  78.     {
  79.       x = NULL;
  80.     }
  81.  
  82.   return x; /* 4. Possibly null storage returned as non-null */
  83. }
  84.