Thread (13 messages) 13 messages, 4 authors, 2019-06-27

Re: [PATCH 2/5] vfs: create a generic checking function for FS_IOC_FSSETXATTR

From: Al Viro <viro@zeniv.linux.org.uk>
Date: 2019-06-26 04:12:29
Also in: linux-btrfs, linux-efi, linux-f2fs-devel, linux-fsdevel, linux-xfs, lkml, ocfs2-devel

On Tue, Jun 25, 2019 at 07:32:18PM -0700, Darrick J. Wong wrote:
quoted hunk ↗ jump to hunk
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -373,10 +373,9 @@ static int check_xflags(unsigned int flags)
 static int btrfs_ioctl_fsgetxattr(struct file *file, void __user *arg)
 {
 	struct btrfs_inode *binode = BTRFS_I(file_inode(file));
-	struct fsxattr fa;
-
-	memset(&fa, 0, sizeof(fa));
-	fa.fsx_xflags = btrfs_inode_flags_to_xflags(binode->flags);
+	struct fsxattr fa = {
+		.fsx_xflags = btrfs_inode_flags_to_xflags(binode->flags),
+	};
Umm...  Sure, there's no padding, but still - you are going to copy that thing
to userland...  How about

static inline void simple_fill_fsxattr(struct fsxattr *fa, unsigned xflags)
{
	memset(fa, 0, sizeof(*fa));
	fa->fsx_xflags = xflags;
}

and let the compiler optimize the crap out?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help