File: args.c

package info (click to toggle)
splint 1%3A3.1.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 21,012 kB
  • ctags: 23,302
  • sloc: ansic: 150,869; yacc: 3,465; sh: 3,034; makefile: 2,160; lex: 412
file content (79 lines) | stat: -rw-r--r-- 1,079 bytes parent folder | download | duplicates (10)
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
74
75
76
77
78
79
# include <stdarg.h>
# include "bool.h"
int sumn (int x, ...)
{
  int y = 0;
  void *yaba;
  va_list args;

  va_start (args, (void *)x); /* okay (args counts as out param) */
  while (x > 0)
    {
      x--;
      y = va_arg (args, int); /* okay */
      y = va_arg (args, char *); /* type error */
      y = va_arg (yaba, int); /* error */
    }
  return y;
}

int test (int x, char *s)
{
  x = sumn(); /* bad */
  x = sumn(x); /* okay */
  x = sumn(s); /* bad */
  x = sumn(x, s); /* okay */

  x = test (x, s, x); /* bad */
  return x;
}

int missingargs (int x, int y)  /* this is okay */
{
  y = x;
  return x;
}

int severalargs (char c, int y, bool b) /* first arg: int, second char *, third extra */
{
  if (b) { c = 'a'; }
  return y;
}

int severalargs2 (int x)  /* bad */
{
  return x;
}

int voidargs (char c) /* bad */
{
  c = 'a'; 
  return 3;
}

int any (...) /* ok */
{
  return 3;
}

int many1 (int x, char c, float f) /* bad */
{
  x;
  c;
  f;
  return x;
}

int many2 (int x, char c, ...)
{
  c;
  return x;
}

int many3 (int x) /* bad */
{
  return x;
}