perf tools: Remove redundant ret variable
PATCH 1/2 perf tools: Remove redundant ret variable
Return value from hist_entry_iter__add() directly instead of taking this in another redundant variable.
--- tools/perf/builtin-annotate.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
tools/perf/builtin-annotate.c +1 -3
@@ -190,7 +190,6 @@ static int process_branch_callback(struct evsel *evsel, };struct addr_location a; -int ret;if (machine__resolve (machine, &a, sample) <0 )return -1 ;
@@ -203,8 +202,7 @@ static int process_branch_callback(struct evsel *evsel,hist__account_cycles (sample->branch_stack, al, sample, false,NULL ); - ret =hist_entry_iter__add (&iter, &a,PERF_MAX_STACK_DEPTH , ann); -return ret; +return hist_entry_iter__add (&iter, &a,PERF_MAX_STACK_DEPTH , ann); }static bool has_annotation (struct perf_annotate *ann)
Signature · 1 line
2.20.1
PATCH 2/2 perf tools: Remove redundant err variable
The variable err in the perf_event__process_sample is only used in the only one judgment statement, it is not used in other places.
So, use the return value from hist_entry_iter__add() directly instead of taking this in another redundant variable.
--- tools/perf/builtin-top.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
tools/perf/builtin-top.c +1 -3
@@ -746,7 +746,6 @@ static void perf_event__process_sample(struct perf_tool *tool, { struct perf_top *top = container_of(tool, struct perf_top, tool);struct addr_location al; -int err;if (!machine && perf_guest) {static struct intlist *seen;
@@ -839,8 +838,7 @@ static void perf_event__process_sample(struct perf_tool *tool,pthread_mutex_lock (&hists->lock); - err =hist_entry_iter__add (&iter, &al, top->max_stack, top); -if (err <0 ) +if (hist_entry_iter__add (&iter, &al, top->max_stack, top) <0 )pr_err ("Problem incrementing symbol period, skipping event\n" );pthread_mutex_unlock (&hists->lock);
Signature · 1 line
2.20.1
Re: [PATCH 2/2] perf tools: Remove redundant err variable
Em Wed, Feb 16, 2022 at 11:04:25AM +0800, tangmeng escreveu:
Quoted 5 lines
The variable err in the
perf_event__process_sampleis only used in the only one judgment statement, it is not used in other places.So, use the return value from
hist_entry_iter__add()directly instead of taking this in another redundant variable.
Thanks, applied.
- Arnaldo
Quoted 31 lines
Signed-off-by tangmeng <[email protected]>--- tools/perf/builtin-top.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)tools/perf/builtin-top.c +1
-3@@ -746,7 +746,6 @@ static void perf_event__process_sample(struct perf_tool *tool, { struct perf_top *top = container_of(tool, struct perf_top, tool);struct addr_location al; -int err;if (!machine && perf_guest) {static struct intlist *seen;@@ -839,8 +838,7 @@ static void perf_event__process_sample(struct perf_tool *tool,pthread_mutex_lock (&hists->lock); - err =hist_entry_iter__add (&iter, &al, top->max_stack, top); -if (err <0 ) +if (hist_entry_iter__add (&iter, &al, top->max_stack, top) <0 )pr_err ("Problem incrementing symbol period, skipping event\n" );pthread_mutex_unlock (&hists->lock);Signature · 1 line
2.20.1
Signature · 1 line
- Arnaldo
Em Wed, Feb 16, 2022 at 11:04:24AM +0800, tangmeng escreveu:
Quoted 2 lines
Return value from
hist_entry_iter__add()directly instead of taking this in another redundant variable.
Thanks, applied.
- Arnaldo
Quoted 31 lines
Signed-off-by tangmeng <[email protected]>--- tools/perf/builtin-annotate.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)tools/perf/builtin-annotate.c +1
-3@@ -190,7 +190,6 @@ static int process_branch_callback(struct evsel *evsel, };struct addr_location a; -int ret;if (machine__resolve (machine, &a, sample) <0 )return -1 ;@@ -203,8 +202,7 @@ static int process_branch_callback(struct evsel *evsel,hist__account_cycles (sample->branch_stack, al, sample, false,NULL ); - ret =hist_entry_iter__add (&iter, &a,PERF_MAX_STACK_DEPTH , ann); -return ret; +return hist_entry_iter__add (&iter, &a,PERF_MAX_STACK_DEPTH , ann); }static bool has_annotation (struct perf_annotate *ann)Signature · 1 line
2.20.1
Signature · 1 line
- Arnaldo