Skip to content

Commit 0e9bcdd

Browse files
authored
FIO38-C FIO47-C FIO42-C tests (#213)
* Fix compilation error for FIO38 test * Fix FIO47 expected files * Fix compilation for FIO42-C
1 parent f1c2ebd commit 0e9bcdd

10 files changed

+289
-12
lines changed
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
| test.c:10:20:10:26 | * ... | A FILE object is being copied. |
2-
| test.c:17:21:17:30 | * ... | A FILE object is being copied. |
3-
| test.c:23:21:23:31 | * ... | A FILE object is being copied. |
4-
| test.c:29:15:29:21 | * ... | A FILE object is being copied. |
5-
| test.c:42:19:42:28 | * ... | A FILE object is being copied. |
1+
| test.c:11:20:11:26 | * ... | A FILE object is being copied. |
2+
| test.c:18:21:18:30 | * ... | A FILE object is being copied. |
3+
| test.c:24:21:24:31 | * ... | A FILE object is being copied. |
4+
| test.c:30:15:30:21 | * ... | A FILE object is being copied. |
5+
| test.c:43:19:43:28 | * ... | A FILE object is being copied. |
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
| test.c:4:20:4:26 | * ... | A FILE object is being copied. |
2+
| test.c:11:21:11:30 | * ... | A FILE object is being copied. |
3+
| test.c:17:21:17:31 | * ... | A FILE object is being copied. |
4+
| test.c:23:15:23:21 | * ... | A FILE object is being copied. |
5+
| test.c:36:19:36:28 | * ... | A FILE object is being copied. |
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
| test.c:4:20:4:26 | * ... | A FILE object is being copied. |
2+
| test.c:11:21:11:30 | * ... | A FILE object is being copied. |
3+
| test.c:17:21:17:31 | * ... | A FILE object is being copied. |
4+
| test.c:23:15:23:21 | * ... | A FILE object is being copied. |
5+
| test.c:36:19:36:28 | * ... | A FILE object is being copied. |

c/cert/test/rules/FIO38-C/test.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <stdio.h>
2+
// Workaround for the Musl implementing FILE as an incomplete type.
23
#if !defined(__DEFINED_struct__IO_FILE)
34
struct _IO_FILE {
45
char __x;
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#include <stdio.h>
2+
3+
int f1(void) {
4+
FILE my_stdout = *stdout; // NON_COMPLIANT
5+
return fputs("Hello, World!\n", &my_stdout);
6+
}
7+
8+
int f2(void) {
9+
FILE *my_stdout;
10+
my_stdout = stdout; // COMPLIANT
11+
FILE my_stdout2 = *my_stdout; // NON_COMPLIANT
12+
return fputs("Hello, World!\n", my_stdout);
13+
}
14+
int f2b(void) {
15+
FILE *const *my_stdout;
16+
my_stdout = &stdout; // COMPLIANT
17+
FILE my_stdout2 = **my_stdout; // NON_COMPLIANT
18+
return fputs("Hello, World!\n", *my_stdout);
19+
}
20+
21+
int f3(void) {
22+
FILE my_stdout;
23+
my_stdout = *stdout; // NON_COMPLIANT
24+
return fputs("Hello, World!\n", &my_stdout);
25+
}
26+
27+
int f4(void) {
28+
FILE *my_stdout;
29+
my_stdout = fopen("file.txt", "w"); // COMPLIANT
30+
return fputs("Hello, World!\n", my_stdout);
31+
}
32+
33+
int f5helper(FILE my_stdout) { return fputs("Hello, World!\n", &my_stdout); }
34+
int f5(void) {
35+
FILE *my_stdout = fopen("file.txt", "w"); // COMPLIANT
36+
return f5helper(*my_stdout); // NON_COMPLIANT
37+
}
38+
39+
int f6helper(FILE *my_stdout) { return fputs("Hello, World!\n", my_stdout); }
40+
int f6(void) {
41+
FILE *my_stdout = fopen("file.txt", "w"); // COMPLIANT
42+
return f6helper(my_stdout); // COMPLIANT
43+
}

c/cert/test/rules/FIO38-C/test.c.gcc

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#include <stdio.h>
2+
3+
int f1(void) {
4+
FILE my_stdout = *stdout; // NON_COMPLIANT
5+
return fputs("Hello, World!\n", &my_stdout);
6+
}
7+
8+
int f2(void) {
9+
FILE *my_stdout;
10+
my_stdout = stdout; // COMPLIANT
11+
FILE my_stdout2 = *my_stdout; // NON_COMPLIANT
12+
return fputs("Hello, World!\n", my_stdout);
13+
}
14+
int f2b(void) {
15+
FILE *const *my_stdout;
16+
my_stdout = &stdout; // COMPLIANT
17+
FILE my_stdout2 = **my_stdout; // NON_COMPLIANT
18+
return fputs("Hello, World!\n", *my_stdout);
19+
}
20+
21+
int f3(void) {
22+
FILE my_stdout;
23+
my_stdout = *stdout; // NON_COMPLIANT
24+
return fputs("Hello, World!\n", &my_stdout);
25+
}
26+
27+
int f4(void) {
28+
FILE *my_stdout;
29+
my_stdout = fopen("file.txt", "w"); // COMPLIANT
30+
return fputs("Hello, World!\n", my_stdout);
31+
}
32+
33+
int f5helper(FILE my_stdout) { return fputs("Hello, World!\n", &my_stdout); }
34+
int f5(void) {
35+
FILE *my_stdout = fopen("file.txt", "w"); // COMPLIANT
36+
return f5helper(*my_stdout); // NON_COMPLIANT
37+
}
38+
39+
int f6helper(FILE *my_stdout) { return fputs("Hello, World!\n", my_stdout); }
40+
int f6(void) {
41+
FILE *my_stdout = fopen("file.txt", "w"); // COMPLIANT
42+
return f6helper(my_stdout); // COMPLIANT
43+
}

c/cert/test/rules/FIO42-C/test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#include <fcntl.h>
22
#include <stdio.h>
33
#include <stdlib.h>
4+
#include <sys/stat.h>
45
#include <unistd.h>
5-
66
int f1a(const char *filename) {
77
FILE *f = fopen(filename, "r"); // NON_COMPLIANT
88
if (NULL == f) {
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
| test.c:376:17:376:30 | v_intmax_t_ptr | This argument should be of type 'int *' but is of type 'long *' |
2+
| test.c:378:17:378:28 | v_size_t_ptr | This argument should be of type 'int *' but is of type 'unsigned long *' |
3+
| test.c:380:17:380:31 | v_ptrdiff_t_ptr | This argument should be of type 'int *' but is of type 'long *' |
4+
| test.c:417:17:417:26 | v_char_ptr | This argument should be of type 'int' but is of type 'char *' |
5+
| test.c:421:18:421:27 | v_char_ptr | This argument should be of type 'int' but is of type 'char *' |
6+
| test.c:425:16:425:25 | v_char_ptr | This argument should be of type 'int' but is of type 'char *' |
7+
| test.c:426:17:426:26 | v_char_ptr | This argument should be of type 'int' but is of type 'char *' |
8+
| test.c:427:18:427:27 | v_char_ptr | This argument should be of type 'int' but is of type 'char *' |
9+
| test.c:428:17:428:26 | v_char_ptr | This argument should be of type 'long' but is of type 'char *' |
10+
| test.c:429:18:429:27 | v_char_ptr | This argument should be of type 'long long' but is of type 'char *' |
11+
| test.c:430:17:430:26 | v_char_ptr | This argument should be of type 'intmax_t' but is of type 'char *' |
12+
| test.c:432:17:432:26 | v_char_ptr | This argument should be of type 'ptrdiff_t' but is of type 'char *' |
13+
| test.c:434:16:434:25 | v_char_ptr | This argument should be of type 'int' but is of type 'char *' |
14+
| test.c:435:17:435:26 | v_char_ptr | This argument should be of type 'int' but is of type 'char *' |
15+
| test.c:436:18:436:27 | v_char_ptr | This argument should be of type 'int' but is of type 'char *' |
16+
| test.c:437:17:437:26 | v_char_ptr | This argument should be of type 'long' but is of type 'char *' |
17+
| test.c:438:18:438:27 | v_char_ptr | This argument should be of type 'long long' but is of type 'char *' |
18+
| test.c:439:17:439:26 | v_char_ptr | This argument should be of type 'intmax_t' but is of type 'char *' |
19+
| test.c:441:17:441:26 | v_char_ptr | This argument should be of type 'ptrdiff_t' but is of type 'char *' |
20+
| test.c:443:16:443:25 | v_char_ptr | This argument should be of type 'unsigned int' but is of type 'char *' |
21+
| test.c:444:17:444:26 | v_char_ptr | This argument should be of type 'unsigned int' but is of type 'char *' |
22+
| test.c:445:18:445:27 | v_char_ptr | This argument should be of type 'unsigned int' but is of type 'char *' |
23+
| test.c:446:17:446:26 | v_char_ptr | This argument should be of type 'unsigned long' but is of type 'char *' |
24+
| test.c:447:18:447:27 | v_char_ptr | This argument should be of type 'unsigned long long' but is of type 'char *' |
25+
| test.c:450:17:450:26 | v_char_ptr | This argument should be of type 'size_t' but is of type 'char *' |
26+
| test.c:454:16:454:25 | v_char_ptr | This argument should be of type 'unsigned int' but is of type 'char *' |
27+
| test.c:455:17:455:26 | v_char_ptr | This argument should be of type 'unsigned int' but is of type 'char *' |
28+
| test.c:456:18:456:27 | v_char_ptr | This argument should be of type 'unsigned int' but is of type 'char *' |
29+
| test.c:457:17:457:26 | v_char_ptr | This argument should be of type 'unsigned long' but is of type 'char *' |
30+
| test.c:458:18:458:27 | v_char_ptr | This argument should be of type 'unsigned long long' but is of type 'char *' |
31+
| test.c:461:17:461:26 | v_char_ptr | This argument should be of type 'size_t' but is of type 'char *' |
32+
| test.c:465:16:465:25 | v_char_ptr | This argument should be of type 'unsigned int' but is of type 'char *' |
33+
| test.c:466:17:466:26 | v_char_ptr | This argument should be of type 'unsigned int' but is of type 'char *' |
34+
| test.c:467:18:467:27 | v_char_ptr | This argument should be of type 'unsigned int' but is of type 'char *' |
35+
| test.c:468:17:468:26 | v_char_ptr | This argument should be of type 'unsigned long' but is of type 'char *' |
36+
| test.c:469:18:469:27 | v_char_ptr | This argument should be of type 'unsigned long long' but is of type 'char *' |
37+
| test.c:472:17:472:26 | v_char_ptr | This argument should be of type 'size_t' but is of type 'char *' |
38+
| test.c:476:16:476:25 | v_char_ptr | This argument should be of type 'unsigned int' but is of type 'char *' |
39+
| test.c:477:17:477:26 | v_char_ptr | This argument should be of type 'unsigned int' but is of type 'char *' |
40+
| test.c:478:18:478:27 | v_char_ptr | This argument should be of type 'unsigned int' but is of type 'char *' |
41+
| test.c:479:17:479:26 | v_char_ptr | This argument should be of type 'unsigned long' but is of type 'char *' |
42+
| test.c:480:18:480:27 | v_char_ptr | This argument should be of type 'unsigned long long' but is of type 'char *' |
43+
| test.c:483:17:483:26 | v_char_ptr | This argument should be of type 'size_t' but is of type 'char *' |
44+
| test.c:487:16:487:25 | v_char_ptr | This argument should be of type 'double' but is of type 'char *' |
45+
| test.c:488:17:488:26 | v_char_ptr | This argument should be of type 'double' but is of type 'char *' |
46+
| test.c:489:18:489:27 | v_char_ptr | This argument should be of type 'long double' but is of type 'char *' |
47+
| test.c:490:17:490:26 | v_char_ptr | This argument should be of type 'long double' but is of type 'char *' |
48+
| test.c:492:16:492:25 | v_char_ptr | This argument should be of type 'double' but is of type 'char *' |
49+
| test.c:493:17:493:26 | v_char_ptr | This argument should be of type 'double' but is of type 'char *' |
50+
| test.c:494:18:494:27 | v_char_ptr | This argument should be of type 'long double' but is of type 'char *' |
51+
| test.c:495:17:495:26 | v_char_ptr | This argument should be of type 'long double' but is of type 'char *' |
52+
| test.c:497:16:497:25 | v_char_ptr | This argument should be of type 'double' but is of type 'char *' |
53+
| test.c:498:17:498:26 | v_char_ptr | This argument should be of type 'double' but is of type 'char *' |
54+
| test.c:499:18:499:27 | v_char_ptr | This argument should be of type 'long double' but is of type 'char *' |
55+
| test.c:500:17:500:26 | v_char_ptr | This argument should be of type 'long double' but is of type 'char *' |
56+
| test.c:502:16:502:25 | v_char_ptr | This argument should be of type 'double' but is of type 'char *' |
57+
| test.c:503:17:503:26 | v_char_ptr | This argument should be of type 'double' but is of type 'char *' |
58+
| test.c:504:18:504:27 | v_char_ptr | This argument should be of type 'long double' but is of type 'char *' |
59+
| test.c:505:17:505:26 | v_char_ptr | This argument should be of type 'long double' but is of type 'char *' |
60+
| test.c:507:16:507:25 | v_char_ptr | This argument should be of type 'double' but is of type 'char *' |
61+
| test.c:508:17:508:26 | v_char_ptr | This argument should be of type 'double' but is of type 'char *' |
62+
| test.c:509:18:509:27 | v_char_ptr | This argument should be of type 'long double' but is of type 'char *' |
63+
| test.c:510:17:510:26 | v_char_ptr | This argument should be of type 'long double' but is of type 'char *' |
64+
| test.c:512:16:512:25 | v_char_ptr | This argument should be of type 'double' but is of type 'char *' |
65+
| test.c:513:17:513:26 | v_char_ptr | This argument should be of type 'double' but is of type 'char *' |
66+
| test.c:514:18:514:27 | v_char_ptr | This argument should be of type 'long double' but is of type 'char *' |
67+
| test.c:515:17:515:26 | v_char_ptr | This argument should be of type 'long double' but is of type 'char *' |
68+
| test.c:517:16:517:25 | v_char_ptr | This argument should be of type 'double' but is of type 'char *' |
69+
| test.c:518:17:518:26 | v_char_ptr | This argument should be of type 'double' but is of type 'char *' |
70+
| test.c:519:18:519:27 | v_char_ptr | This argument should be of type 'long double' but is of type 'char *' |
71+
| test.c:520:17:520:26 | v_char_ptr | This argument should be of type 'long double' but is of type 'char *' |
72+
| test.c:522:16:522:25 | v_char_ptr | This argument should be of type 'double' but is of type 'char *' |
73+
| test.c:523:17:523:26 | v_char_ptr | This argument should be of type 'double' but is of type 'char *' |
74+
| test.c:524:18:524:27 | v_char_ptr | This argument should be of type 'long double' but is of type 'char *' |
75+
| test.c:525:17:525:26 | v_char_ptr | This argument should be of type 'long double' but is of type 'char *' |
76+
| test.c:527:16:527:25 | v_char_ptr | This argument should be of type 'char' but is of type 'char *' |
77+
| test.c:528:17:528:26 | v_char_ptr | This argument should be of type 'wchar_t' but is of type 'char *' |
78+
| test.c:530:16:530:20 | v_int | This argument should be of type 'char *' but is of type 'int' |
79+
| test.c:531:17:531:21 | v_int | This argument should be of type 'wchar_t *' but is of type 'int' |
80+
| test.c:533:16:533:20 | v_int | This argument should be of type 'void *' but is of type 'int' |
81+
| test.c:535:16:535:20 | v_int | This argument should be of type 'int *' but is of type 'int' |
82+
| test.c:536:17:536:21 | v_int | This argument should be of type 'short *' but is of type 'int' |
83+
| test.c:537:18:537:22 | v_int | This argument should be of type 'char *' but is of type 'int' |
84+
| test.c:538:17:538:21 | v_int | This argument should be of type 'long *' but is of type 'int' |
85+
| test.c:539:18:539:22 | v_int | This argument should be of type 'long long *' but is of type 'int' |
86+
| test.c:540:17:540:21 | v_int | This argument should be of type 'int *' but is of type 'int' |
87+
| test.c:541:17:541:21 | v_int | This argument should be of type 'int *' but is of type 'int' |
88+
| test.c:542:17:542:21 | v_int | This argument should be of type 'int *' but is of type 'int' |
89+
| test.c:544:16:544:25 | v_char_ptr | This argument should be of type 'wchar_t' but is of type 'char *' |
90+
| test.c:546:16:546:20 | v_int | This argument should be of type 'wchar_t *' but is of type 'int' |

0 commit comments

Comments
 (0)