Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1581584 > unrolled thread

[PATCH 13/14] perf pmu: Fix check for unset alias->unit array

Started byArnaldo Carvalho de Melo <acme@kernel.org>
First post2017-02-15 20:10 +0100
Last post2017-02-15 20:10 +0100
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 13/14] perf pmu: Fix check for unset alias->unit array Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-02-15 20:10 +0100

#1581584 — [PATCH 13/14] perf pmu: Fix check for unset alias->unit array

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2017-02-15 20:10 +0100
Subject[PATCH 13/14] perf pmu: Fix check for unset alias->unit array
Message-ID<tbd7J-3Wc-49@gated-at.bofh.it>
From: Arnaldo Carvalho de Melo <acme@redhat.com>

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>
---
 tools/perf/util/pmu.c | 4 ++--
 1 file 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,
 	 * define unit, scale and snapshot, fail
 	 * if there's more than one.
 	 */
-	if ((info->unit && alias->unit) ||
+	if ((info->unit && alias->unit[0]) ||
 	    (info->scale && alias->scale) ||
 	    (info->snapshot && alias->snapshot))
 		return -EINVAL;
 
-	if (alias->unit)
+	if (alias->unit[0])
 		info->unit = alias->unit;
 
 	if (alias->scale)
-- 
2.9.3

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web