Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1647667ybv; Sun, 23 Feb 2020 11:36:53 -0800 (PST) X-Google-Smtp-Source: APXvYqzzhEJXLKYJuLyDg77QRFEdr89EWC31BmwSEJHnuKuUp0pwrM6hZKVpSyr/8FPGXmHaPXP0 X-Received: by 2002:aca:4a0b:: with SMTP id x11mr9849911oia.37.1582486613212; Sun, 23 Feb 2020 11:36:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582486613; cv=none; d=google.com; s=arc-20160816; b=DWXwYFcenh6HwiBypPSDN80sZMkxgScpOafMWv00HeBREkSo+1ZZpMnhOx3N+aHsTf qwg9IQBhD651bAKLFX480TRlhsRUhX//8/NhkPmi9lw5FnlZQ2kRYdLJJ3Y/+mbwrScH Ai7EMlVg7PeIqEZlMv7WV6z548yZFZzMBg54rXxZ85hazRgLs4ThOJesekzmN7Po58Z8 YNmCW0DzFmVGOOjEKQ/3iVYgHsdV1FrIip1sG/F8rEZlLb4H7BT8Ra3gtp7y5pOa+GYc W2nN3QqozjoSAqfJZ9bOddOQxH/iBYhPOuwxKPKhxl4YxFIgDKxalvT5mXodY5FAXPUr sXQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=bNSAcK1Y4RTVt5w1GiOECuJlGG3CoUMoepsQyoRrLXQ=; b=rFHgp8OusRr1X7lu1NP2OZqeuuLckufFzJAp6RcukDiM8ipl00eINoRVOM2N1/yVzM MuQ72A5ItljUxgLCjOZ83IExo60u+r+5w4lsxMKreVbK/nXkxN+6DnoYO3MTDi6FE30I esu6PIaVlAvZwE1/tDGLkd9LtRkWIJfvhTfaPsLZ/TeYG4FdwXEYjdRRjNG+mISqscol 8B1KFUezINXPDeGj64i6Kte7giYiCkKo0HOk1xA5RnYec8uVu+qSPA+x22tVapqNRiS1 4r9Ri8oIYwUPCvugdg+4UffSmx8vF8swJ7CJTUaWIzxbGdXQ1nvHnWn1Xuk2aqcLTBgf QnpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pbVUvKR8; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r22si4812566otn.192.2020.02.23.11.36.40; Sun, 23 Feb 2020 11:36:53 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pbVUvKR8; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727033AbgBWTfC (ORCPT + 99 others); Sun, 23 Feb 2020 14:35:02 -0500 Received: from mail-ot1-f65.google.com ([209.85.210.65]:43058 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726208AbgBWTfC (ORCPT ); Sun, 23 Feb 2020 14:35:02 -0500 Received: by mail-ot1-f65.google.com with SMTP id p8so6789248oth.10 for ; Sun, 23 Feb 2020 11:35:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=bNSAcK1Y4RTVt5w1GiOECuJlGG3CoUMoepsQyoRrLXQ=; b=pbVUvKR8TfpAgiImQ5OxGoZyTyiButMVamczWW9Xa6o/33wn2VOI80C4DdCnrOP/XB SHr41FumC4LcT8zxtFsp8n/KQll0LHzwB5sSdg9edEbSHBz3N3HdH92bMbqvDhECu/P4 4taH/UyAEyt0pM4r/jaPO3OlrHAhI8ND9vY6QjWJh5lcX9+xbZi9j1eWvD2IiMvpeNAu SQq4/QYPCnInx4JOsoNHBDSr1har8cB/Qbjvgpsvdi+zAQWcAdSX+KrVvMMcLP8mpnbb eY+rO0deuvE/8YCaOJt/7X7f8nIOWYJx/RJbJMEONkEl/N1ph6LtCzrMIXr6/a4A9Znn JzOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=bNSAcK1Y4RTVt5w1GiOECuJlGG3CoUMoepsQyoRrLXQ=; b=ASIZZiumaDOIhwmrVi6+KW/FLpWOdor6Q2aOei0/XztcEq6Ku11jJTnJBQ1zsGG976 FhijOuZReyDjjWL5vTyjAYFI3sU/fpk4VlFmkVNytn8oTMP8pRoO8OHvtFUcU5FRwA8b q+6WFx2TAMbaClvRTKezbDe28eqvXV9gakSm4/RMSKKirSW1QLpvCxlN3B1YwSj52WVm bD3VuN1eouDPJyyxYD+89W3dNt65Sjzt7rPNPSX6g9Qt1IgFDLNOuOJ6jj20pqNyay+9 ULyVi1wgqYFKbQ/VTraDRk/S2VV1k7SeNafh52bYfSHrfarSP9ZfXzHx/vRSPxX6yNlz S33A== X-Gm-Message-State: APjAAAVm+aj55TBDdeBSl6Sm6opiVbIH++VfPUJ3+i4tLSMDXeJI1nBc ZPp8uN+N0tXkohO0/NI/Y8s= X-Received: by 2002:a05:6830:15a:: with SMTP id j26mr35920326otp.137.1582486501481; Sun, 23 Feb 2020 11:35:01 -0800 (PST) Received: from nick-Blade-Stealth.attlocal.net (23-121-157-107.lightspeed.sntcca.sbcglobal.net. [23.121.157.107]) by smtp.googlemail.com with ESMTPSA id j13sm3267880oij.56.2020.02.23.11.34.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Feb 2020 11:35:00 -0800 (PST) From: Nick Desaulniers To: acme@kernel.org, mingo@redhat.com, peterz@infradead.org Cc: clang-built-linux@googlegroups.com, Nick Desaulniers , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Jin Yao , Changbin Du , John Keeping , Song Liu , linux-kernel@vger.kernel.org Subject: [PATCH] perf: fix -Wstring-compare Date: Sun, 23 Feb 2020 11:34:49 -0800 Message-Id: <20200223193456.25291-1-nick.desaulniers@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) ^ ~~~~~~~~~~~~~~~ Link: https://github.com/ClangBuiltLinux/linux/issues/900 Signed-off-by: Nick Desaulniers --- Note: was generated off of mainline; can rebase on -next if it doesn't apply cleanly. 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 f8b6ae557d8b..c03c36fde7e2 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 c4b030bf6ec2..fbbb6d640dad 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 a08ca276098e..95428511300d 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); } -- 2.17.1