perf auxtrace: Avoid redundant NULL check in auxtrace_mmap_params__set_idx()
PATCH 1/1 perf auxtrace: Avoid redundant NULL check in auxtrace_mmap_params__set_idx()
Since commit eead8a011477 ("libperf threadmap: Don't segv for index 0 for the NULL 'struct perf_thread_map' pointer"), perf_thread_map__pid() can check for a NULL map and return -1 if idx is 0. Cleanup auxtrace_mmap_params__set_idx() and remove the redundant NULL check.
No functional change intended.
--- tools/perf/util/auxtrace.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
tools/perf/util/auxtrace.c +1 -4
@@ -185,10 +185,7 @@ void auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp,if (per_cpu) { mp->cpu =perf_cpu_map__cpu (evlist->core.all_cpus, idx); -if (evlist->core.threads) - mp->tid =perf_thread_map__pid (evlist->core.threads,0 ); -else - mp->tid =-1 ; + mp->tid =perf_thread_map__pid (evlist->core.threads,0 ); }else { mp->cpu.cpu =-1 ; mp->tid =perf_thread_map__pid (evlist->core.threads, idx);
Signature · 1 line
2.49.0
Quoted 8 lines · Gautam Menghani
Since commit
eead8a011477("libperf threadmap: Don't segv for index 0 for the NULL 'structperf_thread_map' pointer"),perf_thread_map__pid()can check for a NULL map and return -1 if idx is 0. Cleanupauxtrace_mmap_params__set_idx()and remove the redundant NULL check.No functional change intended.
Signed-off-by Gautam Menghani <[email protected]>
Quoted 20 lines
--- tools/perf/util/auxtrace.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)tools/perf/util/auxtrace.c +1
-4@@ -185,10 +185,7 @@ void auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp,if (per_cpu) { mp->cpu =perf_cpu_map__cpu (evlist->core.all_cpus, idx); -if (evlist->core.threads) - mp->tid =perf_thread_map__pid (evlist->core.threads,0 ); -else - mp->tid =-1 ; + mp->tid =perf_thread_map__pid (evlist->core.threads,0 ); }else { mp->cpu.cpu =-1 ; mp->tid =perf_thread_map__pid (evlist->core.threads, idx);
Quoted 11 lines · Adrian Hunter
Quoted 8 lines · Gautam Menghani
Since commit
eead8a011477("libperf threadmap: Don't segv for index 0 for the NULL 'structperf_thread_map' pointer"),perf_thread_map__pid()can check for a NULL map and return -1 if idx is 0. Cleanupauxtrace_mmap_params__set_idx()and remove the redundant NULL check.No functional change intended.
Signed-off-by Gautam Menghani <[email protected]>Reviewed-by Adrian Hunter <[email protected]>
Thanks, applied to perf-tools-next,
- Arnaldo
Quoted 20 lines
Quoted 20 lines
--- tools/perf/util/auxtrace.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)tools/perf/util/auxtrace.c +1
-4@@ -185,10 +185,7 @@ void auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp,if (per_cpu) { mp->cpu =perf_cpu_map__cpu (evlist->core.all_cpus, idx); -if (evlist->core.threads) - mp->tid =perf_thread_map__pid (evlist->core.threads,0 ); -else - mp->tid =-1 ; + mp->tid =perf_thread_map__pid (evlist->core.threads,0 ); }else { mp->cpu.cpu =-1 ; mp->tid =perf_thread_map__pid (evlist->core.threads, idx);
Quoted 8 lines · Gautam Menghani
Since commit
eead8a011477("libperf threadmap: Don't segv for index 0 for the NULL 'structperf_thread_map' pointer"),perf_thread_map__pid()can check for a NULL map and return -1 if idx is 0. Cleanupauxtrace_mmap_params__set_idx()and remove the redundant NULL check.No functional change intended.
Signed-off-by Gautam Menghani <[email protected]>
LGTM.
Regards,
Amit
Quoted 23 lines
--- tools/perf/util/auxtrace.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)tools/perf/util/auxtrace.c +1
-4@@ -185,10 +185,7 @@ void auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp,if (per_cpu) { mp->cpu =perf_cpu_map__cpu (evlist->core.all_cpus, idx); -if (evlist->core.threads) - mp->tid =perf_thread_map__pid (evlist->core.threads,0 ); -else - mp->tid =-1 ; + mp->tid =perf_thread_map__pid (evlist->core.threads,0 ); }else { mp->cpu.cpu =-1 ; mp->tid =perf_thread_map__pid (evlist->core.threads, idx);Signature · 1 line
2.49.0
Quoted 18 lines · Gautam Menghani
Since commit
eead8a011477("libperf threadmap: Don't segv for index 0 for the NULL 'structperf_thread_map' pointer"),perf_thread_map__pid()can check for a NULL map and return -1 if idx is 0. Cleanupauxtrace_mmap_params__set_idx()and remove the redundant NULL check.No functional change intended.
Signed-off-by Gautam Menghani <[email protected]>--- tools/perf/util/auxtrace.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)tools/perf/util/auxtrace.c +0
-0@@ -185,10 +185,7 @@ void auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp,
tools/perf/util/auxtrace.c void auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp, · line 191
Quoted 10 lines
tools/perf/util/auxtrace.c +1
-4if (per_cpu) { mp->cpu =perf_cpu_map__cpu (evlist->core.all_cpus, idx); -if (evlist->core.threads) - mp->tid =perf_thread_map__pid (evlist->core.threads,0 ); -else - mp->tid =-1 ; + mp->tid =perf_thread_map__pid (evlist->core.threads,0 ); }else { mp->cpu.cpu =-1 ; mp->tid =perf_thread_map__pid (evlist->core.threads, idx);
LGTM.