diff mbox series

[31/31] xfs: clean up bufsize alignment in xfs_ioc_attr_list

Message ID 20200221141154.476496-32-hch@lst.de (mailing list archive)
State Superseded
Headers show
Series [01/31] xfs: reject invalid flags combinations in XFS_IOC_ATTRLIST_BY_HANDLE | expand

Commit Message

Christoph Hellwig Feb. 21, 2020, 2:11 p.m. UTC
Use the round_down macro, and use the size of the uint32 type we
use in the callback that fills the buffer to make the code a little
more clear - the size of it is always the same as int for platforms
that Linux runs on.

Suggested-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Darrick J. Wong Feb. 21, 2020, 3:28 p.m. UTC | #1
On Fri, Feb 21, 2020 at 06:11:54AM -0800, Christoph Hellwig wrote:
> Use the round_down macro, and use the size of the uint32 type we
> use in the callback that fills the buffer to make the code a little
> more clear - the size of it is always the same as int for platforms
> that Linux runs on.
> 
> Suggested-by: Dave Chinner <dchinner@redhat.com>
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Looks good to me,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/xfs_ioctl.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
> index 4b126f5e9bed..0690e1a8ef1a 100644
> --- a/fs/xfs/xfs_ioctl.c
> +++ b/fs/xfs/xfs_ioctl.c
> @@ -414,7 +414,7 @@ xfs_ioc_attr_list(
>  	context.resynch = 1;
>  	context.attr_filter = xfs_attr_filter(flags);
>  	context.buffer = buffer;
> -	context.bufsize = (bufsize & ~(sizeof(int)-1));  /* align */
> +	context.bufsize = round_down(bufsize, sizeof(uint32_t));
>  	context.firstu = context.bufsize;
>  	context.put_listent = xfs_ioc_attr_put_listent;
>  
> -- 
> 2.24.1
>
diff mbox series

Patch

diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index 4b126f5e9bed..0690e1a8ef1a 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -414,7 +414,7 @@  xfs_ioc_attr_list(
 	context.resynch = 1;
 	context.attr_filter = xfs_attr_filter(flags);
 	context.buffer = buffer;
-	context.bufsize = (bufsize & ~(sizeof(int)-1));  /* align */
+	context.bufsize = round_down(bufsize, sizeof(uint32_t));
 	context.firstu = context.bufsize;
 	context.put_listent = xfs_ioc_attr_put_listent;