]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
math.h: amend abs() kernel-doc and add a note about signed type limits
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Thu, 6 Nov 2025 15:20:51 +0000 (16:20 +0100)
committerAndrew Morton <akpm@linux-foundation.org>
Thu, 20 Nov 2025 22:03:42 +0000 (14:03 -0800)
- 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>
include/linux/math.h

index 0198c92cbe3ef56ee1e3a88c3fbf8f2fa5461bf6..6dc1d1d32fbc81889e0f8dc3b3ad4178628206a3 100644 (file)
@@ -148,11 +148,16 @@ __STRUCT_FRACT(u32)
 
 /**
  * abs - return absolute value of an argument
- * @x: the value.  If it is unsigned type, it is converted to signed type first.
- *     char is treated as if it was signed (regardless of whether it really is)
- *     but the macro's return type is preserved as char.
+ * @x: the value.
  *
- * Return: an absolute value of x.
+ * If it is unsigned type, @x is converted to signed type first.
+ * char is treated as if it was signed (regardless of whether it really is)
+ * but the macro's return type is preserved as char.
+ *
+ * NOTE, for signed type if @x is the minimum, the returned result is undefined
+ * as there is not enough bits to represent it as a positive number.
+ *
+ * Return: an absolute value of @x.
  */
 #define abs(x) __abs_choose_expr(x, long long,                         \
                __abs_choose_expr(x, long,                              \