Menu

Different behaviour with --project

Dzid
2024-06-08
2024-06-09
  • Dzid

    Dzid - 2024-06-08

    I have two files.

    cp.json :

    [
        {
            "command": "arm-none-eabi-gcc   1.c",
            "directory": ".",
            "file": "1.c"
        }
    ]
    

    and 1.c:

    #define TEST_2_5 1
    int main(void){
    }
    

    I can run, either:
    1. cppcheck --enable=all --addon=misra 1.c
    2. cppcheck --enable=all --addon=misra --project=cp.json

    In the former I get:

    $ cppcheck --enable=all --addon=misra 1.c
    Checking 1.c ...
    1.c:1:0: style: misra violation (use --rule-texts=<file> to get proper output) [misra-c2012-2.5]
    #define TEST_2_5 1
    ^
    nofile:0:0: information: Active checkers: 295/1002 (use --checkers-report=<filename> to see details) [checkersReport]
    

    And in the later, there is no violation.

    $ cppcheck --enable=all --addon=misra --project=cp.json
    Checking 1.c ...
    nofile:0:0: information: Active checkers: 295/1002 (use --checkers-report=<filename> to see details) [checkersReport]
    

    What is wrong?

     

    Last edit: Dzid 2024-06-08
  • Dzid

    Dzid - 2024-06-08

    The violation is present in ctu-info file,
    "summary": "MisraMacro", "data": [{"name": "TEST_2_5", "used": false ...
    but then the file is deleted.

     
  • Dzid

    Dzid - 2024-06-08

    Also, running with build dir: ./cppcheck/cppcheck --enable=all --addon=misra 1.c --cppcheck-build-dir=. multiple times, produces misra-c2012-2.5 violation only for the first time.

     

    Last edit: Dzid 2024-06-08
  • Dzid

    Dzid - 2024-06-09

    https://github.com/danmar/cppcheck/pull/6499 fixes this particular issue, but it is not a general solution, as misra addon performs system level analysis only on last macro configuration.

    I added testcases towards implementing a proper fix:
    https://github.com/danmar/cppcheck/pull/6551

     

    Last edit: Dzid 2024-07-26

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.