[PATCH 2/3] tools/mm/page-types: Fix ternary operator precedence in sigbus handler
From: Ye Liu
Date: Tue May 12 2026 - 22:22:07 EST
From: Ye Liu <liuye@xxxxxxxxxx>
The ternary operator (?:) has lower precedence than addition (+), so
the expression `off + sigbus_addr ? sigbus_addr - ptr : 0` was parsed
as `(off + sigbus_addr) ? (sigbus_addr - ptr) : 0` rather than the
intended `off + (sigbus_addr ? sigbus_addr - ptr : 0)`. Add explicit
parentheses to ensure the correct evaluation order.
Signed-off-by: Ye Liu <liuye@xxxxxxxxxx>
---
tools/mm/page-types.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/mm/page-types.c b/tools/mm/page-types.c
index 6594245217a8..66f429f2b698 100644
--- a/tools/mm/page-types.c
+++ b/tools/mm/page-types.c
@@ -1000,7 +1000,7 @@ static void walk_file_range(const char *name, int fd,
fatal("madvise failed: %s", name);
if (sigsetjmp(sigbus_jmp, 1)) {
- end = off + sigbus_addr ? sigbus_addr - ptr : 0;
+ end = off + (sigbus_addr ? sigbus_addr - ptr : 0);
fprintf(stderr, "got sigbus at offset %lld: %s\n",
(long long)end, name);
goto got_sigbus;
--
2.43.0