From 53483eddbce70247a28a9d41dd33e2c559925ed4 Mon Sep 17 00:00:00 2001 From: Jan Dubiec Date: Mon, 3 Mar 2025 01:15:44 +0100 Subject: Silence -Woverflow warning in arc4random.c This patch fixes "integer overflow" warning in arc4random.c. It explicitly casts REKEY_BASE macro to size_t. The existing code relies on an implicit conversion to int and assumes that sizeof(int)=sizeof(size_t), which is not always true. 2025-03-02 Jan Dubiec newlib/ChangeLog: * libc/stdlib/arc4random.c (REKEY_BASE): Explicitly cast the macro to size_t. newlib/libc/stdlib/arc4random.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- newlib/libc/stdlib/arc4random.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'newlib/libc/stdlib/arc4random.c') diff --git a/newlib/libc/stdlib/arc4random.c b/newlib/libc/stdlib/arc4random.c index 09a134c..bc59678 100644 --- a/newlib/libc/stdlib/arc4random.c +++ b/newlib/libc/stdlib/arc4random.c @@ -50,11 +50,11 @@ #define RSBUFSZ (16*BLOCKSZ) #if SIZE_MAX <= 65535 -#define REKEY_BASE ( 32*1024) /* NB. should be a power of 2 */ +#define REKEY_BASE ( (size_t)32*1024) /* NB. should be a power of 2 */ #elif SIZE_MAX <= 1048575 -#define REKEY_BASE ( 512*1024) /* NB. should be a power of 2 */ +#define REKEY_BASE ( (size_t)512*1024) /* NB. should be a power of 2 */ #else -#define REKEY_BASE (1024*1024) /* NB. should be a power of 2 */ +#define REKEY_BASE ((size_t)1024*1024) /* NB. should be a power of 2 */ #endif /* Marked MAP_INHERIT_ZERO, so zero'd out in fork children. */ -- cgit v1.1