Skip to content

Commit 0291b4c

Browse files
authored
Merge pull request #144 from lcartey/m27-0-1/permit-non-cstdio-uses
M27-0-1: Permit elements defined in other headers
2 parents fe14e0a + 61b1a0f commit 0291b4c

File tree

6 files changed

+7
-8
lines changed

6 files changed

+7
-8
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- `M27-0-1`
2+
- `CstdioTypesUsed.ql` - Exclude `size_t` from this rule, as it can be provided by headers other than `<cstdio>`.
3+
- `CstdioMacrosUsed.ql` - Exclude `NULL` from this rule, as it can be provided by headers other than `<cstdio>`.

cpp/autosar/src/rules/M27-0-1/CstdioMacrosUsed.ql

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ from MacroInvocation mi
2222
where
2323
not isExcluded(mi, BannedLibrariesPackage::cstdioMacrosUsedQuery()) and
2424
mi.getMacroName() in [
25-
"BUFSIZ", "EOF", "FILENAME_MAX", "FOPEN_MAX", "L_tmpnam", "NULL", "TMP_MAX", "_IOFBF",
26-
"IOLBF", "_IONBF", "SEEK_CUR", "SEEK_END", "SEEK_SET"
25+
"BUFSIZ", "EOF", "FILENAME_MAX", "FOPEN_MAX", "L_tmpnam", "TMP_MAX", "_IOFBF", "IOLBF",
26+
"_IONBF", "SEEK_CUR", "SEEK_END", "SEEK_SET"
2727
]
2828
select mi, "Use of <cstdio> macro '" + mi.getMacroName() + "'."

cpp/autosar/src/rules/M27-0-1/CstdioTypesUsed.ql

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ from TypeMention tm, UserType ut
2222
where
2323
not isExcluded(tm, BannedLibrariesPackage::cstdioTypesUsedQuery()) and
2424
ut = tm.getMentionedType() and
25-
ut.hasGlobalOrStdName(["FILE", "fpos_t", "size_t"])
25+
ut.hasGlobalOrStdName(["FILE", "fpos_t"])
2626
select tm, "Use of <cstdio> type '" + ut.getQualifiedName() + "'."

cpp/autosar/test/rules/M27-0-1/CstdioMacrosUsed.expected

-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@
77
| test.cpp:30:29:30:37 | FOPEN_MAX | Use of <cstdio> macro 'FOPEN_MAX'. |
88
| test.cpp:41:14:41:16 | EOF | Use of <cstdio> macro 'EOF'. |
99
| test.cpp:50:24:50:31 | SEEK_SET | Use of <cstdio> macro 'SEEK_SET'. |
10-
| test.cpp:60:10:60:13 | NULL | Use of <cstdio> macro 'NULL'. |
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
| test.cpp:4:8:4:11 | type mention | Use of <cstdio> type 'std::FILE'. |
22
| test.cpp:6:8:6:13 | type mention | Use of <cstdio> type 'std::fpos_t'. |
3-
| test.cpp:20:18:20:23 | type mention | Use of <cstdio> type 'size_t'. |
4-
| test.cpp:21:18:21:23 | type mention | Use of <cstdio> type 'size_t'. |
53
| test.cpp:34:3:34:6 | type mention | Use of <cstdio> type 'FILE'. |
64
| test.cpp:36:3:36:8 | type mention | Use of <cstdio> type 'fpos_t'. |
7-
| test.cpp:50:14:50:19 | type mention | Use of <cstdio> type 'size_t'. |

cpp/autosar/test/rules/M27-0-1/test.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@ void *test_cstdio_is_used() {
5757
printf("foo"); // NON_COMPLIANT
5858
puts("all done!"); // NON_COMPLIANT
5959

60-
return NULL; // NON_COMPLIANT
60+
return NULL; // COMPLIANT - NULL is not uniquely defined by cstdio
6161
}

0 commit comments

Comments
 (0)