]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
libxfs: add a xattr_entry helper
authorDarrick J. Wong <djwong@kernel.org>
Mon, 22 Apr 2024 17:01:15 +0000 (10:01 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Mon, 3 Jun 2024 18:37:41 +0000 (11:37 -0700)
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 <hch@lst.de>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
libxfs/defer_item.c

index 36811c7fece1c480a33473ce2e4c7e544dd5f006..fdb922f08c39d80591da7b8b98e0040eb9578ecb 100644 (file)
@@ -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);
 }