Skip to content

Integer overflow on 16-bit MCUs #1

Description

@zakoverflow

Observation

Warning caught while compiliing note-arduino v1.5.4 for an Arduino Uno in the Arduino IDE 2.3.0

/home/zak/Development/Arduino/libraries/Blues_Wireless_Notecard/src/note-c/n_request.c: In function 'noteTransactionShouldLock':
/home/zak/Development/Arduino/libraries/Blues_Wireless_Notecard/src/note-c/n_request.c:503:40: warning: integer overflow in expression [-Woverflow]
             transactionTimeoutMs = (90 * 1000);
                                        ^

Expectation

When compiling for a 16-bit MCU, constant values that would cause an overflow, such as (90 * 1000), should cast into a fixed size integer (e.g. uint32_t) or be gated by precompiler instructions, which provide the largest possible value without overflowing.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions