-
Notifications
You must be signed in to change notification settings - Fork 67
RULE-1-3
: Improve detection of standard compliant main functions
#771
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
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 8 additions & 5 deletions
13
c/misra/test/rules/RULE-1-3/OccurrenceOfUndefinedBehavior.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
| test.c:8:6:8:35 | ____codeql_coding_standards_m2 | May result in undefined behavior. | | ||
| test.c:11:5:11:34 | ____codeql_coding_standards_m3 | May result in undefined behavior. | | ||
| test.c:15:5:15:34 | ____codeql_coding_standards_m4 | May result in undefined behavior. | | ||
| test.c:19:5:19:34 | ____codeql_coding_standards_m5 | May result in undefined behavior. | | ||
| test.c:23:5:23:34 | ____codeql_coding_standards_m6 | May result in undefined behavior. | | ||
| test.c:4:6:4:38 | ____codeql_coding_standards_main1 | main function may trigger undefined behavior because it is not in one of the formats specified by the C standard. | | ||
| test.c:8:5:8:37 | ____codeql_coding_standards_main2 | main function may trigger undefined behavior because it is not in one of the formats specified by the C standard. | | ||
| test.c:27:5:27:37 | ____codeql_coding_standards_main6 | main function may trigger undefined behavior because it is not in one of the formats specified by the C standard. | | ||
| test.c:32:6:32:38 | ____codeql_coding_standards_main7 | main function may trigger undefined behavior because it is not in one of the formats specified by the C standard. | | ||
| test.c:36:5:36:37 | ____codeql_coding_standards_main8 | main function may trigger undefined behavior because it is not in one of the formats specified by the C standard. | | ||
| test.c:40:5:40:37 | ____codeql_coding_standards_main9 | main function may trigger undefined behavior because it is not in one of the formats specified by the C standard. | | ||
| test.c:44:5:44:38 | ____codeql_coding_standards_main10 | main function may trigger undefined behavior because it is not in one of the formats specified by the C standard. | | ||
| test.c:48:5:48:38 | ____codeql_coding_standards_main11 | main function may trigger undefined behavior because it is not in one of the formats specified by the C standard. | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,50 @@ | ||
void main(void) { // COMPLIANT | ||
int main(void) { // COMPLIANT | ||
} | ||
|
||
int ____codeql_coding_standards_m1(int argc, char **argv) { // NON_COMPLIANT | ||
void ____codeql_coding_standards_main1(void) { // NON_COMPLIANT | ||
return 0; | ||
} | ||
|
||
void ____codeql_coding_standards_m2(char *argc, char **argv) { // NON_COMPLIANT | ||
int ____codeql_coding_standards_main2() { // NON_COMPLIANT | ||
return 0; | ||
} | ||
|
||
int ____codeql_coding_standards_main3(int argc, char **argv) { // COMPLIANT | ||
return 0; | ||
} | ||
|
||
int ____codeql_coding_standards_main4(int argc, char argv[][]) { // COMPLIANT | ||
return 0; | ||
} | ||
|
||
int ____codeql_coding_standards_main5(int argc, char *argv[]) { // COMPLIANT | ||
return 0; | ||
} | ||
|
||
typedef int MY_INT; | ||
typedef char *MY_CHAR_PTR; | ||
|
||
int ____codeql_coding_standards_main6(MY_INT argc, | ||
MY_CHAR_PTR argv[]) { // COMPLIANT | ||
return 0; | ||
} | ||
|
||
void ____codeql_coding_standards_main7(char *argc, | ||
char **argv) { // NON_COMPLIANT | ||
} | ||
|
||
int ____codeql_coding_standards_m3(int argc, char *argv) { // NON_COMPLIANT | ||
int ____codeql_coding_standards_main8(int argc, char *argv) { // NON_COMPLIANT | ||
return 0; | ||
} | ||
|
||
int ____codeql_coding_standards_m4() { // NON_COMPLIANT | ||
int ____codeql_coding_standards_main9() { // NON_COMPLIANT | ||
return 0; | ||
} | ||
|
||
int ____codeql_coding_standards_m5(int argc, int *argv) { // NON_COMPLIANT | ||
int ____codeql_coding_standards_main10(int argc, int *argv) { // NON_COMPLIANT | ||
return 0; | ||
} | ||
|
||
int ____codeql_coding_standards_m6(int argc, int **argv) { // NON_COMPLIANT | ||
int ____codeql_coding_standards_main11(int argc, int **argv) { // NON_COMPLIANT | ||
return 0; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
- `RULE-1-3` - `OccurrenceOfUndefinedBehavior.ql`: | ||
- Improve alert message to report the undefined behavior triggered. | ||
- Address both false positives and false negatives in identifying standard compliant main methods. Previously, `void main()` was considered permitted and `int main(void)` banned. In addition, we now detect main methods as standard compliant if they use typedefs, and if arrays are used in the definition of `argv`. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.