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


Groups > linux.kernel > #1582906

[tip:perf/core] perf pmu: Fix check for unset alias->unit array

From tip-bot for Arnaldo Carvalho de Melo <tipbot@zytor.com>
Newsgroups linux.kernel
Subject [tip:perf/core] perf pmu: Fix check for unset alias->unit array
Date 2017-02-16 21:10 +0100
Message-ID <tbAxj-2RL-11@gated-at.bofh.it> (permalink)
References <taQ1r-5hv-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Commit-ID:  b30a7d1fc96d60fe2c02e375a56a046385701d17
Gitweb:     http://git.kernel.org/tip/b30a7d1fc96d60fe2c02e375a56a046385701d17
Author:     Arnaldo Carvalho de Melo <acme@redhat.com>
AuthorDate: Wed, 15 Feb 2017 10:06:20 -0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 15 Feb 2017 10:06:20 -0300

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>
---
 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 82a654de..49bfee0 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)

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

perf pmu: clang points out: address of array 'alias->unit' will  always evaluate to 'true' Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-02-14 19:30 +0100
  Re: perf pmu: clang points out: address of array 'alias->unit' will  always evaluate to 'true' Jiri Olsa <jolsa@redhat.com> - 2017-02-15 12:00 +0100
    perf bison: clang points out: error: conflicting types for  'parse_events_error' always evaluate to 'true' Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-02-15 13:50 +0100
      Re: perf bison: clang points out: error: conflicting types for  'parse_events_error' always evaluate to 'true' Jiri Olsa <jolsa@redhat.com> - 2017-02-15 14:00 +0100
        perf build with clang, modulo libpython: Re: perf bison: clang  points out: error: conflicting types for 'parse_events_error' always  evaluate to 'true' Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-02-15 14:10 +0100
          Re: perf build with clang, modulo libpython: Re: perf bison: clang  points out: error: conflicting types for 'parse_events_error' always  evaluate to 'true' Jiri Olsa <jolsa@redhat.com> - 2017-02-15 14:30 +0100
          [tip:perf/core] perf tools: Add missing parse_events_error()  prototype tip-bot for Arnaldo Carvalho de Melo <tipbot@zytor.com> - 2017-02-16 21:10 +0100
  [tip:perf/core] perf pmu: Fix check for unset alias->unit array tip-bot for Arnaldo Carvalho de Melo <tipbot@zytor.com> - 2017-02-16 21:10 +0100

csiph-web