lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220512135837.41089-1-guozhengkui@vivo.com>
Date:   Thu, 12 May 2022 21:58:37 +0800
From:   Guo Zhengkui <guozhengkui@...o.com>
To:     Potnuri Bharat Teja <bharat@...lsio.com>,
        Jason Gunthorpe <jgg@...pe.ca>,
        Leon Romanovsky <leon@...nel.org>,
        Bernard Metzler <bmt@...ich.ibm.com>,
        linux-rdma@...r.kernel.org (open list:CXGB4 IWARP RNIC DRIVER
        (IW_CXGB4)), linux-kernel@...r.kernel.org (open list)
Cc:     zhengkui_guo@...look.com, Guo Zhengkui <guozhengkui@...o.com>
Subject: [PATCH] RDMA: replace ternary operator with min()

Fix the following coccicheck warnings:

drivers/infiniband/sw/siw/siw_cm.c:1326:11-12: WARNING opportunity for min()
drivers/infiniband/sw/siw/siw_cm.c:488:11-12: WARNING opportunity for min()
drivers/infiniband/hw/cxgb4/cm.c:217:14-15: WARNING opportunity for min()
drivers/infiniband/hw/cxgb4/cm.c:232:14-15: WARNING opportunity for min()

min() macro is defined in include/linux/minmax.h. It avoids multiple
evaluations of the arguments when non-constant and performs strict
type-checking.

Signed-off-by: Guo Zhengkui <guozhengkui@...o.com>
---
 drivers/infiniband/hw/cxgb4/cm.c   | 4 ++--
 drivers/infiniband/sw/siw/siw_cm.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index c16017f6e8db..167faa358800 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -214,7 +214,7 @@ static int c4iw_l2t_send(struct c4iw_rdev *rdev, struct sk_buff *skb,
 		kfree_skb(skb);
 	else if (error == NET_XMIT_DROP)
 		return -ENOMEM;
-	return error < 0 ? error : 0;
+	return min(error, 0);
 }
 
 int c4iw_ofld_send(struct c4iw_rdev *rdev, struct sk_buff *skb)
@@ -229,7 +229,7 @@ int c4iw_ofld_send(struct c4iw_rdev *rdev, struct sk_buff *skb)
 	error = cxgb4_ofld_send(rdev->lldi.ports[0], skb);
 	if (error < 0)
 		kfree_skb(skb);
-	return error < 0 ? error : 0;
+	return min(error, 0);
 }
 
 static void release_tid(struct c4iw_rdev *rdev, u32 hwtid, struct sk_buff *skb)
diff --git a/drivers/infiniband/sw/siw/siw_cm.c b/drivers/infiniband/sw/siw/siw_cm.c
index 17f34d584cd9..3f8181664050 100644
--- a/drivers/infiniband/sw/siw/siw_cm.c
+++ b/drivers/infiniband/sw/siw/siw_cm.c
@@ -485,7 +485,7 @@ static int siw_send_mpareqrep(struct siw_cep *cep, const void *pdata, u8 pd_len)
 
 	rv = kernel_sendmsg(s, &msg, iov, iovec_num + 1, mpa_len);
 
-	return rv < 0 ? rv : 0;
+	return min(rv, 0);
 }
 
 /*
@@ -1324,7 +1324,7 @@ static int kernel_bindconnect(struct socket *s, struct sockaddr *laddr,
 
 	rv = s->ops->connect(s, raddr, size, flags);
 
-	return rv < 0 ? rv : 0;
+	return min(rv, 0);
 }
 
 int siw_connect(struct iw_cm_id *id, struct iw_cm_conn_param *params)
-- 
2.20.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ