]> Git Repo - J-linux.git/commitdiff
xattr: remove redundant check on variable err
authorColin Ian King <[email protected]>
Wed, 30 Oct 2024 18:25:47 +0000 (18:25 +0000)
committerAl Viro <[email protected]>
Wed, 6 Nov 2024 18:00:01 +0000 (13:00 -0500)
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]>
fs/xattr.c

index deb336b821c92510c1103176f1f26bbdd94cb86f..02bee149ad9674d3c16f6de137eb3c0fb7cabd89 100644 (file)
@@ -1142,9 +1142,10 @@ generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size)
 {
        const struct xattr_handler *handler, * const *handlers = dentry->d_sb->s_xattr;
        ssize_t remaining_size = buffer_size;
-       int err = 0;
 
        for_each_xattr_handler(handlers, handler) {
+               int err;
+
                if (!handler->name || (handler->list && !handler->list(dentry)))
                        continue;
                err = xattr_list_one(&buffer, &remaining_size, handler->name);
@@ -1152,7 +1153,7 @@ generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size)
                        return err;
        }
 
-       return err ? err : buffer_size - remaining_size;
+       return buffer_size - remaining_size;
 }
 EXPORT_SYMBOL(generic_listxattr);
 
This page took 0.055463 seconds and 4 git commands to generate.