Re: [PATCH 19/29] xfs: replace ATTR_ENTBASESIZE with offsetoff

Darrick J. Wong
2020-01-21T18:36:28Z

On Tue, Jan 14, 2020 at 09:10:41AM +0100, Christoph Hellwig wrote:
> Replace an opencoded offsetof with the actual helper.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> fs/xfs/xfs_attr_list.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/fs/xfs/xfs_attr_list.c b/fs/xfs/xfs_attr_list.c
> index 9c4acb6dc856..7f08e417d131 100644
> --- a/fs/xfs/xfs_attr_list.c
> +++ b/fs/xfs/xfs_attr_list.c
> @@ -545,10 +545,9 @@ xfs_attr_list_int(
> return error;
> }
>
> -#define ATTR_ENTBASESIZE /* minimum bytes used by an attr */ \
> - (((struct attrlist_ent *) 0)->a_name - (char *) 0)
> #define ATTR_ENTSIZE(namelen) /* actual bytes used by an attr */ \
> - ((ATTR_ENTBASESIZE + (namelen) + 1 + sizeof(uint32_t)-1) \
> + ((offsetof(struct attrlist_ent, a_name) + \
> + (namelen) + 1 + sizeof(uint32_t) - 1) \
> & ~(sizeof(uint32_t)-1))

This looks like an open-coded round_up(), doesn't it? Or roundup(), I
can't remember which is which. :?

--D

>
> /*
> --
> 2.24.1
>