]> git.itanic.dy.fi Git - linux-stable/commitdiff
xfs: use xfs_attr_sf_findname in xfs_attr_shortform_getvalue
authorChristoph Hellwig <hch@lst.de>
Wed, 20 Dec 2023 06:35:00 +0000 (07:35 +0100)
committerChandan Babu R <chandanbabu@kernel.org>
Fri, 29 Dec 2023 08:07:04 +0000 (13:37 +0530)
xfs_attr_shortform_getvalue duplicates the logic in xfs_attr_sf_findname.
Use the helper instead.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Chandan Babu R <chandanbabu@kernel.org>
fs/xfs/libxfs/xfs_attr_leaf.c

index 75c597805ffa8b7fe7dfe31081e27543dc01e0b5..82e1830334160b9087c84832f7113dae971bb6ab 100644 (file)
@@ -848,23 +848,17 @@ int
 xfs_attr_shortform_getvalue(
        struct xfs_da_args              *args)
 {
-       struct xfs_attr_shortform       *sf = args->dp->i_af.if_data;
        struct xfs_attr_sf_entry        *sfe;
-       int                             i;
 
        ASSERT(args->dp->i_af.if_format == XFS_DINODE_FMT_LOCAL);
 
        trace_xfs_attr_sf_lookup(args);
 
-       sfe = &sf->list[0];
-       for (i = 0; i < sf->hdr.count;
-                               sfe = xfs_attr_sf_nextentry(sfe), i++) {
-               if (xfs_attr_match(args, sfe->namelen, sfe->nameval,
-                               sfe->flags))
-                       return xfs_attr_copy_value(args,
-                               &sfe->nameval[args->namelen], sfe->valuelen);
-       }
-       return -ENOATTR;
+       sfe = xfs_attr_sf_findname(args);
+       if (!sfe)
+               return -ENOATTR;
+       return xfs_attr_copy_value(args, &sfe->nameval[args->namelen],
+                       sfe->valuelen);
 }
 
 /* Convert from using the shortform to the leaf format. */