Re: [PATCH][next] bcachefs: remove redundant initialization of variable level

From: Kent Overstreet
Date: Sat Nov 11 2023 - 18:50:11 EST


On Sat, Nov 11, 2023 at 09:19:40PM +0000, David Laight wrote:
> From: Kent Overstreet <kent.overstreet@xxxxxxxxx>
> > 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@xxxxxxxxx>
> >
> > 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.