* [PATCH] perf build-id: Fix wrong return value checking
@ 2026-04-20 18:08 Namhyung Kim
0 siblings, 0 replies; only message in thread
From: Namhyung Kim @ 2026-04-20 18:08 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Ian Rogers, Jiri Olsa, Adrian Hunter, James Clark, Peter Zijlstra,
Ingo Molnar, LKML, linux-perf-users
The {sysfs,filename}__snprintf_build_id() both return the actual length
of build-ID. But in their fprintf counterparts check with sbuild_id
length which contain a terminating NUL bytes. So they cannot match.
This resulted in perf buildid-list -k prints nothing. With this fix,
it can show the following result.
$ perf buildid-list -k
9524074000cb36cf2559a5b52f0555dab47da553
Fixes: fccaaf6fbbc59910e ("perf build-id: Change sprintf functions to snprintf")
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/builtin-buildid-list.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/perf/builtin-buildid-list.c b/tools/perf/builtin-buildid-list.c
index a91bbb34ac946360..8ad39ff9a4b8a4b4 100644
--- a/tools/perf/builtin-buildid-list.c
+++ b/tools/perf/builtin-buildid-list.c
@@ -61,7 +61,7 @@ static int sysfs__fprintf_build_id(FILE *fp)
int ret;
ret = sysfs__snprintf_build_id("/", sbuild_id, sizeof(sbuild_id));
- if (ret != sizeof(sbuild_id))
+ if (ret != sizeof(sbuild_id) - 1)
return ret < 0 ? ret : -EINVAL;
return fprintf(fp, "%s\n", sbuild_id);
@@ -73,7 +73,7 @@ static int filename__fprintf_build_id(const char *name, FILE *fp)
int ret;
ret = filename__snprintf_build_id(name, sbuild_id, sizeof(sbuild_id));
- if (ret != sizeof(sbuild_id))
+ if (ret != sizeof(sbuild_id) - 1)
return ret < 0 ? ret : -EINVAL;
return fprintf(fp, "%s\n", sbuild_id);
--
2.54.0.rc1.555.g9c883467ad-goog
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-04-20 18:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-20 18:08 [PATCH] perf build-id: Fix wrong return value checking Namhyung Kim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox