-
Notifications
You must be signed in to change notification settings - Fork 1k
Add Coccinelle lint checks for non-_RO accessors used with pointers to const
#7622
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
+81
−1
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
60f2ba2
Use _RO accessors for const targets
MichaelChirico a9f74ec
use read-only accessors when appropriate (#7615)
MichaelChirico 5fe9198
one more _RO
MichaelChirico 6dce9df
review suggestions
MichaelChirico fe92745
botched suggested change
MichaelChirico 9a58485
Use more read-only accessors
aitap 9b034c8
gfirstlast: use _RO accessors
aitap a1f9696
add coccinelle rules to use read only accessors
ben-schwen 0a2e090
CI should also run when cocci files are touched
ben-schwen 70d37da
cocci_linter.R: fix zero-length error reports
aitap 83406ed
use_ro_accessors.cocci: expand linter rules
aitap 408f20f
Merge branch 'master' into coccinelle_ro_accessors2
ben-schwen 9f71ddc
Apply suggestions from code review
aitap 5121ef5
Revert "cocci_linter.R: fix zero-length error reports"
aitap 1de948c
Fix the file path list element
aitap 07aae7a
Reorder checks according to SEXPTYPE order
MichaelChirico 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| /* Ensure _RO accessors are used for assignment to 'const' variables */ | ||
| @@ | ||
| type T; | ||
| const T *variable; | ||
| expression E; | ||
| @@ | ||
| - variable = RAW(E) | ||
| + variable = RAW_RO(E) | ||
|
|
||
| @@ | ||
| type T; | ||
| const T *variable; | ||
| expression E; | ||
| @@ | ||
| - variable = LOGICAL(E) | ||
| + variable = LOGICAL_RO(E) | ||
|
|
||
| @@ | ||
| type T; | ||
| const T *variable; | ||
| expression E; | ||
| @@ | ||
| - variable = INTEGER(E) | ||
| + variable = INTEGER_RO(E) | ||
|
|
||
| @@ | ||
| type T; | ||
| const T *variable; | ||
| expression E; | ||
| @@ | ||
| - variable = REAL(E) | ||
| + variable = REAL_RO(E) | ||
|
|
||
| @@ | ||
| type T; | ||
| const T *variable; | ||
| expression E; | ||
| @@ | ||
| - variable = COMPLEX(E) | ||
| + variable = COMPLEX_RO(E) | ||
|
|
||
| /* Just use _RO accessors directly instead of 'const' casting the writeable one */ | ||
| @@ | ||
aitap marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| expression E; | ||
| type T; | ||
| @@ | ||
| -(const T*) RAW(E) | ||
| +RAW_RO(E) | ||
|
|
||
| @@ | ||
| expression E; | ||
| @@ | ||
| -(const int*) LOGICAL(E) | ||
| +LOGICAL_RO(E) | ||
|
|
||
| @@ | ||
| expression E; | ||
| @@ | ||
| -(const int*) INTEGER(E) | ||
| +INTEGER_RO(E) | ||
|
|
||
| @@ | ||
| expression E; | ||
| @@ | ||
| -(const double*) REAL(E) | ||
| +REAL_RO(E) | ||
| @@ | ||
| expression E; | ||
| type T; | ||
| @@ | ||
| -(const T*) COMPLEX(E) | ||
| +COMPLEX_RO(E) | ||
|
|
||
| @@ | ||
| expression E; | ||
| type T; | ||
| @@ | ||
| -(const T*) STRING_PTR(E) | ||
| +STRING_PTR_RO(E) | ||
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 |
|---|---|---|
|
|
@@ -29,6 +29,7 @@ jobs: | |
| c: | ||
| - '**/*.c' | ||
| - '**/*.h' | ||
| - '.ci/linters/cocci/**/*.cocci' | ||
| po: | ||
| - 'po/**/*.po' | ||
| md: | ||
|
|
||
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.