diff mbox series

[v2,13/13] xattr: remove redundant check on variable err

Message ID 20241102073149.2457240-13-viro@zeniv.linux.org.uk (mailing list archive)
State New
Headers show
Series [v2,01/13] teach filename_lookup() to treat NULL filename as "" | expand

Commit Message

Al Viro Nov. 2, 2024, 7:31 a.m. UTC
From: Colin Ian King <colin.i.king@gmail.com>

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 <colin.i.king@gmail.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 fs/xattr.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/fs/xattr.c b/fs/xattr.c
index deb336b821c9..02bee149ad96 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -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);