Menu

can't stop Redundant assignment warnings

2019-07-22
2019-07-30
  • Anthony Fitzgerald

    Hi,
    new to cppcheck
    version 1.88
    can't supress "Redundant assignment" warnings
    I tried just providing the supression value = redundantAssignment
    I tried the value and *.cpp for file name
    I tried the full supression as shown below
    nothing works?

    code (file RS232DigitalIO.cpp)
    564 bool bClose = m_SIO.CloseComPort();
    565 bClose = bClose;
    warning:
    565 Redundant assignment of 'bClose' to itself.
    my suppression:
    <suppressions>
    <suppression symbolname="'bClose" linenumber="565" filename="RS232DigitalIO.cpp">redundantAssignment</suppression>
    </suppressions>
    Thanks,
    ajfitz

     
  • versat

    versat - 2019-07-30

    Sorry for this late reply.
    I have tried to understand the issue and created a small example project to reproduce the issue.
    I can reproduce it with 1.88 and with HEAD (1.89 dev).
    Looks like you found a bug:
    When the suppressions from the project file are loaded and a file name is specified for a suppression that does not start with * then the absolute path is prepended to the file name.
    But the file name that is specified in the error message during the analysis does not (always) contains the full path. So when the file name of the error message and the suppression are compared the Cppcheck wrongly thinks they are different.
    I will create a ticket for that issue.
    Thanks for reporting that!
    Attached is my small test project for reproducing the issue.

     
  • versat

    versat - 2019-07-30

    I have created the ticket https://trac.cppcheck.net/ticket/9240
    As a workaround for this bug it is possible to suppress unwanted errors in files when adding a * in front of the file name.
    So with *supr_issue.cpp it works for my example project.

     

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.