From: Darrick J. Wong Date: Mon, 22 Apr 2024 17:01:15 +0000 (-0700) Subject: libxfs: add a xattr_entry helper X-Git-Tag: v6.9.0~17^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5ac16998a64422509f3123304891aae905e1ff04;p=thirdparty%2Fxfsprogs-dev.git libxfs: add a xattr_entry helper Add a helper to translate from the item list head to the attr_intent item structure and use it so shorten assignments and avoid the need for extra local variables. Inspired-by: Christoph Hellwig Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- diff --git a/libxfs/defer_item.c b/libxfs/defer_item.c index 36811c7f..fdb922f0 100644 --- a/libxfs/defer_item.c +++ b/libxfs/defer_item.c @@ -570,6 +570,13 @@ const struct xfs_defer_op_type xfs_bmap_update_defer_type = { .cancel_item = xfs_bmap_update_cancel_item, }; +/* Logged extended attributes */ + +static inline struct xfs_attr_intent *attri_entry(const struct list_head *e) +{ + return list_entry(e, struct xfs_attr_intent, xattri_list); +} + /* Get an ATTRI. */ static struct xfs_log_item * xfs_attr_create_intent( @@ -618,11 +625,10 @@ xfs_attr_finish_item( struct list_head *item, struct xfs_btree_cur **state) { - struct xfs_attr_intent *attr; - int error; + struct xfs_attr_intent *attr = attri_entry(item); struct xfs_da_args *args; + int error; - attr = container_of(item, struct xfs_attr_intent, xattri_list); args = attr->xattri_da_args; /* @@ -651,9 +657,8 @@ static void xfs_attr_cancel_item( struct list_head *item) { - struct xfs_attr_intent *attr; + struct xfs_attr_intent *attr = attri_entry(item); - attr = container_of(item, struct xfs_attr_intent, xattri_list); xfs_attr_free_item(attr); }