Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2723618ybv; Mon, 24 Feb 2020 10:20:09 -0800 (PST) X-Google-Smtp-Source: APXvYqz3uFezJYn7vUYrv1rQTaHiMEsAjPj6EZmrKPXzCCjM+kkU0vqTwWRiUrVmwg1Bq6dQNBLk X-Received: by 2002:aca:4183:: with SMTP id o125mr263328oia.125.1582568408944; Mon, 24 Feb 2020 10:20:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582568408; cv=none; d=google.com; s=arc-20160816; b=AsJEFoWuvubBVnFFBHckAMR631tHWzIOW6h+RcYqiKF85vFWviSc19nmwd4y1pO7W1 m/kL9AHuo7/SrC3O8XkF+hR8Znzr8jW2LBjEVFT9kvX9+Rm+fAtKJ/4jiVd/uaTCGi5A BJyfZ/+QG7yt9LqoW99DUGclyVfE8lS2sgD2fSHiJa9nEweauV6uimHRALcCo+yEtw/y fA43ZBadqUI1KwQoRtx8OUQAraJqzAn+BLSIih3Mc55e7bcRDC0YMzMnG4ndi1GAKHCS L1ySxfPxrarY3kpAi+X/EHBcQlskZu5BJF1A6OD0owbwIB+5m4DRtuJ07ckHbQ67F9Qh mMSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=mwMd85HDX5SvxneOefTVO3Pm2UjSWW7Q8lu4YFXwuVc=; b=S1EZAmKoKeL2v3KOgQZB23U4g1wAzGQdh93XAk88kpswyW0xuiMsgDijvGlcL7a+nJ g/I7oHIIke0XuvjfbuCG2f72SMvjmN1GSckILdRXkrtUWxk7ordZhx0/eq814awrQc/1 Uo5fRX7aUTpyBmyBrOEOtt52IXL87jG31ni5/tNo3RNrqb4Z9vbJhG77CqkMg4P6G0J4 0NHdzMdZRC6KsekdsTz0cGuTTRjQ1uwRBStIBHmXZPSWt1RaHZzKIHNVC7GeLHUYptWA A6OgFiN+/28Pr6BPSkgF858s9g/PEMoXZ0aTT+84BwwME5QNWeqWU44RlQ/tuUHe1DbN /9GA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=T4WRCbzK; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b126si5203736oii.72.2020.02.24.10.19.56; Mon, 24 Feb 2020 10:20:08 -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=@google.com header.s=20161025 header.b=T4WRCbzK; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727730AbgBXSTr (ORCPT + 99 others); Mon, 24 Feb 2020 13:19:47 -0500 Received: from mail-yw1-f68.google.com ([209.85.161.68]:46882 "EHLO mail-yw1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726208AbgBXSTr (ORCPT ); Mon, 24 Feb 2020 13:19:47 -0500 Received: by mail-yw1-f68.google.com with SMTP id z141so5621757ywd.13 for ; Mon, 24 Feb 2020 10:19:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=mwMd85HDX5SvxneOefTVO3Pm2UjSWW7Q8lu4YFXwuVc=; b=T4WRCbzKak+JI+nr9i6w3iixDwOSrddin5REOzOyfPUPMbKcpYL6CYlC0TdwNEMMwN ldeHn1GZRtkqpWkq1Q51tt2S0xBE6yA0tKuHPYj9MsU+SJb2O+SYGytAzGstWBp18rRZ Bg7cXTVAVmoCrPUH10MhhgEd416+GPaXMr1fxGFekDJMwdLtmtjHF+AIb7STeNWCTCQ0 zuy+iUAKoIm8xQJGLl2afhoWfH6zHiD40F5SuOKBdBPkfyHZQdg0kzd9mvPO4rE8mf1a 1OaX5bV4dTLpDDtbC7c5kbrz4QzaWC8lQQWJOZLDVYQHW/JZc5Ft+gsQqlIxYPyY+pl5 WGEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mwMd85HDX5SvxneOefTVO3Pm2UjSWW7Q8lu4YFXwuVc=; b=a0N3vhBv9n40JKMmBxtMdZwx/Vv9AlAekwdWUWKaWQz46d2I1WfA6275dgjbe5tOFx LJFNT++KWhBTtK1zaTpT83hKFAAENBLtmpbRI28UvnYyQCMu+wWtB3PUhyKDZ+5NaWkV 7Do/+PI/SSIXddSNeM2d09vCk20e7IFFdsji11pF3UzzWnh6p/PWJ41uuWwHDQWqpMX/ xWStgX6YyxRAIGg7tusHEkHo8m2XWKLGnj3o38sZF94dBvVFOEu+8xetuYjY4zYmEoBQ xeQdRPUaHPy6doh8JHJ2jSlaV2XAvM3Bl35iHa53Qbjs+QWYnoK2Fe3vS5r10uEQx6X7 l2SQ== X-Gm-Message-State: APjAAAX4yDdNW8MErctB4a7pWHpLFQJZVP75iRqk6Kyp+m6fnUeqAXHq 1FdCFbbByP+oV3PrDTvuS0qK1mpfMzgcI8C8x1EGMg== X-Received: by 2002:a81:a452:: with SMTP id b79mr41515761ywh.389.1582568384978; Mon, 24 Feb 2020 10:19:44 -0800 (PST) MIME-Version: 1.0 References: <20200223193456.25291-1-nick.desaulniers@gmail.com> In-Reply-To: From: Ian Rogers Date: Mon, 24 Feb 2020 10:19:33 -0800 Message-ID: Subject: Re: [PATCH] perf: fix -Wstring-compare To: David Laight Cc: Nick Desaulniers , Arnaldo Carvalho de Melo , Ingo Molnar , Peter Zijlstra , clang-built-linux , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Jin Yao , Changbin Du , John Keeping , Song Liu , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 24, 2020 at 8:03 AM David Laight wrote: > > From: Ian Rogers > > Sent: 24 February 2020 05:56 > > On Sun, Feb 23, 2020 at 11:35 AM Nick Desaulniers > > wrote: > > > > > > 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. Reviewed-by: Ian Rogers > > 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). > > Just change the (probable): > #define SRCLINE_UNKNOWN "unknown" > with > static const char SRC_LINE_UNKNOWN[] = "unk"; > > David The SRCLINE_UNKNOWN is used to convey information. Having multiple distinct pointers (static) would mean the compiler could likely remove all comparisons as the compiler could prove that pointer is never returned by a function - ie comparisons are either known to be true (!=) or false (==). Thanks, Ian > - > Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK > Registration No: 1397386 (Wales)