Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp349826ybh; Fri, 6 Mar 2020 23:38:15 -0800 (PST) X-Google-Smtp-Source: ADFU+vua2OuDdCO9p92AZwJ9l1gYkNuTQQA0HNmx3uvdK6gS0pznsuqyxbOyHVeViQY+IxSSeATG X-Received: by 2002:a05:6830:309b:: with SMTP id f27mr5542162ots.69.1583566695318; Fri, 06 Mar 2020 23:38:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583566695; cv=none; d=google.com; s=arc-20160816; b=JpjGZCEpGYpLAoFhJ9J2li0ywxoCF+Rg3CNtbglUHnDCp5AjA2aqS1X4FR+RhpVQob spExq3GXpH0hq/81I+yoY8sfMdaGVMOXzJnHSNNs9+GhcfVIYmV95GOedsJFOeAp4w8j HBswvahCI0eFVWnTSq4ln/325lQkqXzT64dhRotLBRkjNCeH2FX6KiuJrr1vpAXjboOG SN3mcrdDLgfJIFLzQQTW+ZKgXedwXO2Ry+AHHQLQyQiX+6jG+ay1lutdeEwwWBslf9h2 6uojB7li0d19u7VARo+DqGFNPqNrthyWHeNs+H4ea1BOqN1pPJyEZD3tLZxPPyiF3LfY tyJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=6dThfqDyIQ3JqEi/S7CGAGBjBEn288UItH6fO0rTw80=; b=egLElA/SV/4ZmTeqpKfJ7b+zvU+ITJF8RG+y12x1NQX5+Ss153rND732jvTUBQlue2 mXs8ID6XDR/KWLbaGhzXUp3kMuhftoJovnncolQ/+peCbp9UdUcegSe2FjuNPMKurAUJ 0ng7x4bCfTkuZvFxwJI7CM4foVnSwvT7QRzFGTrGH0XzndXKq02/pwqFOTIPAVqQFAwt q+RSLVv5/zJfqHclKQyfZKGPq5UJPPL5QDBcZ3rGlCgiuqOMCBhbhoT5nQL3toi+4Wqc PnChCRJgHKsNtuamEdebdqexmdIO8Up6h14IV41887AF/JPG45OWKy3f2SmCUKaQY8LY jpKw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v15si3017598oth.307.2020.03.06.23.38.03; Fri, 06 Mar 2020 23:38:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726340AbgCGHhP (ORCPT + 99 others); Sat, 7 Mar 2020 02:37:15 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:55247 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726086AbgCGHhI (ORCPT ); Sat, 7 Mar 2020 02:37:08 -0500 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jAU0v-0004Hm-8L; Sat, 07 Mar 2020 08:36:49 +0100 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id E35DC1C21A5; Sat, 7 Mar 2020 08:36:48 +0100 (CET) Date: Sat, 07 Mar 2020 07:36:48 -0000 From: "tip-bot2 for Nick Desaulniers" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/urgent] perf diff: Fix undefined string comparision spotted by clang's -Wstring-compare Cc: Nick Desaulniers , Ian Rogers , Alexander Shishkin , Changbin Du , Jin Yao , Jiri Olsa , John Keeping , Mark Rutland , Namhyung Kim , Peter Zijlstra , Song Liu , clang-built-linux@googlegroups.com, Arnaldo Carvalho de Melo , x86 , LKML In-Reply-To: <20200223193456.25291-1-nick.desaulniers@gmail.com> References: <20200223193456.25291-1-nick.desaulniers@gmail.com> MIME-Version: 1.0 Message-ID: <158356660863.28353.13163883291738121062.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the perf/urgent branch of tip: Commit-ID: cfd3bc752a3f5529506d279deb42e3bc8055695b Gitweb: https://git.kernel.org/tip/cfd3bc752a3f5529506d279deb42e3bc8055695b Author: Nick Desaulniers AuthorDate: Sun, 23 Feb 2020 11:34:49 -08:00 Committer: Arnaldo Carvalho de Melo CommitterDate: Fri, 06 Mar 2020 08:30:29 -03:00 perf diff: Fix undefined string comparision spotted by clang's -Wstring-compare clang warns: util/block-info.c:298:18: error: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Werror,-Wstring-compare] if ((start_line != SRCLINE_UNKNOWN) && (end_line != SRCLINE_UNKNOWN)) { ^ ~~~~~~~~~~~~~~~ util/block-info.c:298:51: error: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Werror,-Wstring-compare] if ((start_line != SRCLINE_UNKNOWN) && (end_line != SRCLINE_UNKNOWN)) { ^ ~~~~~~~~~~~~~~~ util/block-info.c:298:18: error: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Werror,-Wstring-compare] if ((start_line != SRCLINE_UNKNOWN) && (end_line != SRCLINE_UNKNOWN)) { ^ ~~~~~~~~~~~~~~~ util/block-info.c:298:51: error: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Werror,-Wstring-compare] if ((start_line != SRCLINE_UNKNOWN) && (end_line != SRCLINE_UNKNOWN)) { ^ ~~~~~~~~~~~~~~~ util/map.c:434:15: error: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Werror,-Wstring-compare] if (srcline != SRCLINE_UNKNOWN) ^ ~~~~~~~~~~~~~~~ Reviewer Notes: Looks good to me. Some more context: https://clang.llvm.org/docs/DiagnosticsReference.html#wstring-compare The spec says: J.1 Unspecified behavior The following are unspecified: .. Whether two string literals result in distinct arrays (6.4.5). Signed-off-by: Nick Desaulniers Reviewed-by: Ian Rogers Cc: Alexander Shishkin Cc: Changbin Du Cc: Jin Yao Cc: Jiri Olsa Cc: John Keeping Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Song Liu Cc: clang-built-linux@googlegroups.com Link: https://github.com/ClangBuiltLinux/linux/issues/900 Link: http://lore.kernel.org/lkml/20200223193456.25291-1-nick.desaulniers@gmail.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-diff.c | 3 ++- tools/perf/util/block-info.c | 3 ++- tools/perf/util/map.c | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index f8b6ae5..c03c36f 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c @@ -1312,7 +1312,8 @@ static int cycles_printf(struct hist_entry *he, struct hist_entry *pair, end_line = map__srcline(he->ms.map, bi->sym->start + bi->end, he->ms.sym); - if ((start_line != SRCLINE_UNKNOWN) && (end_line != SRCLINE_UNKNOWN)) { + if ((strncmp(start_line, SRCLINE_UNKNOWN, strlen(SRCLINE_UNKNOWN)) != 0) && + (strncmp(end_line, SRCLINE_UNKNOWN, strlen(SRCLINE_UNKNOWN)) != 0)) { scnprintf(buf, sizeof(buf), "[%s -> %s] %4ld", start_line, end_line, block_he->diff.cycles); } else { diff --git a/tools/perf/util/block-info.c b/tools/perf/util/block-info.c index c4b030b..fbbb6d6 100644 --- a/tools/perf/util/block-info.c +++ b/tools/perf/util/block-info.c @@ -295,7 +295,8 @@ static int block_range_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, end_line = map__srcline(he->ms.map, bi->sym->start + bi->end, he->ms.sym); - if ((start_line != SRCLINE_UNKNOWN) && (end_line != SRCLINE_UNKNOWN)) { + if ((strncmp(start_line, SRCLINE_UNKNOWN, strlen(SRCLINE_UNKNOWN)) != 0) && + (strncmp(end_line, SRCLINE_UNKNOWN, strlen(SRCLINE_UNKNOWN)) != 0)) { scnprintf(buf, sizeof(buf), "[%s -> %s]", start_line, end_line); } else { diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index a08ca27..9542851 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c @@ -431,7 +431,7 @@ int map__fprintf_srcline(struct map *map, u64 addr, const char *prefix, if (map && map->dso) { char *srcline = map__srcline(map, addr, NULL); - if (srcline != SRCLINE_UNKNOWN) + if (strncmp(srcline, SRCLINE_UNKNOWN, strlen(SRCLINE_UNKNOWN)) != 0) ret = fprintf(fp, "%s%s", prefix, srcline); free_srcline(srcline); }