Various minor fixes for compiler/linter (other then splint itself) warnings.
[splint-patched.git] / test / special.c
blob7c9fc867e62bb4040377219f8ca64203c4d4ee66
1 char gc;
2 int gi;
3 char *gs;
5 int f()
7 char c;
8 unsigned char uc;
9 int i;
10 long int li = 23;
11 short int silly = 3;
12 char *s;
14 printf("hullo this is a %s !", "test");
15 (void) scanf("hullo, welcome to %d", &i); /* defines i */
17 printf("even %d %c harder", i, c); /* 1. Variable c used before definition */
18 uc = 'a';
19 printf("even %d %c harder", li, uc); /* 2. printf format arg 1 (%d) expects int gets long int: li */
20 printf("even %ld %d %hd %hd %d harder", i, li, i, silly, silly); /* 3, 4. [5, 6.]
21 * arg1 (expects long),
22 arg2 (expects int),
23 arg3 (expects short),
24 * (okay if +relaxquals) arg5 (expects int) */
26 (void) scanf("%*d okay"); /* [NO! 5. Statement has no effect] */
27 printf("%s %s", s, s); /* 5. Variable s used before definition */
29 printf("a real %+14.3i", c, i); /* 6, 7. printf format arg 1 (%i) expects int gets char: c, extra arg */
30 fprintf(stdout, "a real %+14.33i", c, i); /* 8, 9. fprintf format arg 1 (%i) expects int gets char: c, extra */
31 printf("%% %d %f %f", c, i); /* 10, 11, 12. printf format arg 1, arg2, missing arg 3 */
33 (void) scanf("hullo, welcome to %d", &i);
34 (void) scanf("hullo, welcome to %d", i); /* 13. scanf format arg 1 (%d) expects int * gets int: i */
36 /* 3 type errors */
37 (void) fscanf(stdin, "hullo, welcome to %d %c %s", i, c, &s); /* 14, 15, 16. arg1, arg2, arg3 */
39 /* 3 modification errors */
40 (void) fscanf(stdin, "hullo, welcome to %23d %c %s", &gi, &gc, gs); /* 17, 18, 19. modifies g1, gc, gs */
41 /* 1 modification error */
42 (void) fscanf(stdin, "hullo, welcome to %*23d %*c %s", gs); /* 20. modifies gs */
44 return 3;