Skip to content

Commit

Permalink
Orangefs: xattr.c cleanup
Browse files Browse the repository at this point in the history
1. It is nonsense to test for negative size_t, suggested by
   David Binderman <dcb314@hotmail.com>

2. By the time Orangefs gets called, the vfs has ensured that
   name != NULL, and that buffer and size are sane.

Signed-off-by: Mike Marshall <hubcap@omnibond.com>
  • Loading branch information
hubcapsc committed Apr 8, 2016
1 parent 9735a22 commit 2d09a2c
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions fs/orangefs/xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ ssize_t orangefs_inode_getxattr(struct inode *inode, const char *prefix,
"%s: prefix %s name %s, buffer_size %zd\n",
__func__, prefix, name, size);

if (name == NULL || (size > 0 && buffer == NULL)) {
gossip_err("orangefs_inode_getxattr: bogus NULL pointers\n");
return -EINVAL;
}
if ((strlen(name) + strlen(prefix)) >= ORANGEFS_MAX_XATTR_NAMELEN) {
gossip_err("Invalid key length (%d)\n",
(int)(strlen(name) + strlen(prefix)));
Expand Down Expand Up @@ -239,21 +235,14 @@ int orangefs_inode_setxattr(struct inode *inode, const char *prefix,
"%s: prefix %s, name %s, buffer_size %zd\n",
__func__, prefix, name, size);

if (size < 0 ||
size >= ORANGEFS_MAX_XATTR_VALUELEN ||
if (size >= ORANGEFS_MAX_XATTR_VALUELEN ||
flags < 0) {
gossip_err("orangefs_inode_setxattr: bogus values of size(%d), flags(%d)\n",
(int)size,
flags);
return -EINVAL;
}

if (name == NULL ||
(size > 0 && value == NULL)) {
gossip_err("orangefs_inode_setxattr: bogus NULL pointers!\n");
return -EINVAL;
}

internal_flag = convert_to_internal_xattr_flags(flags);

if (prefix) {
Expand Down Expand Up @@ -353,10 +342,6 @@ ssize_t orangefs_listxattr(struct dentry *dentry, char *buffer, size_t size)
gossip_err("%s: bogus NULL pointers\n", __func__);
return -EINVAL;
}
if (size < 0) {
gossip_err("Invalid size (%d)\n", (int)size);
return -EINVAL;
}

down_read(&orangefs_inode->xattr_sem);
new_op = op_alloc(ORANGEFS_VFS_OP_LISTXATTR);
Expand Down

0 comments on commit 2d09a2c

Please sign in to comment.