[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <369424fbd25444d39352d3ee0f24a89d@AcuMS.aculab.com>
Date: Tue, 8 Jun 2021 11:12:13 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Peter Zijlstra' <peterz@...radead.org>,
Ricardo Ribalda <ribalda@...omium.org>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-perf-users@...r.kernel.org" <linux-perf-users@...r.kernel.org>,
"Ingo Molnar" <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>
Subject: RE: [PATCH] tools/perf: Do not set a variable unless it will be used
From: Peter Zijlstra
> Sent: 04 June 2021 10:36
>
> On Fri, Jun 04, 2021 at 11:26:38AM +0200, Ricardo Ribalda wrote:
> > clang-13 triggers the following warning:
> >
> > bench/inject-buildid.c:351:6: error: variable 'len' set but not used [-Werror,-Wunused-but-set-
> variable]
> > u64 len = 0;
> >
> > This patch sets the value to len only if it will be used afterwards.
>
> My vote would be to kill that warning, what absolute shite.
The compiler folk need their heads examining.
On one hand they are adding code to initialise everything
to avoid leaking information, and on the other they moan
when you do defensive coding.
There might be a justification for:
foo = complex_expression;
where, maybe, you might have assigned it to the wrong variable.
But for simple constants (especially on declarations)
it is really silly.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists