Skip to content

Commit

Permalink
xattr: mark variable as uninitialized to make both gcc and smatch happy
Browse files Browse the repository at this point in the history
new_xattr in __simple_xattr_set() is only initialized with a valid
pointer if value is not NULL, which only happens if this function is
called directly with the intention to remove an existing extended
attribute. Even being safe to be this way, smatch warns about possible
NULL dereference. Dan Carpenter suggested using uninitialized_var()
which will make both gcc and smatch happy.

Cc: Fengguang Wu <fengguang.wu@intel.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Aristeu Rozanski <aris@redhat.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
  • Loading branch information
Aristeu Rozanski authored and Tejun Heo committed Sep 13, 2012
1 parent 4895768 commit b9d6cfd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ static int __simple_xattr_set(struct simple_xattrs *xattrs, const char *name,
const void *value, size_t size, int flags)
{
struct simple_xattr *xattr;
struct simple_xattr *new_xattr = NULL;
struct simple_xattr *uninitialized_var(new_xattr);
int err = 0;

/* value == NULL means remove */
Expand Down

0 comments on commit b9d6cfd

Please sign in to comment.