[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20260121145731.3623-2-david.laight.linux@gmail.com>
Date: Wed, 21 Jan 2026 14:57:18 +0000
From: david.laight.linux@...il.com
To: Nathan Chancellor <nathan@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Thomas Gleixner <tglx@...utronix.de>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...nel.org>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Arnd Bergmann <arnd@...db.de>,
linux-arch@...r.kernel.org,
linux-kernel@...r.kernel.org,
Yury Norov <yury.norov@...il.com>,
Lucas De Marchi <lucas.demarchi@...el.com>,
Jani Nikula <jani.nikula@...el.com>,
Vincent Mailhol <mailhol.vincent@...adoo.fr>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Kees Cook <keescook@...omium.org>,
Andrew Morton <akpm@...ux-foundation.org>
Cc: David Laight <david.laight.linux@...il.com>
Subject: [PATCH next 01/14] overflow: Reduce expansion of __type_max()
From: David Laight <david.laight.linux@...il.com>
Change '(x - 1) + x' to '2 * (x - 1) + 1' to avoid expanding the
non-trivial __type_half_max() twice.
Signed-off-by: David Laight <david.laight.linux@...il.com>
---
include/linux/overflow.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/overflow.h b/include/linux/overflow.h
index 736f633b2d5f..4f014d55ab25 100644
--- a/include/linux/overflow.h
+++ b/include/linux/overflow.h
@@ -31,7 +31,7 @@
* credit to Christian Biere.
*/
#define __type_half_max(type) ((type)1 << (8*sizeof(type) - 1 - is_signed_type(type)))
-#define __type_max(T) ((T)((__type_half_max(T) - 1) + __type_half_max(T)))
+#define __type_max(T) ((T)(2 * (__type_half_max(T) - 1) + 1))
#define type_max(t) __type_max(typeof(t))
#define __type_min(T) ((T)((T)-type_max(T)-(T)1))
#define type_min(t) __type_min(typeof(t))
--
2.39.5
Powered by blists - more mailing lists