[PATCH 3/7] lib/math/int_log: drop WARN_ON for value == 0

From: Jia He

Date: Thu May 14 2026 - 01:09:22 EST


intlog2(0) and intlog10(0) already return 0, and the math-int_log
kunit suite passes {0, 0} as a valid input. The leftover WARN_ON(1) on
that path produces a backtrace per test run. Just remove it.

Signed-off-by: Jia He <justin.he@xxxxxxx>
---
lib/math/int_log.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/lib/math/int_log.c b/lib/math/int_log.c
index 8f9da3a2ad39..8585207cbe7f 100644
--- a/lib/math/int_log.c
+++ b/lib/math/int_log.c
@@ -59,10 +59,8 @@ unsigned int intlog2(u32 value)
unsigned int significand;
unsigned int interpolation;

- if (unlikely(value == 0)) {
- WARN_ON(1);
+ if (unlikely(value == 0))
return 0;
- }

/* first detect the msb (count begins at 0) */
msb = fls(value) - 1;
@@ -116,10 +114,8 @@ unsigned int intlog10(u32 value)
*/
u64 log;

- if (unlikely(value == 0)) {
- WARN_ON(1);
+ if (unlikely(value == 0))
return 0;
- }

log = intlog2(value);

--
2.34.1