Skip to content

Commit

Permalink
Fix #11793 (False positive: Misra addon crash for struct initializati…
Browse files Browse the repository at this point in the history
…on when struct has a function pointer array) (#5190)
  • Loading branch information
danmar committed Jun 25, 2023
1 parent 87c2b8d commit 91dedf0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/CI-unixish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ jobs:
run: |
./cppcheck --error-exitcode=1 --inline-suppr --addon=threadsafety addons/test/threadsafety
./cppcheck --error-exitcode=1 --inline-suppr --addon=threadsafety --std=c++03 addons/test/threadsafety
./cppcheck --error-exitcode=1 --addon=misra addons/test/misra/crash*.c
./cppcheck --addon=misra --enable=style --inline-suppr --enable=information --error-exitcode=1 addons/test/misra/misra-ctu-*-test.c
pushd addons/test
# We'll force C89 standard to enable an additional verification for
Expand All @@ -403,11 +404,6 @@ jobs:
../../cppcheck --dump namingng_test.c
python3 ../namingng.py --configfile ../naming.json --verify namingng_test.c.dump
- name: Ensure misra addon does not crash
if: contains(matrix.os, 'ubuntu')
run: |
./cppcheck --addon=misra addons/test/misra/crash1.c | ( ! grep 'Bailing out from checking' )
- name: Build democlient
if: matrix.os == 'ubuntu-22.04'
run: |
Expand Down
2 changes: 1 addition & 1 deletion addons/misra_9.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ def getElementDef(nameToken, rawTokens = None):
return ed

def createArrayChildrenDefs(ed, token, var, rawTokens = None):
if token.str == '[':
if token and token.str == '[':
if rawTokens is not None:
foundToken = next((rawToken for rawToken in rawTokens
if rawToken.file == token.file
Expand Down
9 changes: 9 additions & 0 deletions addons/test/misra/crash2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

// #11793

typedef struct pfmlib_pmu {
int flags ;
int (*get_event_encoding[10])(void* this, pfmlib_event_desc_t* e);
} pfmlib_pmu_t ;

pfmlib_pmu_t sparc_ultra3_support = { .flags = 0 };

0 comments on commit 91dedf0

Please sign in to comment.