All of lore.kernel.org
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@fieldses.org>
To: Jeff Garzik <jeff@garzik.org>
Cc: neilb@suse.de, Andrew Morton <akpm@linux-foundation.org>,
	nfs@lists.sourceforge.net, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] NFSD: fix uninitialized variable
Date: Tue, 29 May 2007 15:52:27 -0400	[thread overview]
Message-ID: <20070529195227.GG6815@fieldses.org> (raw)
In-Reply-To: <465B9BB9.7060300@garzik.org>

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

WARNING: multiple messages have this Message-ID (diff)
From: "J. Bruce Fields" <bfields@fieldses.org>
To: Jeff Garzik <jeff@garzik.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	neilb@suse.de, nfs@lists.sourceforge.net,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [NFS] [PATCH] NFSD: fix uninitialized variable
Date: Tue, 29 May 2007 15:52:27 -0400	[thread overview]
Message-ID: <20070529195227.GG6815@fieldses.org> (raw)
In-Reply-To: <465B9BB9.7060300@garzik.org>

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;

  parent reply	other threads:[~2007-05-29 19:52 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-27 10:34 [PATCH] NFSD: fix uninitialized variable Jeff Garzik
2007-05-27 10:34 ` Jeff Garzik
2007-05-29  3:00 ` J. Bruce Fields
2007-05-29  3:00   ` [NFS] " J. Bruce Fields
2007-05-29  3:19   ` Jeff Garzik
2007-05-29  3:19     ` [NFS] " Jeff Garzik
2007-05-29  4:31     ` young dave
2007-05-29  7:29       ` Matt Keenan
2007-05-29  7:29         ` [NFS] " Matt Keenan
2007-05-29  8:32         ` young dave
2007-05-29  8:32           ` [NFS] " young dave
2007-05-29 19:52     ` J. Bruce Fields [this message]
2007-05-29 19:52       ` J. Bruce Fields

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070529195227.GG6815@fieldses.org \
    --to=bfields@fieldses.org \
    --cc=akpm@linux-foundation.org \
    --cc=jeff@garzik.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=nfs@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.