public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@sandeen.net>
To: Jesper Juhl <jesper.juhl@gmail.com>
Cc: xfs-masters@oss.sgi.com, nathans@sgi.com, xfs@oss.sgi.com
Subject: Re: [PATCH] XFS: possibly uninitialized variable use in fs/xfs/xfs_da_btree.c::xfs_da_node_lookup_int()
Date: Sat, 12 Aug 2006 22:24:54 -0500	[thread overview]
Message-ID: <44DE9B86.90006@sandeen.net> (raw)
In-Reply-To: <200608122334.21901.jesper.juhl@gmail.com>

Jesper Juhl wrote:
> I suspect I may be completely wrong, and if that's the case I'd sure like 
> an explanation of where I went wrong along with the NACK for the patch.
> In case my understanding is in fact correct and the patch below makes sense,
> then kindly apply :-)
> 

Seems reasonable to me; I also can't see how it avoids using an uninitialized 
retval in all cases.  But I'm in over my head too, so don't take my word for it 
:).  I'll let the folks @sgi chime in...

FWIW seems like there's a lot of unnecessary endian flipping in there too; I 
haven't tested this but since it endian-flips the magic into blk->magic seems 
like it may as well use it:

Index: xfs-linux/xfs_da_btree.c
===================================================================
--- xfs-linux.orig/xfs_da_btree.c
+++ xfs-linux/xfs_da_btree.c
@@ -1079,14 +1079,14 @@ xfs_da_node_lookup_int(xfs_da_state_t *s
  			return(error);
  		}
  		curr = blk->bp->data;
-		ASSERT(be16_to_cpu(curr->magic) == XFS_DA_NODE_MAGIC ||
-		       be16_to_cpu(curr->magic) == XFS_DIR2_LEAFN_MAGIC ||
-		       be16_to_cpu(curr->magic) == XFS_ATTR_LEAF_MAGIC);
+		blk->magic = be16_to_cpu(curr->magic);
+		ASSERT(blk->magic == XFS_DA_NODE_MAGIC ||
+		       blk->magic == XFS_DIR2_LEAFN_MAGIC ||
+		       blk->magic == XFS_ATTR_LEAF_MAGIC);

  		/*
  		 * Search an intermediate node for a match.
  		 */
-		blk->magic = be16_to_cpu(curr->magic);
  		if (blk->magic == XFS_DA_NODE_MAGIC) {
  			node = blk->bp->data;
  			blk->hashval = 
be32_to_cpu(node->btree[be16_to_cpu(node->hdr.count)-1].hashval);
@@ -1133,10 +1133,10 @@ xfs_da_node_lookup_int(xfs_da_state_t *s
  				blk->index = probe;
  				blkno = be32_to_cpu(btree->before);
  			}
-		} else if (be16_to_cpu(curr->magic) == XFS_ATTR_LEAF_MAGIC) {
+		} else if (blk->magic == XFS_ATTR_LEAF_MAGIC) {
  			blk->hashval = xfs_attr_leaf_lasthash(blk->bp, NULL);
  			break;
-		} else if (be16_to_cpu(curr->magic) == XFS_DIR2_LEAFN_MAGIC) {
+		} else if (blk->magic == XFS_DIR2_LEAFN_MAGIC) {
  			blk->hashval = xfs_dir2_leafn_lasthash(blk->bp, NULL);
  			break;
  		}

  reply	other threads:[~2006-08-13  3:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-12 21:34 [PATCH] XFS: possibly uninitialized variable use in fs/xfs/xfs_da_btree.c::xfs_da_node_lookup_int() Jesper Juhl
2006-08-13  3:24 ` Eric Sandeen [this message]
2006-08-14  5:56   ` review: cleanup xfs_da_node_lookup_int (was Re: [PATCH] XFS: possibly uninitialized variable use in fs/xfs/xfs_da_btree.c::xfs_da_node_lookup_int()) Nathan Scott
2006-08-14 16:00     ` Eric Sandeen
2006-08-16 21:05     ` Jesper Juhl

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=44DE9B86.90006@sandeen.net \
    --to=sandeen@sandeen.net \
    --cc=jesper.juhl@gmail.com \
    --cc=nathans@sgi.com \
    --cc=xfs-masters@oss.sgi.com \
    --cc=xfs@oss.sgi.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox