Products > Programming
GCC v11 32F4: compiler warning depends on optimisation level
<< < (13/13)
newbrain:

--- Quote from: peter-h on November 28, 2024, 08:08:28 pm ---How can they be sure len is not 0. Inbuf could contain any garbage.

--- End quote ---

Just a question: how is inbuf defined?
If a char array has been used, does cppcheck know that, by default, char is unsigned on gcc for arm?

If cppcheck thinks char to be signed, you'll never be able to obtain 0xFFFFu from the line:

--- Code: ---    len = inbuf[4] + 256 * inbuf[5];
--- End code ---
for semi-obvious reasons.

If inbuf is a uint8_t (or equivalently, explicit unsigned char) array, then the warning is indeed spurious, as you suggest.
peter-h:
static uint8_t inbuf[PKT_BUF_LEN];
and PKT_BUF_LEN is 2048 bytes.
Navigation
Message Index
Previous page
There was an error while thanking
Thanking...

Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod