Skip to content

Commit a7c3899

Browse files
committed
perf symbols: No need to check if sym->name is NULL
As it is an array, so will always evaluate to 'true', as reported by clang: builtin-sched.c:2070:19: error: address of array 'sym->name' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion] if (sym && sym->name) { ~~ ~~~~~^~~~ 1 warning generated. So just ditch all those useless checks. Cc: Adrian Hunter <[email protected]> Cc: David Ahern <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Wang Nan <[email protected]> Link: http://lkml.kernel.org/n/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent d6195a6 commit a7c3899

File tree

5 files changed

+5
-6
lines changed

5 files changed

+5
-6
lines changed

tools/perf/builtin-kmem.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,7 @@ static void __print_page_alloc_result(struct perf_session *session, int n_lines)
10651065

10661066
data = rb_entry(next, struct page_stat, node);
10671067
sym = machine__find_kernel_function(machine, data->callsite, &map);
1068-
if (sym && sym->name)
1068+
if (sym)
10691069
caller = sym->name;
10701070
else
10711071
scnprintf(buf, sizeof(buf), "%"PRIx64, data->callsite);
@@ -1107,7 +1107,7 @@ static void __print_page_caller_result(struct perf_session *session, int n_lines
11071107

11081108
data = rb_entry(next, struct page_stat, node);
11091109
sym = machine__find_kernel_function(machine, data->callsite, &map);
1110-
if (sym && sym->name)
1110+
if (sym)
11111111
caller = sym->name;
11121112
else
11131113
scnprintf(buf, sizeof(buf), "%"PRIx64, data->callsite);

tools/perf/builtin-sched.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2067,7 +2067,7 @@ static void save_task_callchain(struct perf_sched *sched,
20672067
break;
20682068

20692069
sym = node->sym;
2070-
if (sym && sym->name) {
2070+
if (sym) {
20712071
if (!strcmp(sym->name, "schedule") ||
20722072
!strcmp(sym->name, "__schedule") ||
20732073
!strcmp(sym->name, "preempt_schedule"))

tools/perf/util/evsel_fprintf.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ int sample__fprintf_callchain(struct perf_sample *sample, int left_alignment,
168168

169169
if (symbol_conf.bt_stop_list &&
170170
node->sym &&
171-
node->sym->name &&
172171
strlist__has_entry(symbol_conf.bt_stop_list,
173172
node->sym->name)) {
174173
break;

tools/perf/util/machine.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1565,7 +1565,7 @@ int machine__process_event(struct machine *machine, union perf_event *event,
15651565

15661566
static bool symbol__match_regex(struct symbol *sym, regex_t *regex)
15671567
{
1568-
if (sym->name && !regexec(regex, sym->name, 0, NULL, 0))
1568+
if (!regexec(regex, sym->name, 0, NULL, 0))
15691569
return 1;
15701570
return 0;
15711571
}

tools/perf/util/symbol_fprintf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ size_t __symbol__fprintf_symname_offs(const struct symbol *sym,
2121
unsigned long offset;
2222
size_t length;
2323

24-
if (sym && sym->name) {
24+
if (sym) {
2525
length = fprintf(fp, "%s", sym->name);
2626
if (al && print_offsets) {
2727
if (al->addr < sym->end)

0 commit comments

Comments
 (0)