diff mbox series

[3/5] fs/stat.c: switch to CLASS(fd_raw)

Message ID 20241112202552.3393751-3-viro@zeniv.linux.org.uk (mailing list archive)
State New
Headers show
Series [1/5] io_statx_prep(): use getname_uflags() | expand

Commit Message

Al Viro Nov. 12, 2024, 8:25 p.m. UTC
... and use fd_empty() consistently

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 fs/stat.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

Comments

Christian Brauner Nov. 13, 2024, 10:20 a.m. UTC | #1
On Tue, Nov 12, 2024 at 08:25:50PM +0000, Al Viro wrote:
> ... and use fd_empty() consistently
> 
> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
> ---

Reviewed-by: Christian Brauner <brauner@kernel.org>
diff mbox series

Patch

diff --git a/fs/stat.c b/fs/stat.c
index 4e8698fa932f..855b995ad09b 100644
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -220,15 +220,10 @@  EXPORT_SYMBOL(vfs_getattr);
  */
 int vfs_fstat(int fd, struct kstat *stat)
 {
-	struct fd f;
-	int error;
-
-	f = fdget_raw(fd);
-	if (!fd_file(f))
+	CLASS(fd_raw, f)(fd);
+	if (fd_empty(f))
 		return -EBADF;
-	error = vfs_getattr(&fd_file(f)->f_path, stat, STATX_BASIC_STATS, 0);
-	fdput(f);
-	return error;
+	return vfs_getattr(&fd_file(f)->f_path, stat, STATX_BASIC_STATS, 0);
 }
 
 static int statx_lookup_flags(int flags)
@@ -275,7 +270,7 @@  static int vfs_statx_fd(int fd, int flags, struct kstat *stat,
 			  u32 request_mask)
 {
 	CLASS(fd_raw, f)(fd);
-	if (!fd_file(f))
+	if (fd_empty(f))
 		return -EBADF;
 	return vfs_statx_path(&fd_file(f)->f_path, flags, stat, request_mask);
 }