Menu

Inline unsuppress?

2020-12-02
2020-12-04
  • Juozapas Bočkus

    I know there is an inline rule suppression feature and it works for me fine, but how do I inline re-enable the suppressed rule after I no longer need it to be suppressed?

     
  • Daniel Marjamäki

    I am not sure what you mean. Just remove the comment?

     
  • Juozapas Bočkus

    I meant that I want only a specific portion of a file with suppression and the rest of the file should be checked for MISRA compatibility.

    // inline suppress
    some_code_that_should_not_be_checked();
    // inline un-suppress
    some_code_that_should_be_checked();

     
  • Daniel Marjamäki

    We do not have such functionality at the moment. Sounds weird that you have different coding rules in a file. How about using a define?

    #ifndef CPPCHECK_MISRA_CHECKER
    some_code_that_should_not_be_checked();
    #endif
    some_code_that_should_be_checked();
    

    cppcheck -DCPPCHECK_MISRA_CHECKER --addon=misra file.c

    well it's a simple solution but maybe that will have problems I don't know.

     
  • Daniel Marjamäki

    If you had different files for misra compliant code and non-misra-compliant code then you could suppress:

    --suppress="misra-c2012-*:non-compliant-file.h"
    
     

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.