* [PATCH linux-next] DM RAID: validate_raid_redundancy: Silence uninitialized variable warning
@ 2013-02-20 20:31 Tim Gardner
2013-02-20 22:16 ` Paul Menzel
2013-02-21 13:19 ` [dm-devel] " Alasdair G Kergon
0 siblings, 2 replies; 8+ messages in thread
From: Tim Gardner @ 2013-02-20 20:31 UTC (permalink / raw)
To: linux-kernel
Cc: Tim Gardner, Alasdair Kergon, dm-devel, Neil Brown, linux-raid
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, but set
it to 0 anyways just to shutup GCC.
Cc: Alasdair Kergon <agk@redhat.com>
Cc: dm-devel@redhat.com
Cc: Neil Brown <neilb@suse.de>
Cc: linux-raid@vger.kernel.org
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
---
drivers/md/dm-raid.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
index 9d6bf19..8005caf 100644
--- 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;
unsigned group_size, last_group_start;
for (i = 0; i < rs->md.raid_disks; i++)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH linux-next] DM RAID: validate_raid_redundancy: Silence uninitialized variable warning
2013-02-20 20:31 [PATCH linux-next] DM RAID: validate_raid_redundancy: Silence uninitialized variable warning Tim Gardner
@ 2013-02-20 22:16 ` Paul Menzel
2013-02-20 22:18 ` Paul Menzel
2013-02-20 22:37 ` NeilBrown
2013-02-21 13:19 ` [dm-devel] " Alasdair G Kergon
1 sibling, 2 replies; 8+ messages in thread
From: Paul Menzel @ 2013-02-20 22:16 UTC (permalink / raw)
To: Tim Gardner
Cc: linux-kernel, Alasdair Kergon, dm-devel, Neil Brown, linux-raid
[-- Attachment #1: Type: text/plain, Size: 1620 bytes --]
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?
> but set it to 0 anyways just to shutup GCC.
Unfortunately I do not know what linux-next version you tested, so the
line numbers are off in.
$ git describe
v3.7.5-4-g9c2ab66
> Cc: Alasdair Kergon <agk@redhat.com>
> Cc: dm-devel@redhat.com
> Cc: Neil Brown <neilb@suse.de>
> Cc: linux-raid@vger.kernel.org
> Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
> ---
> drivers/md/dm-raid.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
> index 9d6bf19..8005caf 100644
> --- 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;
> unsigned group_size, last_group_start;
>
> for (i = 0; i < rs->md.raid_disks; i++)
Thanks,
Paul
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH linux-next] DM RAID: validate_raid_redundancy: Silence uninitialized variable warning
2013-02-20 22:16 ` Paul Menzel
@ 2013-02-20 22:18 ` Paul Menzel
2013-02-20 22:37 ` NeilBrown
1 sibling, 0 replies; 8+ messages in thread
From: Paul Menzel @ 2013-02-20 22:18 UTC (permalink / raw)
To: Tim Gardner
Cc: linux-kernel, Alasdair Kergon, dm-devel, Neil Brown, linux-raid
[-- Attachment #1: Type: text/plain, Size: 1862 bytes --]
Dear Tim,
Am Mittwoch, den 20.02.2013, 23:16 +0100 schrieb Paul Menzel:
> 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?
>
> > but set it to 0 anyways just to shutup GCC.
>
> Unfortunately I do not know what linux-next version you tested, so the
> line numbers are off in.
>
> $ git describe
> v3.7.5-4-g9c2ab66
See below …
> > Cc: Alasdair Kergon <agk@redhat.com>
> > Cc: dm-devel@redhat.com
> > Cc: Neil Brown <neilb@suse.de>
> > Cc: linux-raid@vger.kernel.org
> > Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
> > ---
> > drivers/md/dm-raid.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
> > index 9d6bf19..8005caf 100644
Git to the rescue. I guess I should be able to find that commit to make
sense of the line numbers.
> > --- 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;
> > unsigned group_size, last_group_start;
> >
> > for (i = 0; i < rs->md.raid_disks; i++)
Thanks,
Paul
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH linux-next] DM RAID: validate_raid_redundancy: Silence uninitialized variable warning
2013-02-20 22:16 ` Paul Menzel
2013-02-20 22:18 ` Paul Menzel
@ 2013-02-20 22:37 ` NeilBrown
1 sibling, 0 replies; 8+ messages in thread
From: NeilBrown @ 2013-02-20 22:37 UTC (permalink / raw)
To: Paul Menzel
Cc: Tim Gardner, linux-kernel, Alasdair Kergon, dm-devel, linux-raid
[-- Attachment #1: Type: text/plain, Size: 1591 bytes --]
On Wed, 20 Feb 2013 23:16:37 +0100 Paul Menzel <pm.debian@googlemail.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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [dm-devel] [PATCH linux-next] DM RAID: validate_raid_redundancy: Silence uninitialized variable warning
2013-02-20 20:31 [PATCH linux-next] DM RAID: validate_raid_redundancy: Silence uninitialized variable warning Tim Gardner
2013-02-20 22:16 ` Paul Menzel
@ 2013-02-21 13:19 ` Alasdair G Kergon
2013-02-21 14:50 ` [PATCH linux-next v2] " Tim Gardner
1 sibling, 1 reply; 8+ messages in thread
From: Alasdair G Kergon @ 2013-02-21 13:19 UTC (permalink / raw)
To: Tim Gardner; +Cc: linux-kernel, linux-raid, dm-devel, Alasdair Kergon
On Wed, Feb 20, 2013 at 01:31:18PM -0700, Tim Gardner wrote:
> 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, but set
> it to 0 anyways just to shutup GCC.
Looks bogus to me.
uninitialized_var() please.
Alasdair
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH linux-next v2] DM RAID: validate_raid_redundancy: Silence uninitialized variable warning
2013-02-21 13:19 ` [dm-devel] " Alasdair G Kergon
@ 2013-02-21 14:50 ` Tim Gardner
2013-06-13 15:30 ` Tommi Rantala
0 siblings, 1 reply; 8+ messages in thread
From: Tim Gardner @ 2013-02-21 14:50 UTC (permalink / raw)
To: linux-kernel
Cc: Tim Gardner, Alasdair Kergon, dm-devel, Neil Brown, linux-raid
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 is impossible that rebuilds_per_group could be used before set, but set
it to 0 anyways to silence GCC warnings.
Cc: Alasdair Kergon <agk@redhat.com>
Cc: dm-devel@redhat.com
Cc: Neil Brown <neilb@suse.de>
Cc: linux-raid@vger.kernel.org
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
---
v2 - Added GCC comment. Update commit log with a more definite explanation.
As Neil has pointed out, https://lwn.net/Articles/529954/ indicates
uninitialized_var() is going away.
drivers/md/dm-raid.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
index 9d6bf19..1dbc341 100644
--- a/drivers/md/dm-raid.c
+++ b/drivers/md/dm-raid.c
@@ -380,7 +380,8 @@ 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; /* GCC 4.6.3 */
+ unsigned copies, d;
unsigned group_size, last_group_start;
for (i = 0; i < rs->md.raid_disks; i++)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH linux-next v2] DM RAID: validate_raid_redundancy: Silence uninitialized variable warning
2013-02-21 14:50 ` [PATCH linux-next v2] " Tim Gardner
@ 2013-06-13 15:30 ` Tommi Rantala
2013-06-13 16:00 ` Tim Gardner
0 siblings, 1 reply; 8+ messages in thread
From: Tommi Rantala @ 2013-06-13 15:30 UTC (permalink / raw)
To: Tim Gardner; +Cc: LKML, Alasdair Kergon, dm-devel, Neil Brown, linux-raid
2013/2/21 Tim Gardner <tim.gardner@canonical.com>:
> 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
Hello, is this patch getting merged? I'm also seeing this exact same
compiler warning in my mainline builds.
Tommi
>
> It is impossible that rebuilds_per_group could be used before set, but set
> it to 0 anyways to silence GCC warnings.
>
> Cc: Alasdair Kergon <agk@redhat.com>
> Cc: dm-devel@redhat.com
> Cc: Neil Brown <neilb@suse.de>
> Cc: linux-raid@vger.kernel.org
> Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
> ---
>
> v2 - Added GCC comment. Update commit log with a more definite explanation.
>
> As Neil has pointed out, https://lwn.net/Articles/529954/ indicates
> uninitialized_var() is going away.
>
> drivers/md/dm-raid.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
> index 9d6bf19..1dbc341 100644
> --- a/drivers/md/dm-raid.c
> +++ b/drivers/md/dm-raid.c
> @@ -380,7 +380,8 @@ 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; /* GCC 4.6.3 */
> + unsigned copies, d;
> unsigned group_size, last_group_start;
>
> for (i = 0; i < rs->md.raid_disks; i++)
> --
> 1.7.9.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH linux-next v2] DM RAID: validate_raid_redundancy: Silence uninitialized variable warning
2013-06-13 15:30 ` Tommi Rantala
@ 2013-06-13 16:00 ` Tim Gardner
0 siblings, 0 replies; 8+ messages in thread
From: Tim Gardner @ 2013-06-13 16:00 UTC (permalink / raw)
To: Tommi Rantala; +Cc: LKML, Alasdair Kergon, dm-devel, Neil Brown, linux-raid
On 06/13/2013 09:30 AM, Tommi Rantala wrote:
> 2013/2/21 Tim Gardner <tim.gardner@canonical.com>:
>> 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
>
> Hello, is this patch getting merged? I'm also seeing this exact same
> compiler warning in my mainline builds.
>
> Tommi
>
Dunno. I haven't hassled anyone because it _is_ just a warning.
--
Tim Gardner tim.gardner@canonical.com
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-06-13 16:29 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-20 20:31 [PATCH linux-next] DM RAID: validate_raid_redundancy: Silence uninitialized variable warning Tim Gardner
2013-02-20 22:16 ` Paul Menzel
2013-02-20 22:18 ` Paul Menzel
2013-02-20 22:37 ` NeilBrown
2013-02-21 13:19 ` [dm-devel] " Alasdair G Kergon
2013-02-21 14:50 ` [PATCH linux-next v2] " Tim Gardner
2013-06-13 15:30 ` Tommi Rantala
2013-06-13 16:00 ` Tim Gardner
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).