* [PATCH][next] xattr: remove redundant check on variable err
@ 2024-10-30 18:01 Colin Ian King
2024-10-30 18:19 ` Al Viro
2024-10-31 15:43 ` Jan Kara
0 siblings, 2 replies; 3+ messages in thread
From: Colin Ian King @ 2024-10-30 18:01 UTC (permalink / raw)
To: Alexander Viro, Christian Brauner, Jan Kara, linux-fsdevel
Cc: kernel-janitors, linux-kernel
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.
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
fs/xattr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/xattr.c b/fs/xattr.c
index 05ec7e7d9e87..21beb82ab5dc 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -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);
--
2.39.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH][next] xattr: remove redundant check on variable err
2024-10-30 18:01 [PATCH][next] xattr: remove redundant check on variable err Colin Ian King
@ 2024-10-30 18:19 ` Al Viro
2024-10-31 15:43 ` Jan Kara
1 sibling, 0 replies; 3+ messages in thread
From: Al Viro @ 2024-10-30 18:19 UTC (permalink / raw)
To: Colin Ian King
Cc: Christian Brauner, Jan Kara, linux-fsdevel, kernel-janitors,
linux-kernel
On Wed, Oct 30, 2024 at 06:01:40PM +0000, Colin Ian King wrote:
> 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.
I'd suggest taking err itself into the loop body, while we are at it...
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH][next] xattr: remove redundant check on variable err
2024-10-30 18:01 [PATCH][next] xattr: remove redundant check on variable err Colin Ian King
2024-10-30 18:19 ` Al Viro
@ 2024-10-31 15:43 ` Jan Kara
1 sibling, 0 replies; 3+ messages in thread
From: Jan Kara @ 2024-10-31 15:43 UTC (permalink / raw)
To: Colin Ian King
Cc: Alexander Viro, Christian Brauner, Jan Kara, linux-fsdevel,
kernel-janitors, linux-kernel
On Wed 30-10-24 18:01:40, Colin Ian King wrote:
> 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.
>
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Yeah, makes sense. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> fs/xattr.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/xattr.c b/fs/xattr.c
> index 05ec7e7d9e87..21beb82ab5dc 100644
> --- a/fs/xattr.c
> +++ b/fs/xattr.c
> @@ -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);
>
> --
> 2.39.5
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-10-31 15:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-30 18:01 [PATCH][next] xattr: remove redundant check on variable err Colin Ian King
2024-10-30 18:19 ` Al Viro
2024-10-31 15:43 ` Jan Kara
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox