From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933545AbdBPUFQ (ORCPT ); Thu, 16 Feb 2017 15:05:16 -0500 Received: from terminus.zytor.com ([65.50.211.136]:49224 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932761AbdBPUFO (ORCPT ); Thu, 16 Feb 2017 15:05:14 -0500 Date: Thu, 16 Feb 2017 12:04:57 -0800 From: tip-bot for Arnaldo Carvalho de Melo Message-ID: 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 Reply-To: wangnan0@huawei.com, tglx@linutronix.de, jolsa@kernel.org, dsahern@gmail.com, adrian.hunter@intel.com, acme@redhat.com, namhyung@kernel.org, linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@kernel.org In-Reply-To: <20170214182435.GD4458@kernel.org> References: <20170214182435.GD4458@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf pmu: Fix check for unset alias->unit array Git-Commit-ID: b30a7d1fc96d60fe2c02e375a56a046385701d17 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: b30a7d1fc96d60fe2c02e375a56a046385701d17 Gitweb: http://git.kernel.org/tip/b30a7d1fc96d60fe2c02e375a56a046385701d17 Author: Arnaldo Carvalho de Melo AuthorDate: Wed, 15 Feb 2017 10:06:20 -0300 Committer: Arnaldo Carvalho de Melo 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 Cc: Adrian Hunter Cc: David Ahern Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/r/20170214182435.GD4458@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- 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)