Skip to content

Commit 46a7fce

Browse files
ColinIanKingAl Viro
authored andcommitted
xattr: remove redundant check on variable err
Curretly in function generic_listxattr the for_each_xattr_handler loop checks err and will return out of the function if err is non-zero. It's impossible for err to be non-zero at the end of the function where err is checked again for a non-zero value. The final non-zero check is therefore redundant and can be removed. Also move the declaration of err into the loop. Signed-off-by: Colin Ian King <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent 6140be9 commit 46a7fce

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

fs/xattr.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,17 +1142,18 @@ generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size)
11421142
{
11431143
const struct xattr_handler *handler, * const *handlers = dentry->d_sb->s_xattr;
11441144
ssize_t remaining_size = buffer_size;
1145-
int err = 0;
11461145

11471146
for_each_xattr_handler(handlers, handler) {
1147+
int err;
1148+
11481149
if (!handler->name || (handler->list && !handler->list(dentry)))
11491150
continue;
11501151
err = xattr_list_one(&buffer, &remaining_size, handler->name);
11511152
if (err)
11521153
return err;
11531154
}
11541155

1155-
return err ? err : buffer_size - remaining_size;
1156+
return buffer_size - remaining_size;
11561157
}
11571158
EXPORT_SYMBOL(generic_listxattr);
11581159

0 commit comments

Comments
 (0)