public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Input: libps2 - embed WARN_ON(1) macros into their enclosing if statements
@ 2026-02-14 20:37 Max Brener
  2026-02-17 18:07 ` Dmitry Torokhov
  0 siblings, 1 reply; 3+ messages in thread
From: Max Brener @ 2026-02-14 20:37 UTC (permalink / raw)
  To: dmitry.torokhov; +Cc: linux-input, linux-kernel, Max Brener

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread
* [PATCH] Input: libps2 - embed WARN_ON(1) macros into their enclosing if statements
@ 2026-02-05 17:27 Max Brener
  0 siblings, 0 replies; 3+ messages in thread
From: Max Brener @ 2026-02-05 17:27 UTC (permalink / raw)
  To: dmitry.torokhov; +Cc: linux-input, linux-kernel, Max Brener

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


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

end of thread, other threads:[~2026-02-17 18:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-14 20:37 [PATCH] Input: libps2 - embed WARN_ON(1) macros into their enclosing if statements Max Brener
2026-02-17 18:07 ` Dmitry Torokhov
  -- strict thread matches above, loose matches on Subject: below --
2026-02-05 17:27 Max Brener

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