Skip to contentSkip to conversation

perf evsel: Reduce a variables scope

PATCH Applied Ian Rogers 2 participants 2 messages Sep 18, 2024 – Oct 1, 2024 perf events

lore
Share & tools
lore

Ian Rogers

author reviewer
#0 lore raw

PATCH 1/1 perf evsel: Reduce a variables scope

In __evsel__config_callchain avoid computing arch until code path that uses it.

---
 tools/perf/util/evsel.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/evsel.c +2 -1
index dbf9c8cee3c5..f7e829e96599 100644
@@ -862,7 +862,6 @@ static void __evsel__config_callchain(struct evsel *evsel, struct record_opts *o
 {
 	bool function = evsel__is_function_event(evsel);
 	struct perf_event_attr *attr = &evsel->core.attr;
-	const char *arch = perf_env__arch(evsel__env(evsel));
 
 	evsel__set_sample_bit(evsel, CALLCHAIN);
 
@@ -893,6 +892,8 @@ static void __evsel__config_callchain(struct evsel *evsel, struct record_opts *o
 
 	if (param->record_mode == CALLCHAIN_DWARF) {
 		if (!function) {
+			const char *arch = perf_env__arch(evsel__env(evsel));
+
 			evsel__set_sample_bit(evsel, REGS_USER);
 			evsel__set_sample_bit(evsel, STACK_USER);
 			if (opts->sample_user_regs &&
Signature · 1 line
2.46.0.662.g92d0881bb0-goog
maintainer Applied
#1 lore raw
Quoted 4 lines · Ian Rogers

In __evsel__config_callchain avoid computing arch until code path that uses it.

Applied to perf-tools-next, thanks!

Best regards,
Namhyung