Skip to contentSkip to conversation

Fix gcc4 warning, leaf_pos may be used uninitialized in this function.

PATCH New [email protected] 1 participant 1 message May 28, 2005 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 Fix gcc4 warning, leaf_pos may be used uninitialized in this function.

From: Jesse Millan <[email protected]>

This patch eliminates the warning that is generated
when passing a reference of an uninitialized variable to a function where it possible that the function will return without initializing that variable.

---
 base.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletion(-)
fs/devfs/base.c +4 -1
Index: quilt/fs/devfs/base.c
===================================================================
@@ -1127,8 +1127,11 @@ static devfs_handle_t _devfs_make_parent
 
 	if (dir == NULL)
 		dir = _devfs_get_root_entry();
-	if (dir == NULL)
+	if (dir == NULL) {
+		/* Function would have returned without initializing 'leaf_pos' */
+		*leaf_pos = 0;
 		return NULL;
+	}
 	devfs_get(dir);
 	/*  Search for possible trailing component and ignore it  */
 	for (--namelen; (namelen > 0) && (name[namelen] != '/'); --namelen) ;

--