Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

overflow: Remove is_non_negative() and is_negative()

The is_non_negative() and is_negative() function-like macros just
exist as a workaround to silence the -Wtype-limits warning. Now that
this warning is disabled, those two macros have lost their raison
d'être. Remove them.

This reverts commit dc7fe518b049 ("overflow: Fix -Wtype-limits
compilation warnings").

Suggested-by: Nicolas Schier <nsc@kernel.org>
Link: https://lore.kernel.org/all/aUT_yWin_xslnOFh@derry.ads.avm.de
Signed-off-by: Vincent Mailhol <mailhol@kernel.org>
Reviewed-by: Nicolas Schier <nsc@kernel.org>
Link: https://patch.msgid.link/20251220-remove_wtype-limits-v3-3-24b170af700e@kernel.org
Signed-off-by: Nathan Chancellor <nathan@kernel.org>

authored by

Vincent Mailhol and committed by
Nathan Chancellor
5ce3218d 34a1bd0b

+2 -8
+2 -8
include/linux/overflow.h
··· 36 36 #define __type_min(T) ((T)((T)-type_max(T)-(T)1)) 37 37 #define type_min(t) __type_min(typeof(t)) 38 38 39 - /* 40 - * Avoids triggering -Wtype-limits compilation warning, 41 - * while using unsigned data types to check a < 0. 42 - */ 43 - #define is_non_negative(a) ((a) > 0 || (a) == 0) 44 - #define is_negative(a) (!(is_non_negative(a))) 45 39 46 40 /* 47 41 * Allows for effectively applying __must_check to a macro so we can have ··· 195 201 typeof(d) _d = d; \ 196 202 unsigned long long _a_full = _a; \ 197 203 unsigned int _to_shift = \ 198 - is_non_negative(_s) && _s < 8 * sizeof(*d) ? _s : 0; \ 204 + _s >= 0 && _s < 8 * sizeof(*d) ? _s : 0; \ 199 205 *_d = (_a_full << _to_shift); \ 200 - (_to_shift != _s || is_negative(*_d) || is_negative(_a) || \ 206 + (_to_shift != _s || *_d < 0 || _a < 0 || \ 201 207 (*_d >> _to_shift) != _a); \ 202 208 })) 203 209