Skip to content

Commit a9cfb8e

Browse files
authored
Merge pull request #225 from github/lcartey/address-gcc-compiler-issues
Banned: Simplify alert messages, address compiler compat issues
2 parents a85c43a + aa92cc2 commit a9cfb8e

File tree

49 files changed

+109
-2150
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+109
-2150
lines changed

c/misra/src/rules/RULE-21-10/StandardLibraryTimeAndDateFunctionsUsed.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ where
2525
f.getFile().getBaseName() = "wchar.h"
2626
)
2727
)
28-
select fc, "Call to banned function $@.", f, f.getName()
28+
select fc, "Call to banned function " + f.getName() + "."

c/misra/src/rules/RULE-21-11/StandardHeaderFileTgmathhUsed.ql

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ from Macro m, MacroInvocation mi
1717
where
1818
not isExcluded(mi, BannedPackage::standardHeaderFileTgmathhUsedQuery()) and
1919
mi.getMacro() = m and
20-
m.getFile().getBaseName() = "tgmath.h"
21-
select mi, "Call to banned macro $@.", m, m.getName()
20+
m.getFile().getBaseName() = "tgmath.h" and
21+
not mi.getParentInvocation().getMacro().getFile().getBaseName() = "tgmath.h"
22+
select mi, "Call to banned macro " + m.getName() + "."

c/misra/src/rules/RULE-21-12/ExceptionHandlingFeaturesOfFenvhUsed.ql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,22 @@ class FPExceptionHandlingMacro extends Macro {
3232
}
3333
}
3434

35-
from Locatable call, Locatable def, string name, string kind
35+
from Locatable call, string name, string kind
3636
where
3737
not isExcluded(call, BannedPackage::exceptionHandlingFeaturesOfFenvhUsedQuery()) and
3838
(
3939
exists(FPExceptionHandlingFunction f |
40-
def = f and
4140
call = f.getACallToThisFunction() and
4241
name = f.getName() and
4342
kind = "function"
4443
)
4544
or
4645
exists(FPExceptionHandlingMacro m |
47-
def = m and
4846
call = m.getAnInvocation() and
4947
name = m.getName() and
50-
kind = "macro"
48+
kind = "macro" and
49+
// Exclude macro invocations expanded from other macro invocations from macros in fenv.h.
50+
not call.(MacroInvocation).getParentInvocation().getMacro().getFile().getBaseName() = "fenv.h"
5151
)
5252
)
53-
select call, "Call to banned " + kind + " $@.", def, name
53+
select call, "Call to banned " + kind + " " + name + "."

c/misra/src/rules/RULE-21-21/SystemOfStdlibhUsed.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ where
1919
not isExcluded(call, BannedPackage::systemOfStdlibhUsedQuery()) and
2020
call.getTarget() = target and
2121
target.hasGlobalOrStdName("system")
22-
select call, "Call to banned function $@.", target, target.getName()
22+
select call, "Call to banned function " + target.getName() + "."

c/misra/src/rules/RULE-21-4/StandardHeaderFileUsedSetjmph.ql

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,18 @@ class LongJmp extends Function {
2727
}
2828
}
2929

30-
from Locatable use, Locatable feature, string name
30+
from Locatable use, string name
3131
where
3232
not isExcluded(use, BannedPackage::standardHeaderFileUsedSetjmphQuery()) and
3333
(
3434
exists(SetJmp setjmp |
35-
feature = setjmp and
3635
use = setjmp.getAnInvocation() and
3736
name = "setjmp"
3837
)
3938
or
4039
exists(LongJmp longjmp |
41-
feature = longjmp and
4240
use = longjmp.getACallToThisFunction() and
4341
name = "longjmp"
4442
)
4543
)
46-
select use, "Use of $@.", feature, name
44+
select use, "Use of " + name + "."

c/misra/src/rules/RULE-21-5/StandardHeaderFileUsedSignalh.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ where
1818
not isExcluded(fc, BannedPackage::standardHeaderFileUsedSignalhQuery()) and
1919
fc.getTarget() = f and
2020
f.getFile().getBaseName() = "signal.h"
21-
select fc, "Call to banned function $@.", f, f.getName()
21+
select fc, "Call to banned function " + f.getName() + "."

c/misra/src/rules/RULE-21-6/StandardLibraryInputoutputFunctionsUsed.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@ where
4949
f.getName() = wcharInputOutput() and
5050
f.getFile().getBaseName() = "wchar.h"
5151
)
52-
select fc, "Call to banned function $@.", f, f.getName()
52+
select fc, "Call to banned function " + f.getName() + "."

c/misra/src/rules/RULE-21-7/AtofAtoiAtolAndAtollOfStdlibhUsed.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ where
2222
f = fc.getTarget() and
2323
f.getName() = atoi() and
2424
f.getFile().getBaseName() = "stdlib.h"
25-
select fc, "Call to banned function $@.", f, f.getName()
25+
select fc, "Call to banned function " + f.getName() + "."

c/misra/src/rules/RULE-21-8/TerminationFunctionsOfStdlibhUsed.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ from FunctionCall fc, BannedFunction f
2626
where
2727
not isExcluded(fc, BannedPackage::terminationFunctionsOfStdlibhUsedQuery()) and
2828
f = fc.getTarget()
29-
select fc, "Call to banned function $@.", f, f.getName()
29+
select fc, "Call to banned function " + f.getName() + "."

c/misra/src/rules/RULE-21-8/TerminationMacrosOfStdlibhUsed.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ from MacroInvocation mi, BannedMacro m
2323
where
2424
not isExcluded(mi, BannedPackage::terminationMacrosOfStdlibhUsedQuery()) and
2525
m.getAnInvocation() = mi
26-
select mi, "Use of banned macro $@.", m, m.getName()
26+
select mi, "Use of banned macro " + m.getName() + "."

c/misra/src/rules/RULE-21-9/BsearchAndQsortOfStdlibhUsed.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ where
2121
f = fc.getTarget() and
2222
f.getName() = ["qsort", "bsearch"] and
2323
f.getFile().getBaseName() = "stdlib.h"
24-
select fc, "Call to banned function $@.", f, f.getName()
24+
select fc, "Call to banned function " + f.getName() + "."
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
| test.c:6:18:6:21 | call to time | Call to banned function $@. | time.h:53:8:53:11 | time | time |
2-
| test.c:9:19:9:23 | call to ctime | Call to banned function $@. | time.h:60:7:60:11 | ctime | ctime |
3-
| test.c:17:3:17:6 | call to time | Call to banned function $@. | time.h:53:8:53:11 | time | time |
4-
| test.c:18:8:18:16 | call to localtime | Call to banned function $@. | time.h:58:12:58:20 | localtime | localtime |
5-
| test.c:19:3:19:10 | call to wcsftime | Call to banned function $@. | wchar.h:139:8:139:15 | wcsftime | wcsftime |
1+
| test.c:6:18:6:21 | call to time | Call to banned function time. |
2+
| test.c:9:19:9:23 | call to ctime | Call to banned function ctime. |
3+
| test.c:17:3:17:6 | call to time | Call to banned function time. |
4+
| test.c:18:8:18:16 | call to localtime | Call to banned function localtime. |
5+
| test.c:19:3:19:10 | call to wcsftime | Call to banned function wcsftime. |

c/misra/test/rules/RULE-21-10/test.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#include "time.h"
2-
#include "wchar.h"
1+
#include <time.h>
2+
#include <wchar.h>
33
void f1() {
44
time_t current_time;
55
char *c_time_string;

c/misra/test/rules/RULE-21-10/time.h

Lines changed: 0 additions & 166 deletions
This file was deleted.

0 commit comments

Comments
 (0)