Re: [PATCH] btrfs: fix uninitialized warning in btrfs_log_inode

From: David Sterba
Date: Mon May 22 2023 - 17:57:58 EST


On Wed, May 17, 2023 at 05:07:55PM +0800, Stephen Zhang wrote:
> Qu Wenruo <quwenruo.btrfs@xxxxxxx> 于2023年5月17日周三 15:47写道:
> > On 2023/5/16 09:34, zhangshida wrote:
> > > From: Shida Zhang <zhangshida@xxxxxxxxxx>
> > >
> > > This fixes the following warning reported by gcc 10 under x86_64:
> >
> > Full gcc version please.
>
> it's "gcc (Debian 10.2.1-6) 10.2.1 20210110".
>
> > Especially you need to check if your gcc10 is the latest release.
> >
> > If newer gcc (12.2.1) tested without such error, it may very possible to
> > be a false alert.
> >
> > And in fact it is.
> >
> > @first_dir_index would only be assigned to @last_range_start if
> > last_range_end != 0.
> >
> > Thus the loop must have to be executed once, and @last_range_start won't
> > be zero.
> >
>
> Yup, I know it's a false positive. What I don't know is the criterion
> that decides whether it is a good patch.

If you have analyzed the code and found out that it was indeed a false
positive then please state that in the changelog. Fixing it still makes
sense so the compiler version and briefly explaining why you fix it that
way makes it a good patch.

> That is,
> it doesn't look so good because it is a false alert and the latest gcc
> can get rid of such warnings, based on what you said( if I understand
> correctly).
> Or,
> It looks okay because the patch can make some older gcc get a cleaner
> build and do no harm to the original code logic.

In general I agree here.

> In fact, I've seen Linus complaining about the warning generated by
> some gcc version in another thread.
>
> https://lore.kernel.org/linux-xfs/168384265493.22863.2683852857659893778.pr-tracker-bot@xxxxxxxxxx/T/#t

I share the POV for warning fixes, I'd rather see new reports after
fixing the previous ones than reminding everybody to update.