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

math.h: amend abs() kernel-doc and add a note about signed type limits

- amend the kernel-doc so the description is decoupled from the
parameter descriptions.

- add a note to explain behaviour for the signed types when supplied
value is the minimum (e.g., INT_MIN for int type).

Link: https://lkml.kernel.org/r/20251106152051.2361551-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Andy Shevchenko and committed by
Andrew Morton
f3fb126f 581ee79a

+9 -4
+9 -4
include/linux/math.h
··· 148 148 149 149 /** 150 150 * abs - return absolute value of an argument 151 - * @x: the value. If it is unsigned type, it is converted to signed type first. 152 - * char is treated as if it was signed (regardless of whether it really is) 153 - * but the macro's return type is preserved as char. 151 + * @x: the value. 154 152 * 155 - * Return: an absolute value of x. 153 + * If it is unsigned type, @x is converted to signed type first. 154 + * char is treated as if it was signed (regardless of whether it really is) 155 + * but the macro's return type is preserved as char. 156 + * 157 + * NOTE, for signed type if @x is the minimum, the returned result is undefined 158 + * as there is not enough bits to represent it as a positive number. 159 + * 160 + * Return: an absolute value of @x. 156 161 */ 157 162 #define abs(x) __abs_choose_expr(x, long long, \ 158 163 __abs_choose_expr(x, long, \