aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2017-02-15 08:06:20 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2017-02-15 08:06:20 -0500
commitb30a7d1fc96d60fe2c02e375a56a046385701d17 (patch)
tree38cfab671653991a5c6c925d5c9946c27acab8d9 /tools/perf
parenta0b2f5af4c99d3da7ce9bc2b3b4641c8ffd22615 (diff)
perf pmu: Fix check for unset alias->unit array
The alias->unit field is an array, so to check that it is not set we should see if it is an empty string, i.e. alias->unit[0], instead of checking alias->unit != NULL, as this will _always_ evaluate to 'true'. Pointed out by clang. Acked-by: Jiri Olsa <jolsa@kernel.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/20170214182435.GD4458@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/util/pmu.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 82a654dec666..49bfee0e3d9e 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -945,12 +945,12 @@ static int check_info_data(struct perf_pmu_alias *alias,
945 * define unit, scale and snapshot, fail 945 * define unit, scale and snapshot, fail
946 * if there's more than one. 946 * if there's more than one.
947 */ 947 */
948 if ((info->unit && alias->unit) || 948 if ((info->unit && alias->unit[0]) ||
949 (info->scale && alias->scale) || 949 (info->scale && alias->scale) ||
950 (info->snapshot && alias->snapshot)) 950 (info->snapshot && alias->snapshot))
951 return -EINVAL; 951 return -EINVAL;
952 952
953 if (alias->unit) 953 if (alias->unit[0])
954 info->unit = alias->unit; 954 info->unit = alias->unit;
955 955
956 if (alias->scale) 956 if (alias->scale)