From 5d12df51fc431ecb159112bf4a40983c2ccba165 Mon Sep 17 00:00:00 2001 From: Yoctopuce Date: Fri, 24 May 2024 11:56:40 +0200 Subject: [PATCH] py/obj: Make literals unsigned in float get/new functions. Fixes gcc warning when -Wsign-conversion is on. Signed-off-by: Yoctopuce --- py/obj.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/py/obj.h b/py/obj.h index 8a32bfcf0..bd31ef11d 100644 --- a/py/obj.h +++ b/py/obj.h @@ -203,7 +203,7 @@ static inline mp_float_t mp_obj_float_get(mp_const_obj_t o) { union { mp_float_t f; mp_uint_t u; - } num = {.u = ((mp_uint_t)o - 0x80800000) & ~3}; + } num = {.u = ((mp_uint_t)o - 0x80800000u) & ~3u}; return num.f; } static inline mp_obj_t mp_obj_new_float(mp_float_t f) { @@ -211,7 +211,7 @@ static inline mp_obj_t mp_obj_new_float(mp_float_t f) { mp_float_t f; mp_uint_t u; } num = {.f = f}; - return (mp_obj_t)(((num.u & ~0x3) | 2) + 0x80800000); + return (mp_obj_t)(((num.u & ~0x3u) | 2u) + 0x80800000u); } #endif