[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20130221093744.3ad146c4@notabene.brown>
Date: Thu, 21 Feb 2013 09:37:44 +1100
From: NeilBrown <neilb@...e.de>
To: Paul Menzel <pm.debian@...glemail.com>
Cc: Tim Gardner <tim.gardner@...onical.com>,
linux-kernel@...r.kernel.org, Alasdair Kergon <agk@...hat.com>,
dm-devel@...hat.com, linux-raid@...r.kernel.org
Subject: Re: [PATCH linux-next] DM RAID: validate_raid_redundancy: Silence
uninitialized variable warning
On Wed, 20 Feb 2013 23:16:37 +0100 Paul Menzel <pm.debian@...glemail.com>
wrote:
> Dear Tim,
>
>
> thanks for the patch.
>
>
> Am Mittwoch, den 20.02.2013, 13:31 -0700 schrieb Tim Gardner:
>
> Noting the `gcc` version and build environment is never wrong. ;-)
>
> > drivers/md/dm-raid.c: In function 'raid_ctr':
> > drivers/md/dm-raid.c:453:53: warning: 'rebuilds_per_group' may be used uninitialized in this function [-Wuninitialized]
> > drivers/md/dm-raid.c:383:11: note: 'rebuilds_per_group' was declared here
> >
> > It appears unlikely that rebuilds_per_group could be used before set,
>
> Why? Otherwise the compiler would not complain, right?
It is not simply unlikely, it is impossible. But gcc isn't that clever yet.
> > --- a/drivers/md/dm-raid.c
> > +++ b/drivers/md/dm-raid.c
> > @@ -380,7 +380,7 @@ static int validate_region_size(struct raid_set *rs, unsigned long region_size)
> > static int validate_raid_redundancy(struct raid_set *rs)
> > {
> > unsigned i, rebuild_cnt = 0;
> > - unsigned rebuilds_per_group, copies, d;
> > + unsigned rebuilds_per_group = 0, copies, d;
This should either be:
unsigned uninitialized_var(rebuilds_per_group);
unsigned copies, d;
which the old way and is being deprecated, but at least is consistent with
the kernel as it is, or
unsigned rebuilds_per_group = 0 /* GCC */;
unsigned copies,d;
which is apparently the new way which I believe is due to be imposed on the
kernel immediately after 3.9-rc1
https://lwn.net/Articles/529954/
NeilBrown
Download attachment "signature.asc" of type "application/pgp-signature" (829 bytes)
Powered by blists - more mailing lists