Menu

latest commits: new FP regarding different containers

Martin
2021-11-15
2021-11-16
  • Martin

    Martin - 2021-11-15

    Hi,

    between commits
    old commit: 49d3e07b59819c5f999369feb04543154a752817
    new commit: a0d3c2c719cedcd68877ff911d4fb579bc39f0ed
    a new FP was introduced for:

    void foo(const uint8_t* data, const uint32_t dataLength)
    {
       const uint32_t minimumLength = sizeof(uint16_t) + sizeof(uint16_t);
       if (dataLength >= minimumLength)
       {
                   char* payload = new char[dataLength - minimumLength];
                   std::copy(&data[minimumLength], &data[dataLength], payload);
       }
    }
    

    cppcheck reports:

    error: Iterators of different containers 'data[minimumLength]' and 'data[dataLength]' are used together. [mismatchingContainers]
                   std::copy(&data[minimumLength], &data[dataLength], payload);
                                  ^
    

    Could you please check?

    Thanks,
    Martin

     
  • CHR

    CHR - 2021-11-16

    I think this is the same problem: https://trac.cppcheck.net/ticket/10604

     

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.