Received: by 2002:a25:d783:0:0:0:0:0 with SMTP id o125csp697412ybg; Thu, 19 Mar 2020 07:12:44 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvbO7M856YX8S5EExLqPCvniFvieSOQwoDHu7mXWQ5oTi+5meiSME9StoY0Gd7nuGn6nfIe X-Received: by 2002:a9d:4c10:: with SMTP id l16mr2384007otf.109.1584627164314; Thu, 19 Mar 2020 07:12:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584627164; cv=none; d=google.com; s=arc-20160816; b=YqZhgsslpVwe0h1G9M6QyvZt88QKoeVNZxn84Tn/PAAuccG8HqRMqcDIDf7g7ckwel 9KjBjKYji5WTFjIrY/kF4jtlWM+aDqweN/Q1OZOrTUXFicdmvYp2yPYintt/MnqpogCT DFQek9Mj04e7UOTGzRRGuDXyKFwl6YQnFV2vpfH6yNxv5dSwok5OBfj2ri5Vg28iCWYu Li/4RilfFp9ZuptL+7JIIAHnUGBthlUS3azbp9OiTeiFLHlJnQmysA/dE9G+tjNjLZ33 uixtbzrkPHjGWryQPeV1SGPWZ1fpSdZjYa56Yd8YMDEXkqHn9ZzUUpdiiXV0VVZCySpo 3W4A== 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=OofZZBY9T9tUUvKPWxEDpWnJeHKa64CnQaz53tXAIBw=; b=S+xuHib9q99B/ML3sqj5SnMgKRB9vhTCjvIPq7gJHq2Cq2EPimqWUNzyKk3X9hcu7F x1Cdv7Grxr7OM7eLSGRAm7JukZWGqaenZftPHBRyQczdYRHOTruIYkK2VrMjbhJwf+RK dL0cADDb0l82XFp1oUIjLYKLS4iAlwNG6+bN8LUGJRfsiP8awLepiKZyD3yyo0U/ZCha kqzRJYzHcFNJ/m4LoyOfRZ3qbh7WuHaf03+O/ttoYHe3BgkaVTWcgm8n9WdLWasLWUmQ dpq+u3cdS7dVJ0uJZa/pXrP+vrEu2Y0ot+yFBgIkg9lWOM4PviGUXRlmMfovA4LOaimk brhQ== 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 g144si1168343oib.40.2020.03.19.07.12.24; Thu, 19 Mar 2020 07:12:44 -0700 (PDT) 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 S1728124AbgCSOLe (ORCPT + 99 others); Thu, 19 Mar 2020 10:11:34 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:32888 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727966AbgCSOLU (ORCPT ); Thu, 19 Mar 2020 10:11:20 -0400 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 1jEvt4-0002NJ-KD; Thu, 19 Mar 2020 15:11:06 +0100 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id EA4E01C22A8; Thu, 19 Mar 2020 15:10:56 +0100 (CET) Date: Thu, 19 Mar 2020 14:10:56 -0000 From: "tip-bot2 for Nick Desaulniers" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/core] perf diff: Fix undefined string comparison 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: <158462705662.28353.6097630422293165073.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/core branch of tip: Commit-ID: c395c3553d6870541f1c283479aea2a6f26364d5 Gitweb: https://git.kernel.org/tip/c395c3553d6870541f1c283479aea2a6f26364d5 Author: Nick Desaulniers AuthorDate: Sun, 23 Feb 2020 11:34:49 -08:00 Committer: Arnaldo Carvalho de Melo CommitterDate: Wed, 04 Mar 2020 10:28:08 -03:00 perf diff: Fix undefined string comparison 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); }