Menu

Cppcheck false error

Krishna
2021-07-15
2021-07-15
  • Krishna

    Krishna - 2021-07-15

    Hi,

    I have a volatile variable that I'm calculating difference count with some delay. But with cppcheck v2.4.1 I'm seeing an error.

    Please find the attachment for error information. In the attachment TPR is of type __IO (defined to volatile).

    Is this false error, if so where can I create bug?

     

    Last edit: Krishna 2021-07-15
  • Daniel Marjamäki

    I agree it's a false positive.

    Can you provide a bit better example code. I don't see a false positive for this:

    struct {
      volatile uint32_t TPR;
    } RTC;
    
    void foo() {
    
        uint32_t initialCycles = RTC->TPR;
        Delay();
        uint32_t finalCycles = RTC->TPR;
        uint32_t diffCycles    = finalCycles - initialCycles;
    
        if (diffCycles > 28u){}
    }
    
     
  • Krishna

    Krishna - 2021-07-15

    Hi Daniel,

    Thanks for a quick reply.

    I found the ticket is already there for this issue - https://trac.cppcheck.net/ticket/10223.
    But I'm unable to understand the current status of this ticket. Is it in progress or closed?

    Thanks.

     
    • Daniel Marjamäki

      it is open. nobody is currently working on it.

       
      • Daniel Marjamäki

        if you want to investigate the problem then feel free to do it.

         

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.