Skip to contentSkip to conversation

perf symbols: dso->name is an array, no need to check it against NULL

tip:perf/core tip-bot for Arnaldo Carvalho de Melo 1 participant 1 message Feb 14, 2017 perf events

lore
Share & tools
lore
#0 lore raw
Commit-ID:  5eae7d842510d33d4410c062280eda6c935403dd
Gitweb:     http://git.kernel.org/tip/5eae7d842510d33d4410c062280eda6c935403dd
Author:     Arnaldo Carvalho de Melo <[email protected]>
AuthorDate: Mon, 13 Feb 2017 17:11:03 -0300
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 13 Feb 2017 17:22:35 -0300

perf symbols: dso->name is an array, no need to check it against NULL

As it will always evaluate to 'true', as reported by clang:

util/map.c:390:36: error: address of array 'map->dso->name' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]

          if (map && map->dso && (map->dso->name || map->dso->long_name)) {
                                  ~~~~~~~~~~^~~~ ~~
  util/map.c:393:22: error: address of array 'map->dso->name' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
                  else if (map->dso->name)
                     ~~  ~~~~~~~~~~^~~~
---
 tools/perf/util/map.c                                | 4 ++--
 tools/perf/util/scripting-engines/trace-event-perl.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
tools/perf/util/map.c +2 -2
index 4f9a71c..0a943e7 100644
@@ -387,10 +387,10 @@ size_t map__fprintf_dsoname(struct map *map, FILE *fp)
 {
 	const char *dsoname = "[unknown]";
 
-	if (map && map->dso && (map->dso->name || map->dso->long_name)) {
+	if (map && map->dso) {
 		if (symbol_conf.show_kernel_path && map->dso->long_name)
 			dsoname = map->dso->long_name;
-		else if (map->dso->name)
+		else
 			dsoname = map->dso->name;
 	}
 
tools/perf/util/scripting-engines/trace-event-perl.c +2 -2
index 014ecd6..c1555fd 100644
@@ -309,10 +309,10 @@ static SV *perl_process_callchain(struct perf_sample *sample,
 		if (node->map) {
 			struct map *map = node->map;
 			const char *dsoname = "[unknown]";
-			if (map && map->dso && (map->dso->name || map->dso->long_name)) {
+			if (map && map->dso) {
 				if (symbol_conf.show_kernel_path && map->dso->long_name)
 					dsoname = map->dso->long_name;
-				else if (map->dso->name)
+				else
 					dsoname = map->dso->name;
 			}
 			if (!hv_stores(elem, "dso", newSVpv(dsoname,0))) {