cppcheck: Suprocess warnings of type "objectIndex"

Report from Cppcheck 2.4.1 was:

lib/xmlparse.c:729:26: warning: The address of local variable 'entropy' might be accessed at non-zero index. [objectIndex]
      ((uint8_t *)target)[bytesWrittenTotal] = random8;
                         ^
lib/xmlparse.c:820:39: note: Address of variable taken here.
  writeRandomBytes_arc4random((void *)&entropy, sizeof(entropy));
                                      ^
lib/xmlparse.c:820:31: note: Calling function 'writeRandomBytes_arc4random', 1st argument '(void*)&entropy' value is lifetime=entropy
  writeRandomBytes_arc4random((void *)&entropy, sizeof(entropy));
                              ^
lib/xmlparse.c:729:26: note: The address of local variable 'entropy' might be accessed at non-zero index.
      ((uint8_t *)target)[bytesWrittenTotal] = random8;
                         ^
lib/xmltok.c:318:54: error: The address of local variable 'fromLim' is accessed at non-zero index. [objectIndex]
    const unsigned char prev = (unsigned char)fromLim[-1];
                                                     ^
lib/xmltok.c:369:56: note: Address of variable taken here.
    _INTERNAL_trim_to_complete_utf8_characters(*fromP, &fromLim);
                                                       ^
lib/xmltok.c:369:56: note: Calling function '_INTERNAL_trim_to_complete_utf8_characters', 2nd argument '&fromLim' value is lifetime=fromLim
    _INTERNAL_trim_to_complete_utf8_characters(*fromP, &fromLim);
                                                       ^
lib/xmltok.c:318:54: note: The address of local variable 'fromLim' is accessed at non-zero index.
    const unsigned char prev = (unsigned char)fromLim[-1];
                                                     ^
This commit is contained in:
Sebastian Pipping 2021-04-05 18:32:03 +02:00
parent bfe4b25b80
commit 2f051a681b

View File

@ -70,7 +70,7 @@ elif [[ ${MODE} = cppcheck ]]; then
-name xmltok_ns.c
-o -name xmltok_impl.c
\)
-exec cppcheck --quiet --error-exitcode=1 --force {} +
-exec cppcheck --quiet --error-exitcode=1 --force --suppress=objectIndex {} +
)
find "${find_args[@]}"
elif [[ ${MODE} = clang-format ]]; then