File: outparam.c

package info (click to toggle)
splint 3.1.2.dfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, squeeze, wheezy
  • size: 12,908 kB
  • ctags: 15,816
  • sloc: ansic: 150,306; yacc: 3,463; sh: 3,426; makefile: 2,218; lex: 412
file content (52 lines) | stat: -rw-r--r-- 1,165 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
typedef struct _st { int a; int b; } *st;

void h(st s, st t)
{
  int i;
  st u1, u2;

  u1->a = 3; /* 1. Variable u1 used before definition */
  u2 = u1;
  i = u2->a; 

  i = (*s).a; /* 2. Field s->a used before definition */
  t->a = i;  
}

void f(/*@out@*/ int *a, int *b)
{
  int x;
  int *y;

  x = *a;  /* 3. Value *a used before definition */
  x = *a;  /* not reported */
  x = *a;  /* not reported */
  x = *b; 

  y = a;  
  *a = 3; 
}

int g()
{
  int *b;
  int *c, *d;
  st s, t, t2, t3, t4;
  struct _st u;

  f(c, b);      /* 4, 5. Unallocated storage c passed as out parameter: c,
	                 Variable b used before definition */
  f(d, c);      /* 6. Unallocated storage d passed as out parameter: d */
  *c = *d; 
  s = t;        /* 7. Variable t used before definition */
  s = t2->a;    /* 8, 9. Variable t2 used before definition, 
		         Assignment of int to st: s = t2->a */
  t3->a = 3;   /* 10. Variable t3 used before definition */
  u.a = 3;   
  t4 = (st)malloc(sizeof(struct _st));
  t4->a = 3;   /* 11. Possible arrow access from null pointer: t4 */
  return *b;   /* 10. Fresh storage not released before return: t4 */
}