[btrfs-devel][patch]btrfs_inode_by_name return random value.

Yan Zheng
Thu, 25 Oct 2007 05:07:53 -0000

Hello,

When inode is found, the return value is from the uninitialized
variable 'ret' . I wonder that there is no warning during compilation.

Regards
YZ

--
diff -r 9bf00d0c038f inode.c
--- a/inode.c	Fri Oct 19 14:01:21 2007 -0400
+++ b/inode.c	Thu Oct 25 19:57:29 2007 +0800
@@ -846,15 +846,16 @@ static int btrfs_inode_by_name(struct in
 	struct btrfs_dir_item *di;
 	struct btrfs_path *path;
 	struct btrfs_root *root = BTRFS_I(dir)->root;
-	int ret;
+	int ret = 0;

 	path = btrfs_alloc_path();
 	BUG_ON(!path);
 	di = btrfs_lookup_dir_item(NULL, root, path, dir->i_ino, name,
 				    namelen, 0);
+	if (IS_ERR(di))
+		ret = PTR_ERR(di);
 	if (!di || IS_ERR(di)) {
 		location->objectid = 0;
-		ret = 0;
 		goto out;
 	}
 	btrfs_dir_item_key_to_cpu(path->nodes[0], di, location);