[PATCH 11/31] pahole: Fix --errno typo that decrements instead of negating
Arnaldo Carvalho de Melo <[email protected]> Wed, 29 Jul 2026 16:07:11 -0300
| Newsgroups | org.kernel.vger.dwarves,org.kernel.vger.bpf |
|---|---|
| Message-ID | <[email protected]> |
From: Arnaldo Carvalho de Melo <[email protected]> prototype__stdio_fprintf_value() uses --errno in three error paths, which decrements the global errno value instead of negating it with -errno. This causes the function to return a wrong (often positive) value on error, making callers think the operation succeeded. Before: --errno with errno=5 returns 4 (positive, looks like success) After: -errno with errno=5 returns -5 (negative, correctly signals error) Fixes: 9310b04854a8b709 ("pahole: Add support for referencing header variables when pretty printing") Reported-by: Sashiko:gemini-3-1-pro-preview Assisted-by: Claude:claude-sonnet-4-5 Signed-off-by: Arnaldo Carvalho de Melo <[email protected]> --- pahole.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pahole.c b/pahole.c index 0096dfa34e5047c8..6ba3f578c28570a1 100644 --- a/pahole.c +++ b/pahole.c @@ -2584,7 +2584,7 @@ static int prototype__stdio_fprintf_value(struct prototype *prototype, struct ty return -ENOMEM; if (type__instance_read_once(header, input) < 0) { - printed = --errno; + printed = -errno; fprintf(stderr, "pahole: --header (%s) type couldn't be read\n", conf.header_type); goto out; } @@ -2667,7 +2667,7 @@ static int prototype__stdio_fprintf_value(struct prototype *prototype, struct ty free(member_name); if (pipe_seek(input, seek_bytes) < 0) { - printed = --errno; + printed = -errno; fprintf(stderr, "Couldn't --seek_bytes %s (%" PRIu64 "\n", conf.seek_bytes, seek_bytes); goto out; } @@ -2718,7 +2718,7 @@ static int prototype__stdio_fprintf_value(struct prototype *prototype, struct ty } if (pipe_seek(input, seek_bytes) < 0) { - printed = --errno; + printed = -errno; fprintf(stderr, "Couldn't --seek_bytes %s (%" PRIu64 "\n", conf.seek_bytes, seek_bytes); goto out; } -- 2.55.0