Menu

[Dumpfile] Suppressions for file and blocks?

2024-02-27
2024-02-27
  • Sven Wienand

    Sven Wienand - 2024-02-27

    Hey,

    i found that if i place the

    cppcheck-suppress-file <error>
    

    or

    cppcheck-suppress-begin <error>
    cppcheck-suppress-end <error>
    

    the dump file will have

    <suppression errorId="error" fileName="src/main.c" lineNumber="12" />
    

    and for a file suppression this doesn't make sense as you can not distinguish it from a line supression. It would be easier to remove the lineNumber so that it is similar to the global suppressions given via cli

    <suppression errorId="variableScope" />
    

    For suppression blocks i am not sure how it is currently handled internally but the output in the dump file should either be

    <suppression errorId="error" fileName="src/main.c" lineNumber="12" />
    <suppression errorId="error" fileName="src/main.c" lineNumber="13" />
    <suppression errorId="error" fileName="src/main.c" lineNumber="14" />
    <suppression errorId="error" fileName="src/main.c" lineNumber="15" />
    

    or something maybe something like

    <suppression errorId="error" fileName="src/main.c" lineNumber="12" lineEnd="15"/>
    

    Any suggestions what should be the correct notaition in the dump file and what implication that might have? Especially regarding setting lineNumber of the global file suppression to None?
    Also hints where to do the change would be appreciated. For now i found https://github.com/danmar/cppcheck/blob/da518aa92f7e40ad31625b791f9a0b1325b2c8a1/lib/suppressions.cpp#L444 and https://github.com/danmar/cppcheck/blob/da518aa92f7e40ad31625b791f9a0b1325b2c8a1/lib/suppressions.h#L140C13-L140C23, to get line Begin and End if they are filled out correctly.

    The only thing i didn't found yet was where the line would be set for the cppcheck-suppress-file to set it to NO_LINE.

     

    Last edit: Sven Wienand 2024-02-27
  • Sven Wienand

    Sven Wienand - 2024-02-27

    Okay now i found that there is a Type: https://github.com/danmar/cppcheck/blob/da518aa92f7e40ad31625b791f9a0b1325b2c8a1/lib/suppressions.h#L45-L47

    So maybe we can add the type to the Dump file to give the additional information and we don't need to remove the lineNumber for the file suppression as the type should be "file" and therefore descriptive.

    I would suggest to add Type, lineBegin, lineEnd to the dump file export if they exist.

     

    Last edit: Sven Wienand 2024-02-27

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.