File: switch.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 (73 lines) | stat: -rw-r--r-- 1,037 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
int f1(int x)
{
  switch (x)
    {
    case 0: return 3;
    case 1: return 4;
    default: return 6;
    }
}

typedef enum _et { ONE, TWO, THREE } et;

int f2 (et x)
{
  switch (x)
    {
    case ONE: return 3;
    case TWO: return 8;
    case THREE: return 12;
    }
}

int f3 (et x)
{
  switch (x)
    {
    case ONE: return 3;
    case TWO: break;
    default:  return 12;
    }
} /* 1. Path with no return in function declared to return int */

int f4 (et x)
{
  switch (x)
    {
    case ONE: return 3;
    case TWO: return 14;
    default:  return 12;
    }
}

int f5 (et x)
{
  switch (x)
    {
    case ONE: return 3;
    case TWO: return 14;
    } /* 2. Missing case in switch: THREE */
} /* 3. Path with no return in function declared to return int */

int f6 (et x)
{
  switch (x)
    {
    case ONE: 
      if (3 > 4)
	{
	  return 3;
	}
      else
	{
	  return 12;
	}
    case TWO: 
      if (3 > 4) break;
      return 14;
    default:  return 12;
    }
} /* 4. Path with no return in function declared to return int */