Skip to content

M27-0-1: Permit elements defined in other headers #144

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 3 commits into from
Nov 25, 2022
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
3 changes: 3 additions & 0 deletions change_notes/2022-11-21-null-sizet-not-cstdio.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- `M27-0-1`
- `CstdioTypesUsed.ql` - Exclude `size_t` from this rule, as it can be provided by headers other than `<cstdio>`.
- `CstdioMacrosUsed.ql` - Exclude `NULL` from this rule, as it can be provided by headers other than `<cstdio>`.
4 changes: 2 additions & 2 deletions cpp/autosar/src/rules/M27-0-1/CstdioMacrosUsed.ql
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ from MacroInvocation mi
where
not isExcluded(mi, BannedLibrariesPackage::cstdioMacrosUsedQuery()) and
mi.getMacroName() in [
"BUFSIZ", "EOF", "FILENAME_MAX", "FOPEN_MAX", "L_tmpnam", "NULL", "TMP_MAX", "_IOFBF",
"IOLBF", "_IONBF", "SEEK_CUR", "SEEK_END", "SEEK_SET"
"BUFSIZ", "EOF", "FILENAME_MAX", "FOPEN_MAX", "L_tmpnam", "TMP_MAX", "_IOFBF", "IOLBF",
"_IONBF", "SEEK_CUR", "SEEK_END", "SEEK_SET"
]
select mi, "Use of <cstdio> macro '" + mi.getMacroName() + "'."
2 changes: 1 addition & 1 deletion cpp/autosar/src/rules/M27-0-1/CstdioTypesUsed.ql
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ from TypeMention tm, UserType ut
where
not isExcluded(tm, BannedLibrariesPackage::cstdioTypesUsedQuery()) and
ut = tm.getMentionedType() and
ut.hasGlobalOrStdName(["FILE", "fpos_t", "size_t"])
ut.hasGlobalOrStdName(["FILE", "fpos_t"])
select tm, "Use of <cstdio> type '" + ut.getQualifiedName() + "'."
1 change: 0 additions & 1 deletion cpp/autosar/test/rules/M27-0-1/CstdioMacrosUsed.expected
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@
| test.cpp:30:29:30:37 | FOPEN_MAX | Use of <cstdio> macro 'FOPEN_MAX'. |
| test.cpp:41:14:41:16 | EOF | Use of <cstdio> macro 'EOF'. |
| test.cpp:50:24:50:31 | SEEK_SET | Use of <cstdio> macro 'SEEK_SET'. |
| test.cpp:60:10:60:13 | NULL | Use of <cstdio> macro 'NULL'. |
3 changes: 0 additions & 3 deletions cpp/autosar/test/rules/M27-0-1/CstdioTypesUsed.expected
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
| test.cpp:4:8:4:11 | type mention | Use of <cstdio> type 'std::FILE'. |
| test.cpp:6:8:6:13 | type mention | Use of <cstdio> type 'std::fpos_t'. |
| test.cpp:20:18:20:23 | type mention | Use of <cstdio> type 'size_t'. |
| test.cpp:21:18:21:23 | type mention | Use of <cstdio> type 'size_t'. |
| test.cpp:34:3:34:6 | type mention | Use of <cstdio> type 'FILE'. |
| test.cpp:36:3:36:8 | type mention | Use of <cstdio> type 'fpos_t'. |
| test.cpp:50:14:50:19 | type mention | Use of <cstdio> type 'size_t'. |
2 changes: 1 addition & 1 deletion cpp/autosar/test/rules/M27-0-1/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@ void *test_cstdio_is_used() {
printf("foo"); // NON_COMPLIANT
puts("all done!"); // NON_COMPLIANT

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