From: Johan Hovold <johan@kernel.org>
To: sunliming@web.codeaurora.org
Cc: dpenkler@gmail.com, gregkh@linuxfoundation.org,
harshit.m.mogalapalli@oracle.com, kees@kernel.org,
linux-kernel@vger.kernel.org, sunliming <sunliming@kylinos.cn>
Subject: Re: [PATCH] gpib: lpvo_usb: rewrite DLE/STX sequence validation using !(A && B) for clarity
Date: Mon, 18 May 2026 12:56:40 +0200 [thread overview]
Message-ID: <agrwaJgFDeHgJOdY@hovoldconsulting.com> (raw)
In-Reply-To: <6a07e0f7.e59d1661.1cd5fe.6c90SMTPIN_ADDED_BROKEN@mx.google.com>
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
next parent reply other threads:[~2026-05-18 10:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <6a07e0f7.e59d1661.1cd5fe.6c90SMTPIN_ADDED_BROKEN@mx.google.com>
2026-05-18 10:56 ` Johan Hovold [this message]
2026-05-16 3:12 sunliming
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=agrwaJgFDeHgJOdY@hovoldconsulting.com \
--to=johan@kernel.org \
--cc=dpenkler@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=harshit.m.mogalapalli@oracle.com \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sunliming@kylinos.cn \
--cc=sunliming@web.codeaurora.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®