diff mbox series

[19/29] xfs: replace ATTR_ENTBASESIZE with offsetoff

Message ID 20200114081051.297488-20-hch@lst.de (mailing list archive)
State New, archived
Headers show
Series [01/29] xfs: remove the ATTR_INCOMPLETE flag | expand

Commit Message

Christoph Hellwig Jan. 14, 2020, 8:10 a.m. UTC
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(-)

Comments

Darrick J. Wong Jan. 21, 2020, 6:36 p.m. UTC | #1
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
>
Christoph Hellwig Jan. 23, 2020, 10:43 p.m. UTC | #2
On Tue, Jan 21, 2020 at 10:36:21AM -0800, Darrick J. Wong wrote:
> > -	((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. :?

It looks ok this way, but I'll see if there is something more fancy to
use here..
diff mbox series

Patch

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))
 
 /*