* [PATCH linux-next] scsi: target: cxgbit: replace ternary operator with min()
@ 2022-05-12 13:37 Guo Zhengkui
2022-05-14 2:41 ` Bart Van Assche
0 siblings, 1 reply; 2+ messages in thread
From: Guo Zhengkui @ 2022-05-12 13:37 UTC (permalink / raw)
To: Martin K. Petersen, Max Gurtovoy, Mike Christie, Varun Prakash,
Guo Zhengkui, open list:SCSI TARGET SUBSYSTEM,
open list:SCSI TARGET SUBSYSTEM, open list
Cc: zhengkui_guo
Fix the following coccicheck warnings:
drivers/target/iscsi/cxgbit/cxgbit_cm.c:1042:12-13: WARNING
opportunity for min()
drivers/target/iscsi/cxgbit/cxgbit_cm.c:1011:12-13: 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@vivo.com>
---
drivers/target/iscsi/cxgbit/cxgbit_cm.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/target/iscsi/cxgbit/cxgbit_cm.c b/drivers/target/iscsi/cxgbit/cxgbit_cm.c
index 3336d2b78bf7..6d9a13da6cb7 100644
--- a/drivers/target/iscsi/cxgbit/cxgbit_cm.c
+++ b/drivers/target/iscsi/cxgbit/cxgbit_cm.c
@@ -1008,7 +1008,7 @@ int cxgbit_ofld_send(struct cxgbit_device *cdev, struct sk_buff *skb)
ret = cxgb4_ofld_send(cdev->lldi.ports[0], skb);
if (ret < 0)
kfree_skb(skb);
- return ret < 0 ? ret : 0;
+ return min(ret, 0);
}
static void cxgbit_release_tid(struct cxgbit_device *cdev, u32 tid)
@@ -1039,7 +1039,7 @@ cxgbit_l2t_send(struct cxgbit_device *cdev, struct sk_buff *skb,
ret = cxgb4_l2t_send(cdev->lldi.ports[0], skb, l2e);
if (ret < 0)
kfree_skb(skb);
- return ret < 0 ? ret : 0;
+ return min(ret, 0);
}
static void cxgbit_send_rx_credits(struct cxgbit_sock *csk, struct sk_buff *skb)
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH linux-next] scsi: target: cxgbit: replace ternary operator with min()
2022-05-12 13:37 [PATCH linux-next] scsi: target: cxgbit: replace ternary operator with min() Guo Zhengkui
@ 2022-05-14 2:41 ` Bart Van Assche
0 siblings, 0 replies; 2+ messages in thread
From: Bart Van Assche @ 2022-05-14 2:41 UTC (permalink / raw)
To: Guo Zhengkui, Martin K. Petersen, Max Gurtovoy, Mike Christie,
Varun Prakash, open list:SCSI TARGET SUBSYSTEM,
open list:SCSI TARGET SUBSYSTEM, open list
Cc: zhengkui_guo
On 5/12/22 06:37, Guo Zhengkui wrote:
> diff --git a/drivers/target/iscsi/cxgbit/cxgbit_cm.c b/drivers/target/iscsi/cxgbit/cxgbit_cm.c
> index 3336d2b78bf7..6d9a13da6cb7 100644
> --- a/drivers/target/iscsi/cxgbit/cxgbit_cm.c
> +++ b/drivers/target/iscsi/cxgbit/cxgbit_cm.c
> @@ -1008,7 +1008,7 @@ int cxgbit_ofld_send(struct cxgbit_device *cdev, struct sk_buff *skb)
> ret = cxgb4_ofld_send(cdev->lldi.ports[0], skb);
> if (ret < 0)
> kfree_skb(skb);
> - return ret < 0 ? ret : 0;
> + return min(ret, 0);
> }
>
> static void cxgbit_release_tid(struct cxgbit_device *cdev, u32 tid)
> @@ -1039,7 +1039,7 @@ cxgbit_l2t_send(struct cxgbit_device *cdev, struct sk_buff *skb,
> ret = cxgb4_l2t_send(cdev->lldi.ports[0], skb, l2e);
> if (ret < 0)
> kfree_skb(skb);
> - return ret < 0 ? ret : 0;
> + return min(ret, 0);
> }
>
> static void cxgbit_send_rx_credits(struct cxgbit_sock *csk, struct sk_buff *skb)
I prefer to keep the existing code since "return min(ret, 0)" is not how
humans write kernel code.
Thanks,
Bart.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-05-14 2:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-12 13:37 [PATCH linux-next] scsi: target: cxgbit: replace ternary operator with min() Guo Zhengkui
2022-05-14 2:41 ` Bart Van Assche
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).