Skip to content

FIO38-C FIO47-C FIO42-C tests #213

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Mar 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions c/cert/test/rules/FIO38-C/DoNotCopyAFileObject.expected
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
| test.c:10:20:10:26 | * ... | A FILE object is being copied. |
| test.c:17:21:17:30 | * ... | A FILE object is being copied. |
| test.c:23:21:23:31 | * ... | A FILE object is being copied. |
| test.c:29:15:29:21 | * ... | A FILE object is being copied. |
| test.c:42:19:42:28 | * ... | A FILE object is being copied. |
| test.c:11:20:11:26 | * ... | A FILE object is being copied. |
| test.c:18:21:18:30 | * ... | A FILE object is being copied. |
| test.c:24:21:24:31 | * ... | A FILE object is being copied. |
| test.c:30:15:30:21 | * ... | A FILE object is being copied. |
| test.c:43:19:43:28 | * ... | A FILE object is being copied. |
5 changes: 5 additions & 0 deletions c/cert/test/rules/FIO38-C/DoNotCopyAFileObject.expected.clang
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
| test.c:4:20:4:26 | * ... | A FILE object is being copied. |
| test.c:11:21:11:30 | * ... | A FILE object is being copied. |
| test.c:17:21:17:31 | * ... | A FILE object is being copied. |
| test.c:23:15:23:21 | * ... | A FILE object is being copied. |
| test.c:36:19:36:28 | * ... | A FILE object is being copied. |
5 changes: 5 additions & 0 deletions c/cert/test/rules/FIO38-C/DoNotCopyAFileObject.expected.gcc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
| test.c:4:20:4:26 | * ... | A FILE object is being copied. |
| test.c:11:21:11:30 | * ... | A FILE object is being copied. |
| test.c:17:21:17:31 | * ... | A FILE object is being copied. |
| test.c:23:15:23:21 | * ... | A FILE object is being copied. |
| test.c:36:19:36:28 | * ... | A FILE object is being copied. |
1 change: 1 addition & 0 deletions c/cert/test/rules/FIO38-C/test.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <stdio.h>
// Workaround for the Musl implementing FILE as an incomplete type.
#if !defined(__DEFINED_struct__IO_FILE)
struct _IO_FILE {
char __x;
Expand Down
43 changes: 43 additions & 0 deletions c/cert/test/rules/FIO38-C/test.c.clang
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include <stdio.h>

int f1(void) {
FILE my_stdout = *stdout; // NON_COMPLIANT
return fputs("Hello, World!\n", &my_stdout);
}

int f2(void) {
FILE *my_stdout;
my_stdout = stdout; // COMPLIANT
FILE my_stdout2 = *my_stdout; // NON_COMPLIANT
return fputs("Hello, World!\n", my_stdout);
}
int f2b(void) {
FILE *const *my_stdout;
my_stdout = &stdout; // COMPLIANT
FILE my_stdout2 = **my_stdout; // NON_COMPLIANT
return fputs("Hello, World!\n", *my_stdout);
}

int f3(void) {
FILE my_stdout;
my_stdout = *stdout; // NON_COMPLIANT
return fputs("Hello, World!\n", &my_stdout);
}

int f4(void) {
FILE *my_stdout;
my_stdout = fopen("file.txt", "w"); // COMPLIANT
return fputs("Hello, World!\n", my_stdout);
}

int f5helper(FILE my_stdout) { return fputs("Hello, World!\n", &my_stdout); }
int f5(void) {
FILE *my_stdout = fopen("file.txt", "w"); // COMPLIANT
return f5helper(*my_stdout); // NON_COMPLIANT
}

int f6helper(FILE *my_stdout) { return fputs("Hello, World!\n", my_stdout); }
int f6(void) {
FILE *my_stdout = fopen("file.txt", "w"); // COMPLIANT
return f6helper(my_stdout); // COMPLIANT
}
43 changes: 43 additions & 0 deletions c/cert/test/rules/FIO38-C/test.c.gcc
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include <stdio.h>

int f1(void) {
FILE my_stdout = *stdout; // NON_COMPLIANT
return fputs("Hello, World!\n", &my_stdout);
}

int f2(void) {
FILE *my_stdout;
my_stdout = stdout; // COMPLIANT
FILE my_stdout2 = *my_stdout; // NON_COMPLIANT
return fputs("Hello, World!\n", my_stdout);
}
int f2b(void) {
FILE *const *my_stdout;
my_stdout = &stdout; // COMPLIANT
FILE my_stdout2 = **my_stdout; // NON_COMPLIANT
return fputs("Hello, World!\n", *my_stdout);
}

int f3(void) {
FILE my_stdout;
my_stdout = *stdout; // NON_COMPLIANT
return fputs("Hello, World!\n", &my_stdout);
}

int f4(void) {
FILE *my_stdout;
my_stdout = fopen("file.txt", "w"); // COMPLIANT
return fputs("Hello, World!\n", my_stdout);
}

int f5helper(FILE my_stdout) { return fputs("Hello, World!\n", &my_stdout); }
int f5(void) {
FILE *my_stdout = fopen("file.txt", "w"); // COMPLIANT
return f5helper(*my_stdout); // NON_COMPLIANT
}

int f6helper(FILE *my_stdout) { return fputs("Hello, World!\n", my_stdout); }
int f6(void) {
FILE *my_stdout = fopen("file.txt", "w"); // COMPLIANT
return f6helper(my_stdout); // COMPLIANT
}
2 changes: 1 addition & 1 deletion c/cert/test/rules/FIO42-C/test.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <unistd.h>

int f1a(const char *filename) {
FILE *f = fopen(filename, "r"); // NON_COMPLIANT
if (NULL == f) {
Expand Down
90 changes: 90 additions & 0 deletions c/cert/test/rules/FIO47-C/WrongTypeFormatArguments.expected.clang
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
| test.c:376:17:376:30 | v_intmax_t_ptr | This argument should be of type 'int *' but is of type 'long *' |
| test.c:378:17:378:28 | v_size_t_ptr | This argument should be of type 'int *' but is of type 'unsigned long *' |
| test.c:380:17:380:31 | v_ptrdiff_t_ptr | This argument should be of type 'int *' but is of type 'long *' |
| test.c:417:17:417:26 | v_char_ptr | This argument should be of type 'int' but is of type 'char *' |
| test.c:421:18:421:27 | v_char_ptr | This argument should be of type 'int' but is of type 'char *' |
| test.c:425:16:425:25 | v_char_ptr | This argument should be of type 'int' but is of type 'char *' |
| test.c:426:17:426:26 | v_char_ptr | This argument should be of type 'int' but is of type 'char *' |
| test.c:427:18:427:27 | v_char_ptr | This argument should be of type 'int' but is of type 'char *' |
| test.c:428:17:428:26 | v_char_ptr | This argument should be of type 'long' but is of type 'char *' |
| test.c:429:18:429:27 | v_char_ptr | This argument should be of type 'long long' but is of type 'char *' |
| test.c:430:17:430:26 | v_char_ptr | This argument should be of type 'intmax_t' but is of type 'char *' |
| test.c:432:17:432:26 | v_char_ptr | This argument should be of type 'ptrdiff_t' but is of type 'char *' |
| test.c:434:16:434:25 | v_char_ptr | This argument should be of type 'int' but is of type 'char *' |
| test.c:435:17:435:26 | v_char_ptr | This argument should be of type 'int' but is of type 'char *' |
| test.c:436:18:436:27 | v_char_ptr | This argument should be of type 'int' but is of type 'char *' |
| test.c:437:17:437:26 | v_char_ptr | This argument should be of type 'long' but is of type 'char *' |
| test.c:438:18:438:27 | v_char_ptr | This argument should be of type 'long long' but is of type 'char *' |
| test.c:439:17:439:26 | v_char_ptr | This argument should be of type 'intmax_t' but is of type 'char *' |
| test.c:441:17:441:26 | v_char_ptr | This argument should be of type 'ptrdiff_t' but is of type 'char *' |
| test.c:443:16:443:25 | v_char_ptr | This argument should be of type 'unsigned int' but is of type 'char *' |
| test.c:444:17:444:26 | v_char_ptr | This argument should be of type 'unsigned int' but is of type 'char *' |
| test.c:445:18:445:27 | v_char_ptr | This argument should be of type 'unsigned int' but is of type 'char *' |
| test.c:446:17:446:26 | v_char_ptr | This argument should be of type 'unsigned long' but is of type 'char *' |
| test.c:447:18:447:27 | v_char_ptr | This argument should be of type 'unsigned long long' but is of type 'char *' |
| test.c:450:17:450:26 | v_char_ptr | This argument should be of type 'size_t' but is of type 'char *' |
| test.c:454:16:454:25 | v_char_ptr | This argument should be of type 'unsigned int' but is of type 'char *' |
| test.c:455:17:455:26 | v_char_ptr | This argument should be of type 'unsigned int' but is of type 'char *' |
| test.c:456:18:456:27 | v_char_ptr | This argument should be of type 'unsigned int' but is of type 'char *' |
| test.c:457:17:457:26 | v_char_ptr | This argument should be of type 'unsigned long' but is of type 'char *' |
| test.c:458:18:458:27 | v_char_ptr | This argument should be of type 'unsigned long long' but is of type 'char *' |
| test.c:461:17:461:26 | v_char_ptr | This argument should be of type 'size_t' but is of type 'char *' |
| test.c:465:16:465:25 | v_char_ptr | This argument should be of type 'unsigned int' but is of type 'char *' |
| test.c:466:17:466:26 | v_char_ptr | This argument should be of type 'unsigned int' but is of type 'char *' |
| test.c:467:18:467:27 | v_char_ptr | This argument should be of type 'unsigned int' but is of type 'char *' |
| test.c:468:17:468:26 | v_char_ptr | This argument should be of type 'unsigned long' but is of type 'char *' |
| test.c:469:18:469:27 | v_char_ptr | This argument should be of type 'unsigned long long' but is of type 'char *' |
| test.c:472:17:472:26 | v_char_ptr | This argument should be of type 'size_t' but is of type 'char *' |
| test.c:476:16:476:25 | v_char_ptr | This argument should be of type 'unsigned int' but is of type 'char *' |
| test.c:477:17:477:26 | v_char_ptr | This argument should be of type 'unsigned int' but is of type 'char *' |
| test.c:478:18:478:27 | v_char_ptr | This argument should be of type 'unsigned int' but is of type 'char *' |
| test.c:479:17:479:26 | v_char_ptr | This argument should be of type 'unsigned long' but is of type 'char *' |
| test.c:480:18:480:27 | v_char_ptr | This argument should be of type 'unsigned long long' but is of type 'char *' |
| test.c:483:17:483:26 | v_char_ptr | This argument should be of type 'size_t' but is of type 'char *' |
| test.c:487:16:487:25 | v_char_ptr | This argument should be of type 'double' but is of type 'char *' |
| test.c:488:17:488:26 | v_char_ptr | This argument should be of type 'double' but is of type 'char *' |
| test.c:489:18:489:27 | v_char_ptr | This argument should be of type 'long double' but is of type 'char *' |
| test.c:490:17:490:26 | v_char_ptr | This argument should be of type 'long double' but is of type 'char *' |
| test.c:492:16:492:25 | v_char_ptr | This argument should be of type 'double' but is of type 'char *' |
| test.c:493:17:493:26 | v_char_ptr | This argument should be of type 'double' but is of type 'char *' |
| test.c:494:18:494:27 | v_char_ptr | This argument should be of type 'long double' but is of type 'char *' |
| test.c:495:17:495:26 | v_char_ptr | This argument should be of type 'long double' but is of type 'char *' |
| test.c:497:16:497:25 | v_char_ptr | This argument should be of type 'double' but is of type 'char *' |
| test.c:498:17:498:26 | v_char_ptr | This argument should be of type 'double' but is of type 'char *' |
| test.c:499:18:499:27 | v_char_ptr | This argument should be of type 'long double' but is of type 'char *' |
| test.c:500:17:500:26 | v_char_ptr | This argument should be of type 'long double' but is of type 'char *' |
| test.c:502:16:502:25 | v_char_ptr | This argument should be of type 'double' but is of type 'char *' |
| test.c:503:17:503:26 | v_char_ptr | This argument should be of type 'double' but is of type 'char *' |
| test.c:504:18:504:27 | v_char_ptr | This argument should be of type 'long double' but is of type 'char *' |
| test.c:505:17:505:26 | v_char_ptr | This argument should be of type 'long double' but is of type 'char *' |
| test.c:507:16:507:25 | v_char_ptr | This argument should be of type 'double' but is of type 'char *' |
| test.c:508:17:508:26 | v_char_ptr | This argument should be of type 'double' but is of type 'char *' |
| test.c:509:18:509:27 | v_char_ptr | This argument should be of type 'long double' but is of type 'char *' |
| test.c:510:17:510:26 | v_char_ptr | This argument should be of type 'long double' but is of type 'char *' |
| test.c:512:16:512:25 | v_char_ptr | This argument should be of type 'double' but is of type 'char *' |
| test.c:513:17:513:26 | v_char_ptr | This argument should be of type 'double' but is of type 'char *' |
| test.c:514:18:514:27 | v_char_ptr | This argument should be of type 'long double' but is of type 'char *' |
| test.c:515:17:515:26 | v_char_ptr | This argument should be of type 'long double' but is of type 'char *' |
| test.c:517:16:517:25 | v_char_ptr | This argument should be of type 'double' but is of type 'char *' |
| test.c:518:17:518:26 | v_char_ptr | This argument should be of type 'double' but is of type 'char *' |
| test.c:519:18:519:27 | v_char_ptr | This argument should be of type 'long double' but is of type 'char *' |
| test.c:520:17:520:26 | v_char_ptr | This argument should be of type 'long double' but is of type 'char *' |
| test.c:522:16:522:25 | v_char_ptr | This argument should be of type 'double' but is of type 'char *' |
| test.c:523:17:523:26 | v_char_ptr | This argument should be of type 'double' but is of type 'char *' |
| test.c:524:18:524:27 | v_char_ptr | This argument should be of type 'long double' but is of type 'char *' |
| test.c:525:17:525:26 | v_char_ptr | This argument should be of type 'long double' but is of type 'char *' |
| test.c:527:16:527:25 | v_char_ptr | This argument should be of type 'char' but is of type 'char *' |
| test.c:528:17:528:26 | v_char_ptr | This argument should be of type 'wchar_t' but is of type 'char *' |
| test.c:530:16:530:20 | v_int | This argument should be of type 'char *' but is of type 'int' |
| test.c:531:17:531:21 | v_int | This argument should be of type 'wchar_t *' but is of type 'int' |
| test.c:533:16:533:20 | v_int | This argument should be of type 'void *' but is of type 'int' |
| test.c:535:16:535:20 | v_int | This argument should be of type 'int *' but is of type 'int' |
| test.c:536:17:536:21 | v_int | This argument should be of type 'short *' but is of type 'int' |
| test.c:537:18:537:22 | v_int | This argument should be of type 'char *' but is of type 'int' |
| test.c:538:17:538:21 | v_int | This argument should be of type 'long *' but is of type 'int' |
| test.c:539:18:539:22 | v_int | This argument should be of type 'long long *' but is of type 'int' |
| test.c:540:17:540:21 | v_int | This argument should be of type 'int *' but is of type 'int' |
| test.c:541:17:541:21 | v_int | This argument should be of type 'int *' but is of type 'int' |
| test.c:542:17:542:21 | v_int | This argument should be of type 'int *' but is of type 'int' |
| test.c:544:16:544:25 | v_char_ptr | This argument should be of type 'wchar_t' but is of type 'char *' |
| test.c:546:16:546:20 | v_int | This argument should be of type 'wchar_t *' but is of type 'int' |
Loading