[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d106f21ef1164241a275b1f11b82e7b7@AcuMS.aculab.com>
Date: Sun, 12 Nov 2023 18:34:59 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Kent Overstreet' <kent.overstreet@...ux.dev>
CC: Colin Ian King <colin.i.king@...il.com>,
Brian Foster <bfoster@...hat.com>,
"linux-bcachefs@...r.kernel.org" <linux-bcachefs@...r.kernel.org>,
"kernel-janitors@...r.kernel.org" <kernel-janitors@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH][next] bcachefs: remove redundant initialization of
variable level
From: Kent Overstreet
> Sent: 11 November 2023 23:39
>
> On Sat, Nov 11, 2023 at 09:19:40PM +0000, David Laight wrote:
> > From: Kent Overstreet <kent.overstreet@...ux.dev>
> > > Sent: 11 November 2023 21:02
> > > > Variable level is being initialized a value that is never read, the
> > > > variable is being re-assigned another value several statements later
> > > > on. The initialization is redundant and can be removed. Cleans up
> > > > clang scan build warning:
> > > >
> > > > fs/bcachefs/btree_iter.c:1217:11: warning: Value stored to 'level'
> > > > during its initialization is never read [deadcode.DeadStores]
> > > >
> > > > Signed-off-by: Colin Ian King <colin.i.king@...il.com>
> > >
> > > since we're no longer gnu89, we can simply declare the variable when
> > > it's first used, like so:
> >
> > ugg... I think that is still frowned upon.
> > It makes it very difficult for the average human to find
> > the variable declaration.
>
> No, it's 2023, there's no good reason to be declaring variables before
> giving them values.
The year has nothing to do with whether it is a good idea.
It is epically bad without -Wshadow.
(Have you ever played 'stop the declaration' in C++, it isn't fun.)
Finding declarations is bad enough when they are at the top
of a big block, never mind in the middle of a load of assignments.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists