Fix #11793 (False positive: Misra addon crash for struct initialization when struct has a function pointer array) (#5190)

This commit is contained in:
Daniel Marjamäki 2023-06-25 11:37:49 +02:00 committed by GitHub
parent 87c2b8df04
commit 91dedf05b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 6 deletions

View File

@ -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
@ -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: |

View File

@ -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

View File

@ -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 };