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 <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-ydpm927col06paixb775jjx5@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent d6195a6a
...@@ -1065,7 +1065,7 @@ static void __print_page_alloc_result(struct perf_session *session, int n_lines) ...@@ -1065,7 +1065,7 @@ static void __print_page_alloc_result(struct perf_session *session, int n_lines)
data = rb_entry(next, struct page_stat, node); data = rb_entry(next, struct page_stat, node);
sym = machine__find_kernel_function(machine, data->callsite, &map); sym = machine__find_kernel_function(machine, data->callsite, &map);
if (sym && sym->name) if (sym)
caller = sym->name; caller = sym->name;
else else
scnprintf(buf, sizeof(buf), "%"PRIx64, data->callsite); scnprintf(buf, sizeof(buf), "%"PRIx64, data->callsite);
...@@ -1107,7 +1107,7 @@ static void __print_page_caller_result(struct perf_session *session, int n_lines ...@@ -1107,7 +1107,7 @@ static void __print_page_caller_result(struct perf_session *session, int n_lines
data = rb_entry(next, struct page_stat, node); data = rb_entry(next, struct page_stat, node);
sym = machine__find_kernel_function(machine, data->callsite, &map); sym = machine__find_kernel_function(machine, data->callsite, &map);
if (sym && sym->name) if (sym)
caller = sym->name; caller = sym->name;
else else
scnprintf(buf, sizeof(buf), "%"PRIx64, data->callsite); scnprintf(buf, sizeof(buf), "%"PRIx64, data->callsite);
......
...@@ -2067,7 +2067,7 @@ static void save_task_callchain(struct perf_sched *sched, ...@@ -2067,7 +2067,7 @@ static void save_task_callchain(struct perf_sched *sched,
break; break;
sym = node->sym; sym = node->sym;
if (sym && sym->name) { if (sym) {
if (!strcmp(sym->name, "schedule") || if (!strcmp(sym->name, "schedule") ||
!strcmp(sym->name, "__schedule") || !strcmp(sym->name, "__schedule") ||
!strcmp(sym->name, "preempt_schedule")) !strcmp(sym->name, "preempt_schedule"))
......
...@@ -168,7 +168,6 @@ int sample__fprintf_callchain(struct perf_sample *sample, int left_alignment, ...@@ -168,7 +168,6 @@ int sample__fprintf_callchain(struct perf_sample *sample, int left_alignment,
if (symbol_conf.bt_stop_list && if (symbol_conf.bt_stop_list &&
node->sym && node->sym &&
node->sym->name &&
strlist__has_entry(symbol_conf.bt_stop_list, strlist__has_entry(symbol_conf.bt_stop_list,
node->sym->name)) { node->sym->name)) {
break; break;
......
...@@ -1565,7 +1565,7 @@ int machine__process_event(struct machine *machine, union perf_event *event, ...@@ -1565,7 +1565,7 @@ int machine__process_event(struct machine *machine, union perf_event *event,
static bool symbol__match_regex(struct symbol *sym, regex_t *regex) static bool symbol__match_regex(struct symbol *sym, regex_t *regex)
{ {
if (sym->name && !regexec(regex, sym->name, 0, NULL, 0)) if (!regexec(regex, sym->name, 0, NULL, 0))
return 1; return 1;
return 0; return 0;
} }
......
...@@ -21,7 +21,7 @@ size_t __symbol__fprintf_symname_offs(const struct symbol *sym, ...@@ -21,7 +21,7 @@ size_t __symbol__fprintf_symname_offs(const struct symbol *sym,
unsigned long offset; unsigned long offset;
size_t length; size_t length;
if (sym && sym->name) { if (sym) {
length = fprintf(fp, "%s", sym->name); length = fprintf(fp, "%s", sym->name);
if (al && print_offsets) { if (al && print_offsets) {
if (al->addr < sym->end) if (al->addr < sym->end)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment