File: alias.c

package info (click to toggle)
splint 3.1.2.dfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 14,732 kB
  • ctags: 16,317
  • sloc: ansic: 150,320; yacc: 3,463; sh: 3,003; makefile: 2,153; lex: 412
file content (58 lines) | stat: -rw-r--r-- 1,133 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
53
54
55
56
57
58
# include "mut.h"

int glob;
int *globp;

int f(int *a, int b, int **c)
{
  int *x, *y, *z;

  x = a;   
  *x = 3;  /* 1. modifies *a */
  x = a;
  y = x;
  *y = 4;  /* 2. modifies *a */

  globp = a;  /* 3. modifies *globp */
  if (*x == 3) return 3; /* 4. returns aliasing globp */

  if (*x == 4) 
    {
      globp = z; /* 5, 6. z use before def, modifies globp */
      return 4; /* okay */
    }
  
  *globp = 4; /* 7, 8. modifies *a, *globp */

  x = globp;
  *x = 7;     /* 9, 10. modifies *globp, *a */

  x = &glob;
  *x = 4;    /* 11. modifies glob */

  x = &b;  /* okay */
  *x = 3;  /* okay */
  b = 3;   /* okay */
  *x = b;  /* okay */
  x = *c;  /* okay */
  *x = 4;  /* 12. modifies **c */
  a = *c;  /* okay */
  *a = 4;  /* 13. modifies **c (but not *a) */
  *globp = 3; /* 14, 15. modifies *globp, modifies *a */
  return 4;   /* 16. returns with globp aliasing a */
}

int h (mut a, mut b) 
{ 
  mut c = mut_create();

  mut_mod (a);  /* 17. modifies a */
  a = b;
  mut_mod (a);  /* 18. modifies b */
  b = c; 
  mut_mod (b);  /* okay */

  return 3;     /* 19. locally allocated storage c not released */
}