linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Peter Zijlstra' <peterz@infradead.org>,
	Ricardo Ribalda <ribalda@chromium.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-perf-users@vger.kernel.org"
	<linux-perf-users@vger.kernel.org>,
	"Ingo Molnar" <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>
Subject: RE: [PATCH] tools/perf: Do not set a variable unless it will be used
Date: Tue, 8 Jun 2021 11:12:13 +0000	[thread overview]
Message-ID: <369424fbd25444d39352d3ee0f24a89d@AcuMS.aculab.com> (raw)
In-Reply-To: <YLn0D+1R2QHZYRVV@hirez.programming.kicks-ass.net>

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)


      parent reply	other threads:[~2021-06-08 11:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-04  9:26 [PATCH] tools/perf: Do not set a variable unless it will be used Ricardo Ribalda
2021-06-04  9:36 ` Peter Zijlstra
2021-06-04 19:24   ` Ricardo Ribalda
2021-06-08 11:28     ` Peter Zijlstra
2021-06-09 14:15       ` Ricardo Ribalda
2021-06-08 11:12   ` David Laight [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=369424fbd25444d39352d3ee0f24a89d@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=acme@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=ribalda@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).