All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf annotate: Return an error for --gtk with --show-nr-samples
@ 2026-12-03  2:23 ` Weidong Wang
  0 siblings, 0 replies; 3+ messages in thread
From: Weidong Wang via B4 Relay @ 2026-12-03  2:23 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Namhyung Kim
  Cc: Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Ian Rogers, Adrian Hunter, James Clark,
	linux-perf-users, linux-kernel, Weidong Wang

From: Weidong Wang <weidongw@illinois.edu>

cmd_annotate() rejects --show-nr-samples in --gtk mode by printing an
error and returning ret. At that point ret holds the successful result
of hists__init() and is not updated again, so it is 0 and perf annotate
exits with status 0 without doing anything.

Return -EINVAL instead, as the other option checks in the function do,
so the failure is visible to callers.

Found by a static analysis tool.

The fix and this changelog were drafted with AI assistance (Claude Code,
with a second review by OpenAI Codex), then reviewed by the submitter.

Fixes: 1ac39372e06f ("perf annotate stdio: Support --show-nr-samples option")
Signed-off-by: Weidong Wang <weidongw@illinois.edu>
---
Tested on x86_64 with perf built with GTK4=1, before and after this
patch: "perf annotate --gtk --show-nr-samples" prints the error and
exits with status 0 before, and with status 234 (-EINVAL) after.

Testing:
- checkpatch.pl --strict: no errors or warnings.
---
 tools/perf/builtin-annotate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 65846110c309..f3041479a528 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -839,7 +839,7 @@ int cmd_annotate(int argc, const char **argv)
 #ifdef HAVE_GTK4_SUPPORT
 	if (symbol_conf.show_nr_samples && annotate.use_gtk) {
 		pr_err("--show-nr-samples is not available in --gtk mode at this time\n");
-		return ret;
+		return -EINVAL;
 	}
 #endif
 

---
base-commit: 316fdb2d4ed172316923794f91dc9cd2b44bebfd
change-id: 20261202-kbug-l1942-6437c34d9282

Best regards,
--  
Weidong Wang <weidongw@illinois.edu>



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-12-03  2:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03  2:23 [PATCH] perf annotate: Return an error for --gtk with --show-nr-samples Weidong Wang via B4 Relay
2026-12-03  2:23 ` Weidong Wang
2026-12-03  2:26 ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.