Skip to content

Commit c9ced08

Browse files
Format test, commit user README changes.
1 parent 722dc6a commit c9ced08

File tree

3 files changed

+101
-103
lines changed

3 files changed

+101
-103
lines changed
Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
| test.c:15:25:15:29 | func2 | The address of function func2 is taken without the & operator. |
2-
| test.c:16:27:16:31 | func3 | The address of function func3 is taken without the & operator. |
3-
| test.c:22:16:22:20 | func1 | The address of function func1 is taken without the & operator. |
4-
| test.c:39:5:39:9 | func1 | The address of function func1 is taken without the & operator. |
5-
| test.c:40:5:40:9 | func2 | The address of function func2 is taken without the & operator. |
6-
| test.c:48:7:48:11 | func1 | The address of function func1 is taken without the & operator. |
7-
| test.c:49:7:49:11 | func2 | The address of function func2 is taken without the & operator. |
8-
| test.c:58:15:58:19 | func1 | The address of function func1 is taken without the & operator. |
9-
| test.c:59:23:59:27 | func2 | The address of function func2 is taken without the & operator. |
10-
| test.c:60:15:60:19 | func1 | The address of function func1 is taken without the & operator. |
11-
| test.c:60:22:60:26 | func2 | The address of function func2 is taken without the & operator. |
12-
| test.c:68:13:68:17 | func1 | The address of function func1 is taken without the & operator. |
13-
| test.c:69:14:69:18 | func1 | The address of function func1 is taken without the & operator. |
14-
| test.c:70:14:70:18 | func1 | The address of function func1 is taken without the & operator. |
15-
| test.c:72:20:72:24 | func1 | The address of function func1 is taken without the & operator. |
1+
| test.c:14:25:14:29 | func2 | The address of function func2 is taken without the & operator. |
2+
| test.c:15:27:15:31 | func3 | The address of function func3 is taken without the & operator. |
3+
| test.c:21:12:21:16 | func1 | The address of function func1 is taken without the & operator. |
4+
| test.c:38:3:38:7 | func1 | The address of function func1 is taken without the & operator. |
5+
| test.c:39:3:39:7 | func2 | The address of function func2 is taken without the & operator. |
6+
| test.c:47:5:47:9 | func1 | The address of function func1 is taken without the & operator. |
7+
| test.c:48:5:48:9 | func2 | The address of function func2 is taken without the & operator. |
8+
| test.c:57:13:57:17 | func1 | The address of function func1 is taken without the & operator. |
9+
| test.c:58:21:58:25 | func2 | The address of function func2 is taken without the & operator. |
10+
| test.c:59:13:59:17 | func1 | The address of function func1 is taken without the & operator. |
11+
| test.c:59:20:59:24 | func2 | The address of function func2 is taken without the & operator. |
12+
| test.c:67:11:67:15 | func1 | The address of function func1 is taken without the & operator. |
13+
| test.c:68:12:68:16 | func1 | The address of function func1 is taken without the & operator. |
14+
| test.c:69:12:69:16 | func1 | The address of function func1 is taken without the & operator. |
15+
| test.c:71:18:71:22 | func1 | The address of function func1 is taken without the & operator. |

c/misra/test/rules/RULE-17-12/test.c

Lines changed: 85 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
11
void func1() {}
2-
void func2(int x, char* y) {}
2+
void func2(int x, char *y) {}
33

4-
typedef struct {} s;
4+
typedef struct {
5+
} s;
56

6-
int func3() {
7-
return 0;
8-
}
7+
int func3() { return 0; }
98

109
typedef void (*func_ptr_t1)();
11-
typedef void (*func_ptr_t2)(int x, char* y);
10+
typedef void (*func_ptr_t2)(int x, char *y);
1211
typedef s (*func_ptr_t3)();
1312

14-
func_ptr_t1 func_ptr1 = &func1; // COMPLIANT
15-
func_ptr_t2 func_ptr2 = func2; // NON-COMPLIANT
13+
func_ptr_t1 func_ptr1 = &func1; // COMPLIANT
14+
func_ptr_t2 func_ptr2 = func2; // NON-COMPLIANT
1615
func_ptr_t3 func_ptr3 = &(func3); // NON-COMPLIANT
1716

1817
void take_func(func_ptr_t1 f1, func_ptr_t2 f2);
1918

2019
func_ptr_t1 returns_func(int x) {
21-
if (x == 0) {
22-
return func1; // NON-COMPLIANT
23-
} else if (x == 1) {
24-
return &func1; // COMPLIANT
25-
}
20+
if (x == 0) {
21+
return func1; // NON-COMPLIANT
22+
} else if (x == 1) {
23+
return &func1; // COMPLIANT
24+
}
2625

27-
return returns_func(0); // COMPLIANT
26+
return returns_func(0); // COMPLIANT
2827
}
2928

3029
#define MACRO_IDENTITY(f) (f)
@@ -33,77 +32,76 @@ func_ptr_t1 returns_func(int x) {
3332
#define MACRO_INVOKE_AND_USE_AS_TOKEN(f) f(0, #f)
3433

3534
void test() {
36-
func1(); // COMPLIANT
37-
func2(1, "hello"); // COMPLIANT
38-
39-
func1; // NON-COMPLIANT
40-
func2; // NON-COMPLIANT
41-
42-
&func1; // COMPLIANT
43-
&func2; // COMPLIANT
44-
45-
(func1)(); // COMPLIANT
46-
(func2)(1, "hello"); // COMPLIANT
47-
48-
&(func1); // NON-COMPLIANT
49-
&(func2); // NON-COMPLIANT
50-
51-
(&func1)(); // COMPLIANT
52-
(&func2)(1, "hello"); // COMPLIANT
53-
54-
(func1()); // COMPLIANT
55-
(func2(1, "hello")); // COMPLIANT
56-
57-
take_func(&func1, &func2); // COMPLIANT
58-
take_func(func1, &func2); // NON-COMPLIANT
59-
take_func(&func1, func2); // NON-COMPLIANT
60-
take_func(func1, func2); // NON-COMPLIANT
61-
62-
returns_func(0); // COMPLIANT
63-
returns_func(0)(); // COMPLIANT
64-
(returns_func(0))(); // COMPLIANT
65-
66-
(void*) &func1; // COMPLIANT
67-
(void*) (&func1); // COMPLIANT
68-
(void*) func1; // NON-COMPLIANT
69-
(void*) (func1); // NON-COMPLIANT
70-
((void*) func1); // NON-COMPLIANT
71-
72-
MACRO_IDENTITY(func1); // NON-COMPLIANT
73-
MACRO_IDENTITY(func1)(); // NON-COMPLIANT[FALSE NEGATIVE]
74-
MACRO_IDENTITY(&func1); // COMPLIANT
75-
MACRO_IDENTITY(&func1)(); // COMPLIANT
76-
77-
MACRO_INVOKE_RISKY(func3); // NON-COMPLIANT[FALSE NEGATIVE]
78-
MACRO_INVOKE_IMPROVED(func3); // NON-COMPLIANT[FALSE NEGATIVE]
79-
MACRO_INVOKE_IMPROVED(&func3); // COMPLIANT
80-
81-
MACRO_INVOKE_AND_USE_AS_TOKEN(func1); // COMPLIANT
82-
83-
// Function pointers are exempt from this rule.
84-
func_ptr1(); // COMPLIANT
85-
func_ptr2(1, "hello"); // COMPLIANT
86-
func_ptr1; // COMPLIANT
87-
func_ptr2; // COMPLIANT
88-
&func_ptr1; // COMPLIANT
89-
&func_ptr2; // COMPLIANT
90-
(func_ptr1)(); // COMPLIANT
91-
(func_ptr2)(1, "hello"); // COMPLIANT
92-
(*func_ptr1)(); // COMPLIANT
93-
(*func_ptr2)(1, "hello"); // COMPLIANT
94-
take_func(func_ptr1, func_ptr2); // COMPLIANT
95-
(void*) func_ptr1; // COMPLIANT
96-
(void*) &func_ptr1; // COMPLIANT
97-
(void*) (&func_ptr1); // COMPLIANT
98-
(void*) func_ptr1; // COMPLIANT
99-
(void*) (func_ptr1); // COMPLIANT
100-
((void*) func_ptr1); // COMPLIANT
101-
MACRO_IDENTITY(func_ptr1); // COMPLIANT
102-
MACRO_IDENTITY(func_ptr1)(); // COMPLIANT
103-
MACRO_IDENTITY(&func_ptr1); // COMPLIANT
104-
(*MACRO_IDENTITY(&func_ptr1))(); // COMPLIANT
105-
MACRO_INVOKE_RISKY(func_ptr3); // COMPLIANT
106-
MACRO_INVOKE_IMPROVED(func_ptr3); // COMPLIANT
107-
MACRO_INVOKE_IMPROVED(*&func_ptr3); // COMPLIANT
108-
35+
func1(); // COMPLIANT
36+
func2(1, "hello"); // COMPLIANT
37+
38+
func1; // NON-COMPLIANT
39+
func2; // NON-COMPLIANT
40+
41+
&func1; // COMPLIANT
42+
&func2; // COMPLIANT
43+
44+
(func1)(); // COMPLIANT
45+
(func2)(1, "hello"); // COMPLIANT
46+
47+
&(func1); // NON-COMPLIANT
48+
&(func2); // NON-COMPLIANT
49+
50+
(&func1)(); // COMPLIANT
51+
(&func2)(1, "hello"); // COMPLIANT
52+
53+
(func1()); // COMPLIANT
54+
(func2(1, "hello")); // COMPLIANT
55+
56+
take_func(&func1, &func2); // COMPLIANT
57+
take_func(func1, &func2); // NON-COMPLIANT
58+
take_func(&func1, func2); // NON-COMPLIANT
59+
take_func(func1, func2); // NON-COMPLIANT
60+
61+
returns_func(0); // COMPLIANT
62+
returns_func(0)(); // COMPLIANT
63+
(returns_func(0))(); // COMPLIANT
64+
65+
(void *)&func1; // COMPLIANT
66+
(void *)(&func1); // COMPLIANT
67+
(void *)func1; // NON-COMPLIANT
68+
(void *)(func1); // NON-COMPLIANT
69+
((void *)func1); // NON-COMPLIANT
70+
71+
MACRO_IDENTITY(func1); // NON-COMPLIANT
72+
MACRO_IDENTITY(func1)(); // NON-COMPLIANT[FALSE NEGATIVE]
73+
MACRO_IDENTITY(&func1); // COMPLIANT
74+
MACRO_IDENTITY (&func1)(); // COMPLIANT
75+
76+
MACRO_INVOKE_RISKY(func3); // NON-COMPLIANT[FALSE NEGATIVE]
77+
MACRO_INVOKE_IMPROVED(func3); // NON-COMPLIANT[FALSE NEGATIVE]
78+
MACRO_INVOKE_IMPROVED(&func3); // COMPLIANT
79+
80+
MACRO_INVOKE_AND_USE_AS_TOKEN(func1); // COMPLIANT
81+
82+
// Function pointers are exempt from this rule.
83+
func_ptr1(); // COMPLIANT
84+
func_ptr2(1, "hello"); // COMPLIANT
85+
func_ptr1; // COMPLIANT
86+
func_ptr2; // COMPLIANT
87+
&func_ptr1; // COMPLIANT
88+
&func_ptr2; // COMPLIANT
89+
(func_ptr1)(); // COMPLIANT
90+
(func_ptr2)(1, "hello"); // COMPLIANT
91+
(*func_ptr1)(); // COMPLIANT
92+
(*func_ptr2)(1, "hello"); // COMPLIANT
93+
take_func(func_ptr1, func_ptr2); // COMPLIANT
94+
(void *)func_ptr1; // COMPLIANT
95+
(void *)&func_ptr1; // COMPLIANT
96+
(void *)(&func_ptr1); // COMPLIANT
97+
(void *)func_ptr1; // COMPLIANT
98+
(void *)(func_ptr1); // COMPLIANT
99+
((void *)func_ptr1); // COMPLIANT
100+
MACRO_IDENTITY(func_ptr1); // COMPLIANT
101+
MACRO_IDENTITY(func_ptr1)(); // COMPLIANT
102+
MACRO_IDENTITY(&func_ptr1); // COMPLIANT
103+
(*MACRO_IDENTITY(&func_ptr1))(); // COMPLIANT
104+
MACRO_INVOKE_RISKY(func_ptr3); // COMPLIANT
105+
MACRO_INVOKE_IMPROVED(func_ptr3); // COMPLIANT
106+
MACRO_INVOKE_IMPROVED(*&func_ptr3); // COMPLIANT
109107
}

docs/user_manual.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ The datasheet _"CodeQL Coding Standards: supported rules"_, provided with each r
7474

7575
[^1]: AUTOSAR C++ versions R22-11, R21-11, R20-11, R19-11 and R19-03 are all identical as indicated in the document change history.
7676
[^2]: The unimplemented supportable AUTOSAR rules are `A7-1-8` and `A8-2-1`. These rules require additional support in the CodeQL CLI to ensure the required information is available in the CodeQL database to identify violations of these rules.
77-
[^3]: The unimplemented supportable MISRA C 2012 rules are `Rule 9.5` and `Dir 4.14`. `Rule 9.5` requires additional support in the CodeQL CLI to ensure the required information is available in the CodeQL database to identify violations of these rules. `Dir 4.14` is covered by the default CodeQL queries, which identify potential security vulnerabilities caused by not validating external input.
77+
[^3]: The unimplemented supportable MISRA C 2012 rules are `Rule 9.5`, `Rule 17.13`, and `Dir 4.14`. `Rule 9.5` and `Rule 17.13` require additional support in the CodeQL CLI to ensure the required information is available in the CodeQL database to identify violations of these rules. `Dir 4.14` is covered by the default CodeQL queries, which identify potential security vulnerabilities caused by not validating external input.
7878
[^4]: The rules 5.13.7, 19.0.1 and 19.1.2 are not planned to be implemented by CodeQL as they are compiler checked in all supported compilers.
7979

8080
## Supported environment

0 commit comments

Comments
 (0)