linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: tip-bot for Arnaldo Carvalho de Melo <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: jolsa@kernel.org, tglx@linutronix.de, wangnan0@huawei.com,
	hpa@zytor.com, mingo@kernel.org, linux-kernel@vger.kernel.org,
	namhyung@kernel.org, acme@redhat.com, dsahern@gmail.com,
	adrian.hunter@intel.com
Subject: [tip:perf/core] perf pmu: Fix check for unset alias->unit array
Date: Thu, 16 Feb 2017 12:04:57 -0800	[thread overview]
Message-ID: <tip-b30a7d1fc96d60fe2c02e375a56a046385701d17@git.kernel.org> (raw)
In-Reply-To: <20170214182435.GD4458@kernel.org>

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)

      parent reply	other threads:[~2017-02-16 20:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-14 18:24 perf pmu: clang points out: address of array 'alias->unit' will always evaluate to 'true' Arnaldo Carvalho de Melo
2017-02-15 10:50 ` Jiri Olsa
2017-02-15 12:41   ` perf bison: clang points out: error: conflicting types for 'parse_events_error' " Arnaldo Carvalho de Melo
2017-02-15 12:52     ` Jiri Olsa
2017-02-15 13:06       ` perf build with clang, modulo libpython: " Arnaldo Carvalho de Melo
2017-02-15 13:21         ` Jiri Olsa
2017-02-16 20:05         ` [tip:perf/core] perf tools: Add missing parse_events_error() prototype tip-bot for Arnaldo Carvalho de Melo
2017-02-16 20:04 ` tip-bot for Arnaldo Carvalho de Melo [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tip-b30a7d1fc96d60fe2c02e375a56a046385701d17@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=dsahern@gmail.com \
    --cc=hpa@zytor.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=wangnan0@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).