]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: rename diff_two_keys routines
authorFedor Pchelkin <pchelkin@ispras.ru>
Mon, 6 Oct 2025 12:39:38 +0000 (14:39 +0200)
committerAndrey Albershteyn <aalbersh@kernel.org>
Mon, 13 Oct 2025 09:53:39 +0000 (11:53 +0200)
Source kernel commit: edce172444b4f489715a3df2e5d50893e74ce3da

One may think that diff_two_keys routines are used to compute the actual
difference between the arguments but they return a result of a
three-way-comparison of the passed operands. So it looks more appropriate
to denote them as cmp_two_keys.

Found by Linux Verification Center (linuxtesting.org).

Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
libxfs/xfs_alloc_btree.c
libxfs/xfs_bmap_btree.c
libxfs/xfs_btree.c
libxfs/xfs_btree.h
libxfs/xfs_ialloc_btree.c
libxfs/xfs_refcount_btree.c
libxfs/xfs_rmap_btree.c
libxfs/xfs_rtrefcount_btree.c
libxfs/xfs_rtrmap_btree.c
repair/rcbag_btree.c

index 63b8db4ed01350bd00a813b3b346028093028e45..85ce9f728f8d7c5388d391562abc49b05cbaa26d 100644 (file)
@@ -212,7 +212,7 @@ xfs_cntbt_key_diff(
 }
 
 STATIC int64_t
-xfs_bnobt_diff_two_keys(
+xfs_bnobt_cmp_two_keys(
        struct xfs_btree_cur            *cur,
        const union xfs_btree_key       *k1,
        const union xfs_btree_key       *k2,
@@ -225,7 +225,7 @@ xfs_bnobt_diff_two_keys(
 }
 
 STATIC int64_t
-xfs_cntbt_diff_two_keys(
+xfs_cntbt_cmp_two_keys(
        struct xfs_btree_cur            *cur,
        const union xfs_btree_key       *k1,
        const union xfs_btree_key       *k2,
@@ -438,7 +438,7 @@ const struct xfs_btree_ops xfs_bnobt_ops = {
        .init_ptr_from_cur      = xfs_allocbt_init_ptr_from_cur,
        .key_diff               = xfs_bnobt_key_diff,
        .buf_ops                = &xfs_bnobt_buf_ops,
-       .diff_two_keys          = xfs_bnobt_diff_two_keys,
+       .cmp_two_keys           = xfs_bnobt_cmp_two_keys,
        .keys_inorder           = xfs_bnobt_keys_inorder,
        .recs_inorder           = xfs_bnobt_recs_inorder,
        .keys_contiguous        = xfs_allocbt_keys_contiguous,
@@ -468,7 +468,7 @@ const struct xfs_btree_ops xfs_cntbt_ops = {
        .init_ptr_from_cur      = xfs_allocbt_init_ptr_from_cur,
        .key_diff               = xfs_cntbt_key_diff,
        .buf_ops                = &xfs_cntbt_buf_ops,
-       .diff_two_keys          = xfs_cntbt_diff_two_keys,
+       .cmp_two_keys           = xfs_cntbt_cmp_two_keys,
        .keys_inorder           = xfs_cntbt_keys_inorder,
        .recs_inorder           = xfs_cntbt_recs_inorder,
        .keys_contiguous        = NULL, /* not needed right now */
index 40e0cb3016fc5e680b95ad7c277b7da2ff245192..eb3e5d70de6a1225e14db025b6ec37febfeabeb4 100644 (file)
@@ -378,7 +378,7 @@ xfs_bmbt_key_diff(
 }
 
 STATIC int64_t
-xfs_bmbt_diff_two_keys(
+xfs_bmbt_cmp_two_keys(
        struct xfs_btree_cur            *cur,
        const union xfs_btree_key       *k1,
        const union xfs_btree_key       *k2,
@@ -647,7 +647,7 @@ const struct xfs_btree_ops xfs_bmbt_ops = {
        .init_high_key_from_rec = xfs_bmbt_init_high_key_from_rec,
        .init_rec_from_cur      = xfs_bmbt_init_rec_from_cur,
        .key_diff               = xfs_bmbt_key_diff,
-       .diff_two_keys          = xfs_bmbt_diff_two_keys,
+       .cmp_two_keys           = xfs_bmbt_cmp_two_keys,
        .buf_ops                = &xfs_bmbt_buf_ops,
        .keys_inorder           = xfs_bmbt_keys_inorder,
        .recs_inorder           = xfs_bmbt_recs_inorder,
index fce215f924898dd86b4120b0ec8fa9cf63121405..78cc31f61e1523a17bee5bdcfb81b425125e857f 100644 (file)
@@ -5055,7 +5055,7 @@ xfs_btree_simple_query_range(
        int                             error;
 
        ASSERT(cur->bc_ops->init_high_key_from_rec);
-       ASSERT(cur->bc_ops->diff_two_keys);
+       ASSERT(cur->bc_ops->cmp_two_keys);
 
        /*
         * Find the leftmost record.  The btree cursor must be set
index 355b304696e6c3e3e90d512cd97bbf7c8d3fad2f..1046bbf3839aa6e6d605af4621fb31cc71ba35c2 100644 (file)
@@ -176,15 +176,15 @@ struct xfs_btree_ops {
                            const union xfs_btree_key *key);
 
        /*
-        * Difference between key2 and key1 -- positive if key1 > key2,
-        * negative if key1 < key2, and zero if equal.  If the @mask parameter
-        * is non NULL, each key field to be used in the comparison must
-        * contain a nonzero value.
+        * Compare key1 and key2 -- positive if key1 > key2, negative if
+        * key1 < key2, and zero if equal.  If the @mask parameter is non NULL,
+        * each key field to be used in the comparison must contain a nonzero
+        * value.
         */
-       int64_t (*diff_two_keys)(struct xfs_btree_cur *cur,
-                                const union xfs_btree_key *key1,
-                                const union xfs_btree_key *key2,
-                                const union xfs_btree_key *mask);
+       int64_t (*cmp_two_keys)(struct xfs_btree_cur *cur,
+                               const union xfs_btree_key *key1,
+                               const union xfs_btree_key *key2,
+                               const union xfs_btree_key *mask);
 
        const struct xfs_buf_ops        *buf_ops;
 
@@ -546,7 +546,7 @@ xfs_btree_keycmp_lt(
        const union xfs_btree_key       *key1,
        const union xfs_btree_key       *key2)
 {
-       return cur->bc_ops->diff_two_keys(cur, key1, key2, NULL) < 0;
+       return cur->bc_ops->cmp_two_keys(cur, key1, key2, NULL) < 0;
 }
 
 static inline bool
@@ -555,7 +555,7 @@ xfs_btree_keycmp_gt(
        const union xfs_btree_key       *key1,
        const union xfs_btree_key       *key2)
 {
-       return cur->bc_ops->diff_two_keys(cur, key1, key2, NULL) > 0;
+       return cur->bc_ops->cmp_two_keys(cur, key1, key2, NULL) > 0;
 }
 
 static inline bool
@@ -564,7 +564,7 @@ xfs_btree_keycmp_eq(
        const union xfs_btree_key       *key1,
        const union xfs_btree_key       *key2)
 {
-       return cur->bc_ops->diff_two_keys(cur, key1, key2, NULL) == 0;
+       return cur->bc_ops->cmp_two_keys(cur, key1, key2, NULL) == 0;
 }
 
 static inline bool
@@ -602,7 +602,7 @@ xfs_btree_masked_keycmp_lt(
        const union xfs_btree_key       *key2,
        const union xfs_btree_key       *mask)
 {
-       return cur->bc_ops->diff_two_keys(cur, key1, key2, mask) < 0;
+       return cur->bc_ops->cmp_two_keys(cur, key1, key2, mask) < 0;
 }
 
 static inline bool
@@ -612,7 +612,7 @@ xfs_btree_masked_keycmp_gt(
        const union xfs_btree_key       *key2,
        const union xfs_btree_key       *mask)
 {
-       return cur->bc_ops->diff_two_keys(cur, key1, key2, mask) > 0;
+       return cur->bc_ops->cmp_two_keys(cur, key1, key2, mask) > 0;
 }
 
 static inline bool
index 4cccac145dc7753490816c19826363e4eece0a55..d5f55f7466dbf850165b53b22a01f581cc527cd7 100644 (file)
@@ -274,7 +274,7 @@ xfs_inobt_key_diff(
 }
 
 STATIC int64_t
-xfs_inobt_diff_two_keys(
+xfs_inobt_cmp_two_keys(
        struct xfs_btree_cur            *cur,
        const union xfs_btree_key       *k1,
        const union xfs_btree_key       *k2,
@@ -431,7 +431,7 @@ const struct xfs_btree_ops xfs_inobt_ops = {
        .init_ptr_from_cur      = xfs_inobt_init_ptr_from_cur,
        .key_diff               = xfs_inobt_key_diff,
        .buf_ops                = &xfs_inobt_buf_ops,
-       .diff_two_keys          = xfs_inobt_diff_two_keys,
+       .cmp_two_keys           = xfs_inobt_cmp_two_keys,
        .keys_inorder           = xfs_inobt_keys_inorder,
        .recs_inorder           = xfs_inobt_recs_inorder,
        .keys_contiguous        = xfs_inobt_keys_contiguous,
@@ -461,7 +461,7 @@ const struct xfs_btree_ops xfs_finobt_ops = {
        .init_ptr_from_cur      = xfs_finobt_init_ptr_from_cur,
        .key_diff               = xfs_inobt_key_diff,
        .buf_ops                = &xfs_finobt_buf_ops,
-       .diff_two_keys          = xfs_inobt_diff_two_keys,
+       .cmp_two_keys           = xfs_inobt_cmp_two_keys,
        .keys_inorder           = xfs_inobt_keys_inorder,
        .recs_inorder           = xfs_inobt_recs_inorder,
        .keys_contiguous        = xfs_inobt_keys_contiguous,
index efb9af710f7361c7d9ab0fabea221a2ab0a95f5b..63417b873cdfbc376b99cd096be199002c89f938 100644 (file)
@@ -188,7 +188,7 @@ xfs_refcountbt_key_diff(
 }
 
 STATIC int64_t
-xfs_refcountbt_diff_two_keys(
+xfs_refcountbt_cmp_two_keys(
        struct xfs_btree_cur            *cur,
        const union xfs_btree_key       *k1,
        const union xfs_btree_key       *k2,
@@ -340,7 +340,7 @@ const struct xfs_btree_ops xfs_refcountbt_ops = {
        .init_ptr_from_cur      = xfs_refcountbt_init_ptr_from_cur,
        .key_diff               = xfs_refcountbt_key_diff,
        .buf_ops                = &xfs_refcountbt_buf_ops,
-       .diff_two_keys          = xfs_refcountbt_diff_two_keys,
+       .cmp_two_keys           = xfs_refcountbt_cmp_two_keys,
        .keys_inorder           = xfs_refcountbt_keys_inorder,
        .recs_inorder           = xfs_refcountbt_recs_inorder,
        .keys_contiguous        = xfs_refcountbt_keys_contiguous,
index f4da35050d26358a8bfbe387627bb4447678e610..0481850e46c81ef21888707664ac272b048f1e78 100644 (file)
@@ -273,7 +273,7 @@ xfs_rmapbt_key_diff(
 }
 
 STATIC int64_t
-xfs_rmapbt_diff_two_keys(
+xfs_rmapbt_cmp_two_keys(
        struct xfs_btree_cur            *cur,
        const union xfs_btree_key       *k1,
        const union xfs_btree_key       *k2,
@@ -516,7 +516,7 @@ const struct xfs_btree_ops xfs_rmapbt_ops = {
        .init_ptr_from_cur      = xfs_rmapbt_init_ptr_from_cur,
        .key_diff               = xfs_rmapbt_key_diff,
        .buf_ops                = &xfs_rmapbt_buf_ops,
-       .diff_two_keys          = xfs_rmapbt_diff_two_keys,
+       .cmp_two_keys           = xfs_rmapbt_cmp_two_keys,
        .keys_inorder           = xfs_rmapbt_keys_inorder,
        .recs_inorder           = xfs_rmapbt_recs_inorder,
        .keys_contiguous        = xfs_rmapbt_keys_contiguous,
@@ -633,7 +633,7 @@ const struct xfs_btree_ops xfs_rmapbt_mem_ops = {
        .init_ptr_from_cur      = xfbtree_init_ptr_from_cur,
        .key_diff               = xfs_rmapbt_key_diff,
        .buf_ops                = &xfs_rmapbt_mem_buf_ops,
-       .diff_two_keys          = xfs_rmapbt_diff_two_keys,
+       .cmp_two_keys           = xfs_rmapbt_cmp_two_keys,
        .keys_inorder           = xfs_rmapbt_keys_inorder,
        .recs_inorder           = xfs_rmapbt_recs_inorder,
        .keys_contiguous        = xfs_rmapbt_keys_contiguous,
index a532476407e913061dc770506a7cbb23eb9c25cb..1f563a724c2245b14e896cd10856452b8f5d07a9 100644 (file)
@@ -169,7 +169,7 @@ xfs_rtrefcountbt_key_diff(
 }
 
 STATIC int64_t
-xfs_rtrefcountbt_diff_two_keys(
+xfs_rtrefcountbt_cmp_two_keys(
        struct xfs_btree_cur            *cur,
        const union xfs_btree_key       *k1,
        const union xfs_btree_key       *k2,
@@ -387,7 +387,7 @@ const struct xfs_btree_ops xfs_rtrefcountbt_ops = {
        .init_ptr_from_cur      = xfs_rtrefcountbt_init_ptr_from_cur,
        .key_diff               = xfs_rtrefcountbt_key_diff,
        .buf_ops                = &xfs_rtrefcountbt_buf_ops,
-       .diff_two_keys          = xfs_rtrefcountbt_diff_two_keys,
+       .cmp_two_keys           = xfs_rtrefcountbt_cmp_two_keys,
        .keys_inorder           = xfs_rtrefcountbt_keys_inorder,
        .recs_inorder           = xfs_rtrefcountbt_recs_inorder,
        .keys_contiguous        = xfs_rtrefcountbt_keys_contiguous,
index d46fb67bb5d4285bcbb52afb60aa4dcb599fb64d..5b3836fccc252eb318005a7d90ab8fa29e7a214b 100644 (file)
@@ -215,7 +215,7 @@ xfs_rtrmapbt_key_diff(
 }
 
 STATIC int64_t
-xfs_rtrmapbt_diff_two_keys(
+xfs_rtrmapbt_cmp_two_keys(
        struct xfs_btree_cur            *cur,
        const union xfs_btree_key       *k1,
        const union xfs_btree_key       *k2,
@@ -512,7 +512,7 @@ const struct xfs_btree_ops xfs_rtrmapbt_ops = {
        .init_ptr_from_cur      = xfs_rtrmapbt_init_ptr_from_cur,
        .key_diff               = xfs_rtrmapbt_key_diff,
        .buf_ops                = &xfs_rtrmapbt_buf_ops,
-       .diff_two_keys          = xfs_rtrmapbt_diff_two_keys,
+       .cmp_two_keys           = xfs_rtrmapbt_cmp_two_keys,
        .keys_inorder           = xfs_rtrmapbt_keys_inorder,
        .recs_inorder           = xfs_rtrmapbt_recs_inorder,
        .keys_contiguous        = xfs_rtrmapbt_keys_contiguous,
@@ -621,7 +621,7 @@ const struct xfs_btree_ops xfs_rtrmapbt_mem_ops = {
        .init_ptr_from_cur      = xfbtree_init_ptr_from_cur,
        .key_diff               = xfs_rtrmapbt_key_diff,
        .buf_ops                = &xfs_rtrmapbt_mem_buf_ops,
-       .diff_two_keys          = xfs_rtrmapbt_diff_two_keys,
+       .cmp_two_keys           = xfs_rtrmapbt_cmp_two_keys,
        .keys_inorder           = xfs_rtrmapbt_keys_inorder,
        .recs_inorder           = xfs_rtrmapbt_recs_inorder,
        .keys_contiguous        = xfs_rtrmapbt_keys_contiguous,
index bed7c7a8f69960e0a18c4cec41c25c19c24a8be4..404b509f64d7874fc7c566a395afa394ff960829 100644 (file)
@@ -73,7 +73,7 @@ rcbagbt_key_diff(
 }
 
 STATIC int64_t
-rcbagbt_diff_two_keys(
+rcbagbt_cmp_two_keys(
        struct xfs_btree_cur            *cur,
        const union xfs_btree_key       *k1,
        const union xfs_btree_key       *k2,
@@ -222,7 +222,7 @@ static const struct xfs_btree_ops rcbagbt_mem_ops = {
        .init_ptr_from_cur      = xfbtree_init_ptr_from_cur,
        .key_diff               = rcbagbt_key_diff,
        .buf_ops                = &rcbagbt_mem_buf_ops,
-       .diff_two_keys          = rcbagbt_diff_two_keys,
+       .cmp_two_keys           = rcbagbt_cmp_two_keys,
        .keys_inorder           = rcbagbt_keys_inorder,
        .recs_inorder           = rcbagbt_recs_inorder,
 };