diff --git a/.github/workflows/CI-unixish.yml b/.github/workflows/CI-unixish.yml index 0c941e057..f5f25d51b 100644 --- a/.github/workflows/CI-unixish.yml +++ b/.github/workflows/CI-unixish.yml @@ -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: | diff --git a/addons/misra_9.py b/addons/misra_9.py index 8a9a62878..b4f780bba 100644 --- a/addons/misra_9.py +++ b/addons/misra_9.py @@ -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 diff --git a/addons/test/misra/crash2.c b/addons/test/misra/crash2.c new file mode 100644 index 000000000..c736a265d --- /dev/null +++ b/addons/test/misra/crash2.c @@ -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 };