xattr: remove redundant check on variable err
Subsystems (2)
PATCH 1/1 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.
--- fs/xattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xattr.c +1 -1
@@ -1015,7 +1015,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);
Signature · 1 line
2.39.5
Al Viro
maintainerQuoted 5 lines · Colin Ian King
Curretly in function
generic_listxattrthefor_each_xattr_handlerloop 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.
I'd suggest taking err itself into the loop body, while we are at it...
Quoted 7 lines · Colin Ian King
Curretly in function
generic_listxattrthefor_each_xattr_handlerloop 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.Signed-off-by Colin Ian King <[email protected]>
Yeah, makes sense. Feel free to add:
Honza
Quoted 20 lines
--- fs/xattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/xattr.c +1
-1@@ -1015,7 +1015,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);Signature · 1 line
2.39.5
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR