From 191f7e486957782606da737a728ccf59f12d0cab Mon Sep 17 00:00:00 2001 From: James Almer Date: Thu, 20 Nov 2025 23:50:44 -0300 Subject: [PATCH] tests/checkasm/sw_ops: fix signed integer related UB when shifting values Fixes: src/tests/checkasm/sw_ops.c:441:34: runtime error: shift exponent 32 is too large for 32-bit type 'int' src/tests/checkasm/sw_ops.c:591:37: runtime error: shift exponent 32 is too large for 32-bit type 'int' Signed-off-by: James Almer --- tests/checkasm/sw_ops.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/checkasm/sw_ops.c b/tests/checkasm/sw_ops.c index 20b697bf25..aea25bbbbc 100644 --- a/tests/checkasm/sw_ops.c +++ b/tests/checkasm/sw_ops.c @@ -438,7 +438,7 @@ static AVRational rndq(SwsPixelType t) { const unsigned num = rnd(); if (ff_sws_pixel_type_is_int(t)) { - const unsigned mask = (1 << (ff_sws_pixel_type_size(t) * 8)) - 1; + const unsigned mask = UINT_MAX >> (32 - ff_sws_pixel_type_size(t) * 8); return (AVRational) { num & mask, 1 }; } else { const unsigned den = rnd(); @@ -588,7 +588,7 @@ static void check_convert(void) .convert.to = o, }); } else if (isize > osize || !ff_sws_pixel_type_is_int(i)) { - uint32_t range = (1 << osize * 8) - 1; + uint32_t range = UINT32_MAX >> (32 - osize * 8); CHECK_COMMON_RANGE(name, range, i, o, { .op = SWS_OP_CONVERT, .type = i,