[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[patch 3/3] Fix misleading gcc4 warning, size may be used uninitialized (ext3)

From: Jesse Millan <jessem cs pdx edu>

Similar story as the ext2 version of acl.c.

The function ext3_set_acl() declares a size_t called 'size' without
setting it to an initial value. 'size' is not referred to again until
you see:

if (acl) {
	// Email KJ comments: size IS initialized in this function
	// only if acl != NULL
	value = ext3_acl_to_disk(acl, &size);

// Email KJ comments: If acl == NULL, size is passed to
// this function uninitialized.
error = ext3_xattr_set_handle(handle, inode, name_index, "",
                                      value, size, 0);

The external function ext3_xattr_set_handle() initializes a member of a
 ext3_xattr_info structure to the value of size.

Initializing 'size' to zero eliminates the compiler warning and the
possibility of passing an uninitialized variable around.

*Note unlike previous patches, initializing 'size' in the function
ext3_acl_to_disk() does not eliminate this particular warning. This is
because of the conditional call to the function that initializes it.

Signed-off-by: Jesse Millan <jessem cs pdx edu>
Signed-off-by: Domen Puncer <domen coderock org>

 acl.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)

Index: quilt/fs/ext3/acl.c
--- quilt.orig/fs/ext3/acl.c
+++ quilt/fs/ext3/acl.c
@@ -225,7 +225,7 @@ ext3_set_acl(handle_t *handle, struct in
 	struct ext3_inode_info *ei = EXT3_I(inode);
 	int name_index;
 	void *value = NULL;
-	size_t size;
+	size_t size = 0;
 	int error;
 	if (S_ISLNK(inode->i_mode))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]