From: Max Brener <linmaxi@gmail.com>
To: dmitry.torokhov@gmail.com
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
Max Brener <linmaxi@gmail.com>
Subject: [PATCH] Input: libps2 - embed WARN_ON(1) macros into their enclosing if statements
Date: Sat, 14 Feb 2026 22:37:24 +0200 [thread overview]
Message-ID: <20260214203725.6463-1-linmaxi@gmail.com> (raw)
Make WARN_ON(1) statements embedded inside their respective 'if' expressions,
to improve code clarity.
Signed-off-by: Max Brener <linmaxi@gmail.com>
---
drivers/input/serio/libps2.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/drivers/input/serio/libps2.c b/drivers/input/serio/libps2.c
index 269df83a167d..05b64277aecd 100644
--- a/drivers/input/serio/libps2.c
+++ b/drivers/input/serio/libps2.c
@@ -154,10 +154,8 @@ EXPORT_SYMBOL(ps2_end_command);
*/
void ps2_drain(struct ps2dev *ps2dev, size_t maxbytes, unsigned int timeout)
{
- if (maxbytes > sizeof(ps2dev->cmdbuf)) {
- WARN_ON(1);
+ if (WARN_ON(maxbytes > sizeof(ps2dev->cmdbuf)))
maxbytes = sizeof(ps2dev->cmdbuf);
- }
ps2_begin_command(ps2dev);
@@ -270,15 +268,11 @@ int __ps2_command(struct ps2dev *ps2dev, u8 *param, unsigned int command)
int i;
u8 send_param[16];
- if (receive > sizeof(ps2dev->cmdbuf)) {
- WARN_ON(1);
+ if (WARN_ON(receive > sizeof(ps2dev->cmdbuf)))
return -EINVAL;
- }
- if (send && !param) {
- WARN_ON(1);
+ if (WARN_ON(send && !param))
return -EINVAL;
- }
memcpy(send_param, param, send);
--
2.43.0
next reply other threads:[~2026-02-14 20:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-14 20:37 Max Brener [this message]
2026-02-17 18:07 ` [PATCH] Input: libps2 - embed WARN_ON(1) macros into their enclosing if statements Dmitry Torokhov
-- strict thread matches above, loose matches on Subject: below --
2026-02-05 17:27 Max Brener
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=20260214203725.6463-1-linmaxi@gmail.com \
--to=linmaxi@gmail.com \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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