* Re: [NFS] [PATCH] NFSD: fix uninitialized variable
@ 2007-05-29 3:19 ` Jeff Garzik
0 siblings, 0 replies; 13+ messages in thread
From: Jeff Garzik @ 2007-05-29 3:19 UTC (permalink / raw)
To: J. Bruce Fields; +Cc: Andrew Morton, neilb, nfs, LKML
J. Bruce Fields wrote:
> On Sun, May 27, 2007 at 06:34:42AM -0400, Jeff Garzik wrote:
>> Unlike many of the bogus warnings spewed by gcc, this one actually
>> complains about a real bug:
>
> No, the calls to posix_acl_valid() in nfs4_acl_posix_to_nfsv4() ensure
> that the passed-in acl has ACL_USER_OBJ, ACL_GROUP_OBJ, and ACL_OTHER
> entries, and hence that these fields will always be initialized.
OK
> But I don't want anyone else wasting their time on this. Should we cave
> in and add the initialization here just to shut up gcc? Or would a
> comment here help?
Given what you said above, I don't see gcc, on its best day, will ever
know enough to validate that that variable is indeed always initialized.
So I would vote for silencing it on those grounds.
Jeff
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [NFS] [PATCH] NFSD: fix uninitialized variable
2007-05-29 3:19 ` [NFS] " Jeff Garzik
(?)
@ 2007-05-29 4:31 ` young dave
2007-05-29 7:29 ` [NFS] " Matt Keenan
-1 siblings, 1 reply; 13+ messages in thread
From: young dave @ 2007-05-29 4:31 UTC (permalink / raw)
To: Jeff Garzik; +Cc: J. Bruce Fields, Andrew Morton, neilb, nfs, LKML
Hi,
> Given what you said above, I don't see gcc, on its best day, will ever
> know enough to validate that that variable is indeed always initialized.
> So I would vote for silencing it on those grounds.
I agree too. How about this one:
diff -dur linux/fs/nfsd/nfs4acl.c linux.new/fs/nfsd/nfs4acl.c
--- linux/fs/nfsd/nfs4acl.c 2007-05-29 12:28:29.000000000 +0000
+++ linux.new/fs/nfsd/nfs4acl.c 2007-05-29 12:30:45.000000000 +0000
@@ -183,8 +183,6 @@
summarize_posix_acl(struct posix_acl *acl, struct posix_acl_summary *pas)
{
struct posix_acl_entry *pa, *pe;
- pas->users = 0;
- pas->groups = 0;
pas->mask = 07;
pe = acl->a_entries + acl->a_count;
@@ -229,6 +227,7 @@
int eflag = ((flags & NFS4_ACL_TYPE_DEFAULT) ?
NFS4_INHERITANCE_FLAGS | NFS4_ACE_INHERIT_ONLY_ACE : 0);
+ memset(pas, 0, sizeof(struct posix_acl_summary);
BUG_ON(pacl->a_count < 3);
summarize_posix_acl(pacl, &pas);
Regards
dave
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH] NFSD: fix uninitialized variable
2007-05-29 4:31 ` young dave
@ 2007-05-29 7:29 ` Matt Keenan
0 siblings, 0 replies; 13+ messages in thread
From: Matt Keenan @ 2007-05-29 7:29 UTC (permalink / raw)
To: young dave; +Cc: Jeff Garzik, neilb, LKML, J. Bruce Fields, nfs, Andrew Morton
young dave wrote:
> Hi,
>
>> Given what you said above, I don't see gcc, on its best day, will ever
>> know enough to validate that that variable is indeed always initialized.
>> So I would vote for silencing it on those grounds.
>
> I agree too. How about this one:
>
> diff -dur linux/fs/nfsd/nfs4acl.c linux.new/fs/nfsd/nfs4acl.c
> --- linux/fs/nfsd/nfs4acl.c 2007-05-29 12:28:29.000000000 +0000
> +++ linux.new/fs/nfsd/nfs4acl.c 2007-05-29 12:30:45.000000000 +0000
> @@ -183,8 +183,6 @@
> summarize_posix_acl(struct posix_acl *acl, struct posix_acl_summary *pas)
> {
> struct posix_acl_entry *pa, *pe;
> - pas->users = 0;
> - pas->groups = 0;
> pas->mask = 07;
>
> pe = acl->a_entries + acl->a_count;
> @@ -229,6 +227,7 @@
> int eflag = ((flags & NFS4_ACL_TYPE_DEFAULT) ?
> NFS4_INHERITANCE_FLAGS | NFS4_ACE_INHERIT_ONLY_ACE : 0);
>
> + memset(pas, 0, sizeof(struct posix_acl_summary);
> BUG_ON(pacl->a_count < 3);
> summarize_posix_acl(pacl, &pas);
>
^^^^^
apart from the fact that this patch won't compile let alone run...
Matt
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
NFS maillist - NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [NFS] [PATCH] NFSD: fix uninitialized variable
@ 2007-05-29 7:29 ` Matt Keenan
0 siblings, 0 replies; 13+ messages in thread
From: Matt Keenan @ 2007-05-29 7:29 UTC (permalink / raw)
To: young dave; +Cc: Jeff Garzik, J. Bruce Fields, Andrew Morton, neilb, nfs, LKML
young dave wrote:
> Hi,
>
>> Given what you said above, I don't see gcc, on its best day, will ever
>> know enough to validate that that variable is indeed always initialized.
>> So I would vote for silencing it on those grounds.
>
> I agree too. How about this one:
>
> diff -dur linux/fs/nfsd/nfs4acl.c linux.new/fs/nfsd/nfs4acl.c
> --- linux/fs/nfsd/nfs4acl.c 2007-05-29 12:28:29.000000000 +0000
> +++ linux.new/fs/nfsd/nfs4acl.c 2007-05-29 12:30:45.000000000 +0000
> @@ -183,8 +183,6 @@
> summarize_posix_acl(struct posix_acl *acl, struct posix_acl_summary *pas)
> {
> struct posix_acl_entry *pa, *pe;
> - pas->users = 0;
> - pas->groups = 0;
> pas->mask = 07;
>
> pe = acl->a_entries + acl->a_count;
> @@ -229,6 +227,7 @@
> int eflag = ((flags & NFS4_ACL_TYPE_DEFAULT) ?
> NFS4_INHERITANCE_FLAGS | NFS4_ACE_INHERIT_ONLY_ACE : 0);
>
> + memset(pas, 0, sizeof(struct posix_acl_summary);
> BUG_ON(pacl->a_count < 3);
> summarize_posix_acl(pacl, &pas);
>
^^^^^
apart from the fact that this patch won't compile let alone run...
Matt
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH] NFSD: fix uninitialized variable
2007-05-29 7:29 ` [NFS] " Matt Keenan
@ 2007-05-29 8:32 ` young dave
-1 siblings, 0 replies; 13+ messages in thread
From: young dave @ 2007-05-29 8:32 UTC (permalink / raw)
To: Matt Keenan; +Cc: Jeff Garzik, neilb, LKML, J. Bruce Fields, nfs, Andrew Morton
Hi, matt
embarrassed :)
below resend it.
diff -dur linux/fs/nfsd/nfs4acl.c linux.new/fs/nfsd/nfs4acl.c
--- linux/fs/nfsd/nfs4acl.c 2007-05-29 12:28:29.000000000 +0000
+++ linux.new/fs/nfsd/nfs4acl.c 2007-05-29 16:32:26.000000000 +0000
@@ -183,8 +183,6 @@
summarize_posix_acl(struct posix_acl *acl, struct posix_acl_summary *pas)
{
struct posix_acl_entry *pa, *pe;
- pas->users = 0;
- pas->groups = 0;
pas->mask = 07;
pe = acl->a_entries + acl->a_count;
@@ -229,6 +227,7 @@
int eflag = ((flags & NFS4_ACL_TYPE_DEFAULT) ?
NFS4_INHERITANCE_FLAGS | NFS4_ACE_INHERIT_ONLY_ACE : 0);
+ memset(pas, 0, sizeof(struct posix_acl_summary));
BUG_ON(pacl->a_count < 3);
summarize_posix_acl(pacl, &pas);
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
NFS maillist - NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [NFS] [PATCH] NFSD: fix uninitialized variable
@ 2007-05-29 8:32 ` young dave
0 siblings, 0 replies; 13+ messages in thread
From: young dave @ 2007-05-29 8:32 UTC (permalink / raw)
To: Matt Keenan; +Cc: Jeff Garzik, J. Bruce Fields, Andrew Morton, neilb, nfs, LKML
Hi, matt
embarrassed :)
below resend it.
diff -dur linux/fs/nfsd/nfs4acl.c linux.new/fs/nfsd/nfs4acl.c
--- linux/fs/nfsd/nfs4acl.c 2007-05-29 12:28:29.000000000 +0000
+++ linux.new/fs/nfsd/nfs4acl.c 2007-05-29 16:32:26.000000000 +0000
@@ -183,8 +183,6 @@
summarize_posix_acl(struct posix_acl *acl, struct posix_acl_summary *pas)
{
struct posix_acl_entry *pa, *pe;
- pas->users = 0;
- pas->groups = 0;
pas->mask = 07;
pe = acl->a_entries + acl->a_count;
@@ -229,6 +227,7 @@
int eflag = ((flags & NFS4_ACL_TYPE_DEFAULT) ?
NFS4_INHERITANCE_FLAGS | NFS4_ACE_INHERIT_ONLY_ACE : 0);
+ memset(pas, 0, sizeof(struct posix_acl_summary));
BUG_ON(pacl->a_count < 3);
summarize_posix_acl(pacl, &pas);
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] NFSD: fix uninitialized variable
2007-05-29 3:19 ` [NFS] " Jeff Garzik
@ 2007-05-29 19:52 ` J. Bruce Fields
-1 siblings, 0 replies; 13+ messages in thread
From: J. Bruce Fields @ 2007-05-29 19:52 UTC (permalink / raw)
To: Jeff Garzik; +Cc: neilb, Andrew Morton, nfs, LKML
On Mon, May 28, 2007 at 11:19:21PM -0400, Jeff Garzik wrote:
> J. Bruce Fields wrote:
> >But I don't want anyone else wasting their time on this. Should we cave
> >in and add the initialization here just to shut up gcc? Or would a
> >comment here help?
>
> Given what you said above, I don't see gcc, on its best day, will ever
> know enough to validate that that variable is indeed always initialized.
I recall there being arguments before about when to add initializations.
Unfortunately I can't remember the content of those arguments. But I
thought that on the gcc-haters side the complaint was exactly that gcc
was emitting warnings in cases where it could never hope to determine
whether an initialization is required. Am I misremembering?
> So I would vote for silencing it on those grounds.
That said, I'm OK with the extra initialization. Might be worth a
comment, though, just to avoid giving the wrong impression about the
assumptions here; something like:
--b.
diff --git a/fs/nfsd/nfs4acl.c b/fs/nfsd/nfs4acl.c
index cc3b7ba..4adb5ee 100644
--- a/fs/nfsd/nfs4acl.c
+++ b/fs/nfsd/nfs4acl.c
@@ -183,8 +183,13 @@ static void
summarize_posix_acl(struct posix_acl *acl, struct posix_acl_summary *pas)
{
struct posix_acl_entry *pa, *pe;
- pas->users = 0;
- pas->groups = 0;
+
+ /*
+ * Only pas.users and pas.groups need initialization; previous
+ * posix_acl_valid() calls ensure that the other fields will be
+ * initialized in the following loop. But, just to placate gcc:
+ */
+ memset(pas, 0, sizeof(*pas));
pas->mask = 07;
pe = acl->a_entries + acl->a_count;
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
NFS maillist - NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [NFS] [PATCH] NFSD: fix uninitialized variable
@ 2007-05-29 19:52 ` J. Bruce Fields
0 siblings, 0 replies; 13+ messages in thread
From: J. Bruce Fields @ 2007-05-29 19:52 UTC (permalink / raw)
To: Jeff Garzik; +Cc: Andrew Morton, neilb, nfs, LKML
On Mon, May 28, 2007 at 11:19:21PM -0400, Jeff Garzik wrote:
> J. Bruce Fields wrote:
> >But I don't want anyone else wasting their time on this. Should we cave
> >in and add the initialization here just to shut up gcc? Or would a
> >comment here help?
>
> Given what you said above, I don't see gcc, on its best day, will ever
> know enough to validate that that variable is indeed always initialized.
I recall there being arguments before about when to add initializations.
Unfortunately I can't remember the content of those arguments. But I
thought that on the gcc-haters side the complaint was exactly that gcc
was emitting warnings in cases where it could never hope to determine
whether an initialization is required. Am I misremembering?
> So I would vote for silencing it on those grounds.
That said, I'm OK with the extra initialization. Might be worth a
comment, though, just to avoid giving the wrong impression about the
assumptions here; something like:
--b.
diff --git a/fs/nfsd/nfs4acl.c b/fs/nfsd/nfs4acl.c
index cc3b7ba..4adb5ee 100644
--- a/fs/nfsd/nfs4acl.c
+++ b/fs/nfsd/nfs4acl.c
@@ -183,8 +183,13 @@ static void
summarize_posix_acl(struct posix_acl *acl, struct posix_acl_summary *pas)
{
struct posix_acl_entry *pa, *pe;
- pas->users = 0;
- pas->groups = 0;
+
+ /*
+ * Only pas.users and pas.groups need initialization; previous
+ * posix_acl_valid() calls ensure that the other fields will be
+ * initialized in the following loop. But, just to placate gcc:
+ */
+ memset(pas, 0, sizeof(*pas));
pas->mask = 07;
pe = acl->a_entries + acl->a_count;
^ permalink raw reply related [flat|nested] 13+ messages in thread