mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: [PATCH] gpib: lpvo_usb: rewrite DLE/STX sequence validation using !(A && B) for clarity
       [not found] <6a07e0f7.e59d1661.1cd5fe.6c90SMTPIN_ADDED_BROKEN@mx.google.com>
@ 2026-05-18 10:56 ` Johan Hovold
  0 siblings, 0 replies; 2+ messages in thread
From: Johan Hovold @ 2026-05-18 10:56 UTC (permalink / raw)
  To: sunliming
  Cc: dpenkler, gregkh, harshit.m.mogalapalli, kees, linux-kernel, sunliming

On Sat, May 16, 2026 at 11:12:27AM +0800, sunliming@web.codeaurora.org wrote:
> From: sunliming <sunliming@kylinos.cn>
> 
> Fix below smatch warnings:
> drivers/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c:808 usb_gpib_read() warn: was
> && intended here instead of ||?

This warning doesn't apply here where the two calls to one_char() return
different values.

It's meant to catch cases where the wrong operator is used so that a
condition is always true:

	(x != a || x != b) <=> !(x == a && x == b) <=> true	(a != b)

> Signed-off-by: sunliming <sunliming@kylinos.cn>
> ---
>  drivers/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c b/drivers/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c
> index e6ea9422d6f2..3e09f8226a56 100644
> --- a/drivers/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c
> +++ b/drivers/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c
> @@ -802,7 +802,7 @@ static int usb_gpib_read(struct gpib_board *board,
>  	if (retval < 0)
>  		goto read_return;
>  
> -	if (one_char(board, &b) != DLE || one_char(board, &b) != STX) {
> +	if (!(one_char(board, &b) == DLE && one_char(board, &b) == STX)) {

Whether one prefer one over the other here is just a matter of taste.

>  		dev_err(board->gpib_dev, "wrong <DLE><STX> sequence\n");
>  		retval = -EIO;
>  		goto read_return;

Johan

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH] gpib: lpvo_usb: rewrite DLE/STX sequence validation using !(A && B) for clarity
@ 2026-05-16  3:12 sunliming
  0 siblings, 0 replies; 2+ messages in thread
From: sunliming @ 2026-05-16  3:12 UTC (permalink / raw)
  To: dpenkler, gregkh
  Cc: johan, harshit.m.mogalapalli, kees, linux-kernel, sunliming

From: sunliming <sunliming@kylinos.cn>

Fix below smatch warnings:
drivers/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c:808 usb_gpib_read() warn: was
&& intended here instead of ||?

Signed-off-by: sunliming <sunliming@kylinos.cn>
---
 drivers/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c b/drivers/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c
index e6ea9422d6f2..3e09f8226a56 100644
--- a/drivers/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c
+++ b/drivers/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c
@@ -802,7 +802,7 @@ static int usb_gpib_read(struct gpib_board *board,
 	if (retval < 0)
 		goto read_return;
 
-	if (one_char(board, &b) != DLE || one_char(board, &b) != STX) {
+	if (!(one_char(board, &b) == DLE && one_char(board, &b) == STX)) {
 		dev_err(board->gpib_dev, "wrong <DLE><STX> sequence\n");
 		retval = -EIO;
 		goto read_return;
-- 
2.43.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-05-18 10:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <6a07e0f7.e59d1661.1cd5fe.6c90SMTPIN_ADDED_BROKEN@mx.google.com>
2026-05-18 10:56 ` [PATCH] gpib: lpvo_usb: rewrite DLE/STX sequence validation using !(A && B) for clarity Johan Hovold
2026-05-16  3:12 sunliming

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®