From 642f6dce97e24f22ee6179174ec9be588fc6a60c Mon Sep 17 00:00:00 2001 From: Stefan Gloor Date: Wed, 28 Jan 2026 10:43:14 +0100 Subject: [PATCH] chore(p256-m): add explicit uint16_t cast in u32_muladd64 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When splitting 32-bit x and y values into lower and higher 16-bit values, make sure to explicitly cast the higher part to uint16_t as well. This fixes the compiler warning: src/common/crypto_p256.c: In function ‘u32_muladd64’: src/common/crypto_p256.c:264:29: warning: conversion from ‘uint32_t’ {aka ‘unsigned int’} to ‘uint16_t’ {aka ‘const short unsigned int’} may change value [-Wconversio] 264 | const uint16_t xh = x >> 16; | ^ src/common/crypto_p256.c:265:29: warning: conversion from ‘uint32_t’ {aka ‘unsigned int’} to ‘uint16_t’ {aka ‘const short unsigned int’} may change value [-Wconversio] 265 | const uint16_t yh = y >> 16; | ^ Signed-off-by: Stefan Gloor --- p256-m.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/p256-m.c b/p256-m.c index 28b85cb..8653ae6 100644 --- a/p256-m.c +++ b/p256-m.c @@ -307,8 +307,8 @@ static uint64_t u32_muladd64(uint32_t x, uint32_t y, uint32_t z, uint32_t t) /* x = xl + 2**16 xh, y = yl + 2**16 yh */ const uint16_t xl = (uint16_t) x; const uint16_t yl = (uint16_t) y; - const uint16_t xh = x >> 16; - const uint16_t yh = y >> 16; + const uint16_t xh = (uint16_t)(x >> 16); + const uint16_t yh = (uint16_t)(y >> 16); /* x*y = xl*yl + 2**16 (xh*yl + yl*yh) + 2**32 xh*yh * = lo + 2**16 (m1 + m2 ) + 2**32 hi */