[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <dad75d5a7aa443e39dc20972d80ee83c@AcuMS.aculab.com>
Date: Mon, 24 Feb 2020 16:03:24 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Ian Rogers' <irogers@...gle.com>,
Nick Desaulniers <nick.desaulniers@...il.com>
CC: Arnaldo Carvalho de Melo <acme@...nel.org>,
Ingo Molnar <mingo@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
clang-built-linux <clang-built-linux@...glegroups.com>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...hat.com>,
Namhyung Kim <namhyung@...nel.org>,
Jin Yao <yao.jin@...ux.intel.com>,
Changbin Du <changbin.du@...el.com>,
John Keeping <john@...anate.com>,
Song Liu <songliubraving@...com>,
LKML <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH] perf: fix -Wstring-compare
From: Ian Rogers
> Sent: 24 February 2020 05:56
> On Sun, Feb 23, 2020 at 11:35 AM Nick Desaulniers
> <nick.desaulniers@...il.com> 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 <nick.desaulniers@...il.com>
> > ---
> > Note: was generated off of mainline; can rebase on -next if it doesn't
> > apply cleanly.
>
> 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
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists