Menu

Cppcheck-2.5

2021-05-22
2021-11-16
1 2 3 > >> (Page 1 of 3)
  • Daniel Marjamäki

    We got asked by different people about when we will release Cppcheck-2.5. As there was problems in Cppcheck-2.4.

    I think it would be good to focus on robustness from now on so we can release Cppcheck-2.5 soonish, maybe in a couple of weeks.

    What regressions did we have in Cppcheck-2.4 that we should fix in Cppcheck-2.5? The ones I know about..
    * crash was reported in chat that is already fixed in HEAD.
    * misra addon problems (9.x)
    * suppressions and compile database (https://sourceforge.net/p/cppcheck/discussion/general/thread/add5506807)
    * include limits missing (https://sourceforge.net/p/cppcheck/discussion/general/thread/ab8d5e7d54/)

    Does anybody have any feedback about other critical regressions/bugs?

     
    • CHR

      CHR - 2021-05-28

      I just ran this commit on our code base.
      There are a bunch of new unreadVariable, uninitvar and knownConditionTrueFalse warnings, which seem to be TP at first glance.
      I have found a minor FP, and there might be an instance of FP pointerOutOfBounds that I still need to investigate.

      Since 2.4, we get a spurious ctuOneDefinitionRuleViolationfrom a header file that I can't isolate so far. Maybe cppcheck thinks that the header is included twice, despite the include guards?

       
      • CHR

        CHR - 2021-05-28

        As it turns out, ctuOneDefinitionRuleViolation disappears when --cppcheck-build-dir=MyDir is removed. I saw many files were created in MyDir, but the execution time did not improve at all. Is --cppcheck-build-dir supposed to work with the -j N option?

         
  • Richard Smith

    Richard Smith - 2021-05-27

    Compared to 2.3 I'm also seeing a regression in MISRA 8.2 and arrayIndexOutofBounds.
    I need to try and create test cases for both of these but I believe they are false postive regressions. They do not occur in 2.3 and they are in 2.4 and HEAD.

    Grrr...I tried to provide examples but the spambot protection is preventing me from posting them. I'll have to try and work on seeing if I can come up with some small test cases.

     
  • Richard Smith

    Richard Smith - 2021-05-27
    misra-c2012-8.2: Function types shall be in prototype form with named parameters_
    bool func_name_write_buffer               (device_register_t register_address,
    
     arrayIndexOutOfBounds: Array 'string[5]' accessed at index 255, which is out of bounds.
            if (!success || (string[loc] == (uint8_t)'\0'))
    
     
    • Daniel Marjamäki

      we would need some more code to reproduce these false positives.

      misra-c2012-8.2: is the parser wrong for some reason maybe? I am pretty sure that the problem is not this specific code.

      arrayIndexOutOfBounds: I cannot tell why Cppcheck thinks that loc is 255. I need more code.

       

      Last edit: Daniel Marjamäki 2021-05-28
      • Richard Smith

        Richard Smith - 2021-05-28

        Nod. I was just marking the categories of regressions I'm seeing so they are on the list of things to look into.
        Not having any luck with making a test case for 8.2. I'll probably have to add some sort of code in the script to dump out the tokens.
        I'll need to look deeper into the OutOfBounds error and verify it really is a FP, but it doesn't happen in 2.3. So something changed between 2.3 and HEAD that affects it.

         
        • Daniel Marjamäki

          understood.. good!

           
  • Richard Smith

    Richard Smith - 2021-05-27

    There we go. I removed the file paths and spambot was happy.

     
  • Daniel Marjamäki

    I consider current cppcheck HEAD to be cppcheck-2.5-rc1

    Does anybody see important regressions?

    Richard could you check if the misra crash is fixed that is very important.

     

    Last edit: Daniel Marjamäki 2021-06-12
    • Richard Smith

      Richard Smith - 2021-06-12

      Richard could you check if the misra crash is fixed that is very important.

      Thanks for the update. Ill try to test tomorrow but if not then on Monday.

       
  • Daniel Marjamäki

    Hello! My goal is to release cppcheck-2.5 on saturday. If anybody see a problem please share it.

     
    👍
    1

    Last edit: Daniel Marjamäki 2021-06-15
    • Richard Smith

      Richard Smith - 2021-06-15

      Sorry it took me a so long to test.
      The misra 9.2 StopIteration exception has not changed.

        File "/home/rsmith/..../share/Cppcheck/addons/misra_9.py", line 438, in createArrayChildrenDefs
          foundToken = next(rawToken for rawToken in rawTokens if rawToken.file == token.file and rawToken.linenr == token.linenr and rawToken.column == token.column)
      StopIteration
      
       
      • Daniel Marjamäki

        This should be fixed so please feel free to try again..

         
    • Paul Fultz

      Paul Fultz - 2021-06-15

      There are some known syntax/ast regressions:

      https://trac.cppcheck.net/ticket/10317
      https://trac.cppcheck.net/ticket/10309
      https://trac.cppcheck.net/ticket/10034

      It would be good to fix those before release as these can't be easily suppressed.

       
  • Duong Nhat Minh

    Duong Nhat Minh - 2021-06-17

    Hi,
    When the function has no input parameter, I got false positive with misra-c2012-8.2.

    [rule_test.h:4] (warning) Function types shall be in prototype form with named parameters (Required) [misra-c2012-8.2]

     
    • Georgiy Komarov

      Georgiy Komarov - 2021-06-17

      Hi,

      Could you please add the source code of your example? I can't reproduce this using just the code of the rule_test.h from your screenshot.

      The full cppcheck command you are using and the version of cppcheck will be also very helpful.

       
      • Duong Nhat Minh

        Duong Nhat Minh - 2021-06-17

        Hi,

        I'm using Cppcheck 2.4.1.
        The full cppcheck commands:

        cppcheck --dump Misra_Test.c
        "C:\Program Files\Cppcheck\addons\misra.py" --rule-texts="E:\Cppcheck\misra_rules.txt" Misra_Test.c.dump
        

        I attached my source code. Sorry it's quite messy since it's only for test, please just focus on the rule 8.2. My whole check results:

        E:\Minh\Programming\Coding_Standard\MISRA\Misra_Check\c_test>cppcheck --dump Misra_Test.c
        Checking Misra_Test.c ...
        
        E:\Minh\Programming\Coding_Standard\MISRA\Misra_Check\c_test>python "C:\Program Files\Cppcheck\addons\misra.py" --rule-texts="E:\Cppcheck\misra_rules.txt" Misra_Test.c.dump
        Checking Misra_Test.c.dump...
        Checking Misra_Test.c.dump, config ...
        [rule_test.h:4] (warning) Function types shall be in prototype form with named parameters (Required) [misra-c2012-8.2]
        [Misra_Test.c:20] (warning) Function types shall be in prototype form with named parameters (Required) [misra-c2012-8.2]
        [Misra_Test.c:25] (warning) Arrays shall not be partially initialized (Required) [misra-c2012-9.3]
        [Misra_Test.c:25] (warning) An element of an object shall not be initialized more than once (Required) [misra-c2012-9.4]
        [Misra_Test.c:26] (style) The comma operator should not be used (Advisory) [misra-c2012-12.3]
        [Misra_Test.c:8] (warning) Expressions resulting from the expansion of macro parameters shall be enclosed in parentheses (Required) [misra-c2012-20.7]
        [Misra_Test.c:4] (warning) The Standard Library input/output functions shall not be used (Required) [misra-c2012-21.6]
        
        MISRA rules violations found:
                Required: 6
                Advisory: 1
        
        MISRA rules violated:
                misra-c2012-8.2 (-): 2
                misra-c2012-9.3 (-): 1
                misra-c2012-9.4 (-): 1
                misra-c2012-12.3 (-): 1
                misra-c2012-20.7 (-): 1
                misra-c2012-21.6 (-): 1
        
        E:\Minh\Programming\Coding_Standard\MISRA\Misra_Check\c_test>cppcheck --version
        Cppcheck 2.4.1
        
         
        • Georgiy Komarov

          Georgiy Komarov - 2021-06-17

          Thanks for the example.

          But I can't reproduce this issue yet.

          I've downloaded sources and executed the following command: ./cppcheck --dump Misra_Test.c && addons/misra.py Misra_Test.c.dump.

          With both cppcheck 2.4.1 and cppcheck from the main branch, I didn't get any false positives:

          Checking Misra_Test.c ...
          Checking Misra_Test.c.dump...
          Checking Misra_Test.c.dump, config ...
          [Misra_Test.c:25] (style) misra violation (use --rule-texts=<file> to get proper output) (Undefined) [misra-c2012-9.3]
          [Misra_Test.c:25] (style) misra violation (use --rule-texts=<file> to get proper output) (Undefined) [misra-c2012-9.4]
          [Misra_Test.c:26] (style) misra violation (use --rule-texts=<file> to get proper output) (Undefined) [misra-c2012-12.3]
          [Misra_Test.c:8] (style) misra violation (use --rule-texts=<file> to get proper output) (Undefined) [misra-c2012-20.7]
          [Misra_Test.c:4] (style) misra violation (use --rule-texts=<file> to get proper output) (Undefined) [misra-c2012-21.6]
          
          MISRA rules violations found:
              Undefined: 5
          
          MISRA rules violated:
              misra-c2012-9.3 (-): 1
              misra-c2012-9.4 (-): 1
              misra-c2012-12.3 (-): 1
              misra-c2012-20.7 (-): 1
              misra-c2012-21.6 (-): 1
          

          That's very strange.

          According to git blame, rule 8.2 was implemented in the single commit: 9786f1 and one follow-up minor fix that can't be related to false positives. So, I assume that false positives you reported are not related to the cppcheck version.

          I'm not sure what else could be causing the problems.
          Could you please also attach the dump file (Misra_Test.c.dump) you generated?
          May be there some platform-dependent differences, because I'm on Linux, but but that would be strange.

           
          • Duong Nhat Minh

            Duong Nhat Minh - 2021-06-17

            Hi,

            Thanks for response.

            Sorry I forgot to mention that I'm using this file for Misra check.
            https://github.com/jubnzv/cppcheck/blob/fix-misra-8-2-crash/addons/misra.py

            I attached the dump file, please take a look.
            Thanks

             

            Last edit: Duong Nhat Minh 2021-06-17
            • Georgiy Komarov

              Georgiy Komarov - 2021-06-17

              I was able to reproduce the problem.

              These false positives occur only for dump files created with cppcheck 2.4.1. But MISRA addon in version 2.4.1 doesn't have rule 8.2, so, we need the an addon from the latest version of Cppcheck to reproduce the problem.

              The good news is that if you use cppcheck from the main branch (or version 2.5, which is coming soon), these false positives will disappear.

               
              • Richard Smith

                Richard Smith - 2021-06-17

                But the bad news is that I'm running 2.5 and I also see a huge amount of 8.2 violations that appear to be false positive. I've isolated a few examples from a uart driver that I can post up.

                $ cppcheck --addon=misra.py uart.c 
                Checking uart.c ...
                uart.c:37:23: style: misra violation (use --rule-texts=<file> to get proper output) [misra-c2012-8.2]
                void uart1_initialize(int baud)
                                      ^
                uart.c:103:29: style: misra violation (use --rule-texts=<file> to get proper output) [misra-c2012-8.2]
                bool uart1_polled_send_byte(uint8_t data)
                                            ^
                
                 
                • Richard Smith

                  Richard Smith - 2021-06-17

                  I should add that to get this I first have to apply the workaround I put up in the other thread to prevents the StopIteration issue I have.

                   
                • Georgiy Komarov

                  Georgiy Komarov - 2021-06-25

                  Sorry for the late response. Here is a fix: https://github.com/danmar/cppcheck/pull/3306 .

                   
                  • Richard Smith

                    Richard Smith - 2021-06-26

                    Looks like the StopIteration exception may be fixed as I'm not seeing that any more however I still have a large amount of 8.2 messages. Many (but not all) seem to be related to C99 types. Here is a small file that triggers one.

                    $ cppcheck --addon=misra.py 8_2.c 
                    Checking 8_2.c ...
                    8_2.c:114:33: style: misra violation (use --rule-texts=<file> to get proper output) [misra-c2012-8.2]
                    static bool default_rx_callback(uint8_t * const data)
                                                    ^
                    
                     
1 2 3 > >> (Page 1 of 3)

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.