Skip to content
Commit cae8bd74 authored by Daniel Leung's avatar Daniel Leung Committed by Carles Cufí
Browse files

sys: util: cast input of KB() to size_t for large number



Numbers in C macros are treated as signed integer. This causes
issues when using macro KB(x). If the result is larger than
(2^31 - 1), it is treated as a negative number downstream.
For example, the RAM size of up_squared is 2GB. The result of
KB(CONFIG_SRAM_SIZE) should be 2147483648, but due to being
casted as signed, the result is instead -2147483648. Any
calculations using this would be incorrectly. Fix it by
casting x in KB(x) to size_t first.

Fixes #27164

Signed-off-by: default avatarDaniel Leung <daniel.leung@intel.com>
parent f327ed2f
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment