[PATCH] tools/sched_ext: fix strtoul() misuse in scx_hotplug_seq()

From: David Carlier

Date: Fri Feb 27 2026 - 13:14:50 EST


scx_hotplug_seq() uses strtoul() to parse the hotplug sequence number
but checks the result with val < 0. Since strtoul() returns an unsigned
long, it never produces a negative value, making the validation dead
code.

Switch to strtol() so the negative check is meaningful and fix the
format specifier from %lu to %ld to match the long type of val.

Signed-off-by: David Carlier <devnexen@xxxxxxxxx>
---
tools/sched_ext/include/scx/compat.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/sched_ext/include/scx/compat.h b/tools/sched_ext/include/scx/compat.h
index 8b4897fc8b99..1518d05d3e21 100644
--- a/tools/sched_ext/include/scx/compat.h
+++ b/tools/sched_ext/include/scx/compat.h
@@ -137,8 +137,8 @@ static inline long scx_hotplug_seq(void)
buf[len] = 0;
close(fd);

- val = strtoul(buf, NULL, 10);
- SCX_BUG_ON(val < 0, "invalid num hotplug events: %lu", val);
+ val = strtol(buf, NULL, 10);
+ SCX_BUG_ON(val < 0, "invalid num hotplug events: %ld", val);

return val;
}
--
2.51.0