Menu

false positives with branch prediction

2021-06-23
2021-06-25
  • Paul Aitken

    Paul Aitken - 2021-06-23

    How can I avoid false positive reports when using DPDK's "likely" and "unlikely" branch prediction macros?

    eg, "Memory leak" is reported for this snippet:

        ptr = calloc(...);
        if (unlikely(!ptr)) {
            RTE_LOG(...);
            return NULL;
        }
    

    Thanks.

     
  • Daniel Marjamäki

    you could test the configuration in gnu.cfg

      <define name="likely(X)" value="(X)"/>
      <define name="unlikely(X)" value="(X)"/>
    
     
  • Paul Aitken

    Paul Aitken - 2021-06-25

    Thanks @danielmarjamaki, cppcheck --library=gnu ... solved that.

     

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.