]> andersk Git - splint.git/blob - test/temp/yeates
Removed stray files in test
[splint.git] / test / temp / yeates
1 From owner-lclint-interest@virginia.edu Fri May 25 20:18 EDT 2001
2 X-Mailer: exmh version 2.2 06/23/2000 with version: MH 6.8.3 #8[UCI]
3 To: lclint-interest@cs.virginia.edu
4 Subject: lack of control flow analysis
5 Mime-Version: 1.0
6 Date: Fri, 25 May 2001 17:12:18 -0700
7 From: Mathew Yeates <mathew@fugue.jpl.nasa.gov>
8 Precedence: bulk
9 Content-Type: text/plain; charset=us-ascii
10 Content-Length: 1277
11
12
13 I did some more work on the problem I sent yesterday. Here is a slightly 
14 modified version.
15 Even though line 14 is never executed, it causes s->i to go dead because 
16 "free" takes an
17 "only" param. And, even if line 13 were executed,  line 18 would not be 
18 executed
19 because of the "return" statement. It appears that lclint cannot tell when a 
20 particular branch
21 is impossible in a particular context.
22
23 The error I get from the following program is
24 t.c:18:7: Dead storage s->i passed as out parameter: s->i
25
26
27
28 1  #include <stdlib.h>
29      2  int foo(   /*@out@*/char  *  b  );
30      3
31      4  struct s {
32      5      /*@reldef@ *//*@relnull@ */ char *i;
33      6  };
34      7
35      8  static int redir(struct s *s)
36      9  {
37     10      s->i = malloc(1 * sizeof(int));
38     11      if (!(s->i))
39     12          return 1;
40     13      if (0) {
41     14          free(s->i);
42     15          return 1;
43     16      }
44     17      if (foo(s->i) == 1) {
45     18          free(s->i);
46     19          /*@-usereleased@ */
47     20          return 1;
48     21          /*@=usereleased@ */
49     22      }
50     23  /*@-usereleased@ */
51     24      return 0;
52     25  /*@=usereleased@ */
53     26  }
54     27
55     28  void goo(void)
56     29  {
57     30      struct s s;
58     31      if (redir(&s) == 1) exit(0);
59     32  }
60
61
62
This page took 0.041052 seconds and 5 git commands to generate.