From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751941AbdBNSZJ (ORCPT ); Tue, 14 Feb 2017 13:25:09 -0500 Received: from mail.kernel.org ([198.145.29.136]:46060 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751894AbdBNSY4 (ORCPT ); Tue, 14 Feb 2017 13:24:56 -0500 Date: Tue, 14 Feb 2017 15:24:35 -0300 From: Arnaldo Carvalho de Melo To: Jiri Olsa Cc: Linux Kernel Mailing List Subject: perf pmu: clang points out: address of array 'alias->unit' will always evaluate to 'true' Message-ID: <20170214182435.GD4458@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.7.1 (2016-10-04) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org util/pmu.c:948:28: error: address of array 'alias->unit' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion] if ((info->unit && alias->unit) || ~~ ~~~~~~~^~~~ util/pmu.c:953:13: error: address of array 'alias->unit' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion] if (alias->unit) ~~ ~~~~~~~^~~~ 2 errors generated. So, is this test about having something on that alias->unit array? I.e. should this suffice? [acme@jouet linux]$ cat clang.patch 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) [acme@jouet linux]$