]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
RDMA/rdmavt: Use int type to store negative error codes
authorQianfeng Rong <rongqianfeng@vivo.com>
Tue, 26 Aug 2025 15:05:56 +0000 (23:05 +0800)
committerLeon Romanovsky <leon@kernel.org>
Thu, 11 Sep 2025 06:18:35 +0000 (02:18 -0400)
Change 'ret' from u32 to int in alloc_qpn() to store -EINVAL, and remove
the 'bail' label as it simply returns 'ret'.

Storing negative error codes in an u32 causes no runtime issues, but it's
ugly as pants,  Change 'ret' from u32 to int type - this change has no
runtime impact.

Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
Link: https://patch.msgid.link/20250826150556.541440-1-rongqianfeng@vivo.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/sw/rdmavt/qp.c

index e825e2ef7966b37c01aac1f6f7c2a4329e372ce8..134a79eecfcb876cea25e7ae71c613f37b695948 100644 (file)
@@ -492,7 +492,7 @@ static int alloc_qpn(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt,
 {
        u32 i, offset, max_scan, qpn;
        struct rvt_qpn_map *map;
-       u32 ret;
+       int ret;
        u32 max_qpn = exclude_prefix == RVT_AIP_QP_PREFIX ?
                RVT_AIP_QPN_MAX : RVT_QPN_MAX;
 
@@ -510,7 +510,8 @@ static int alloc_qpn(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt,
                else
                        qpt->flags |= n;
                spin_unlock(&qpt->lock);
-               goto bail;
+
+               return ret;
        }
 
        qpn = qpt->last + qpt->incr;
@@ -530,7 +531,8 @@ static int alloc_qpn(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt,
                        if (!test_and_set_bit(offset, map->page)) {
                                qpt->last = qpn;
                                ret = qpn;
-                               goto bail;
+
+                               return ret;
                        }
                        offset += qpt->incr;
                        /*
@@ -565,10 +567,7 @@ static int alloc_qpn(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt,
                qpn = mk_qpn(qpt, map, offset);
        }
 
-       ret = -ENOMEM;
-
-bail:
-       return ret;
+       return -ENOMEM;
 }
 
 /**