perf symbols: No need to check if sym->name is NULL 83/292583/1
authorArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 13 Feb 2017 19:52:15 +0000 (16:52 -0300)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Tue, 9 May 2023 09:23:42 +0000 (18:23 +0900)
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.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
[sw0312.kim: backport upstream commit a7c3899c0686 to resolve gcc-12 build issue]
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Change-Id: I512d780fa0d3420ee4d24d61f1fcdc78c6ed73bc

tools/perf/builtin-kmem.c
tools/perf/util/machine.c
tools/perf/util/symbol_fprintf.c

index 496a4ca..25ddebc 100644 (file)
@@ -1045,7 +1045,7 @@ static void __print_page_alloc_result(struct perf_session *session, int n_lines)
 
                data = rb_entry(next, struct page_stat, node);
                sym = machine__find_kernel_function(machine, data->callsite, &map);
-               if (sym && sym->name)
+               if (sym)
                        caller = sym->name;
                else
                        scnprintf(buf, sizeof(buf), "%"PRIx64, data->callsite);
@@ -1087,7 +1087,7 @@ static void __print_page_caller_result(struct perf_session *session, int n_lines
 
                data = rb_entry(next, struct page_stat, node);
                sym = machine__find_kernel_function(machine, data->callsite, &map);
-               if (sym && sym->name)
+               if (sym)
                        caller = sym->name;
                else
                        scnprintf(buf, sizeof(buf), "%"PRIx64, data->callsite);
index 45ea7a8..6072b7d 100644 (file)
@@ -1549,7 +1549,7 @@ int machine__process_event(struct machine *machine, union perf_event *event,
 
 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 0;
 }
index a680bda..4f60ca5 100644 (file)
@@ -20,7 +20,7 @@ size_t __symbol__fprintf_symname_offs(const struct symbol *sym,
        unsigned long offset;
        size_t length;
 
-       if (sym && sym->name) {
+       if (sym) {
                length = fprintf(fp, "%s", sym->name);
                if (al) {
                        if (al->addr < sym->end)