public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
To: gregkh@linuxfoundation.org
Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Subject: [PATCH 07/10] tty: vt/keyboard: simplify returns from vt_do_kbkeycode_ioctl()
Date: Wed, 19 Nov 2025 11:01:37 +0100	[thread overview]
Message-ID: <20251119100140.830761-8-jirislaby@kernel.org> (raw)
In-Reply-To: <20251119100140.830761-1-jirislaby@kernel.org>

Return immediately when something goes wrong in vt_do_kbkeycode_ioctl().
This makes the code flow more obvious.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
---
 drivers/tty/vt/keyboard.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
index 65913a137862..487518a696e6 100644
--- a/drivers/tty/vt/keyboard.c
+++ b/drivers/tty/vt/keyboard.c
@@ -1879,27 +1879,27 @@ int vt_do_kdskbmeta(unsigned int console, unsigned int arg)
 	return ret;
 }
 
-int vt_do_kbkeycode_ioctl(int cmd, struct kbkeycode __user *user_kbkc,
-								int perm)
+int vt_do_kbkeycode_ioctl(int cmd, struct kbkeycode __user *user_kbkc, int perm)
 {
 	struct kbkeycode tmp;
-	int kc = 0;
+	int kc;
 
 	if (copy_from_user(&tmp, user_kbkc, sizeof(struct kbkeycode)))
 		return -EFAULT;
+
 	switch (cmd) {
 	case KDGETKEYCODE:
 		kc = getkeycode(tmp.scancode);
-		if (kc >= 0)
-			kc = put_user(kc, &user_kbkc->keycode);
-		break;
+		if (kc < 0)
+			return kc;
+		return put_user(kc, &user_kbkc->keycode);
 	case KDSETKEYCODE:
 		if (!perm)
 			return -EPERM;
-		kc = setkeycode(tmp.scancode, tmp.keycode);
-		break;
+		return setkeycode(tmp.scancode, tmp.keycode);
 	}
-	return kc;
+
+	return 0;
 }
 
 static unsigned short vt_kdgkbent(unsigned char kbdmode, unsigned char idx,
-- 
2.51.1


  parent reply	other threads:[~2025-11-19 10:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-19 10:01 [PATCH 00/10] tty: another batch of conversions to guards Jiri Slaby (SUSE)
2025-11-19 10:01 ` [PATCH 01/10] tty: pty: use guard()s Jiri Slaby (SUSE)
2025-11-19 10:01 ` [PATCH 02/10] tty: n_tty: " Jiri Slaby (SUSE)
2025-11-19 10:01 ` [PATCH 03/10] tty: n_hdlc: simplify return from n_hdlc_tty_ioctl() Jiri Slaby (SUSE)
2025-11-19 10:01 ` [PATCH 04/10] tty: n_hdlc: use guard()s Jiri Slaby (SUSE)
2025-11-19 10:01 ` [PATCH 05/10] tty: moxa: " Jiri Slaby (SUSE)
2025-11-19 10:01 ` [PATCH 06/10] tty: vt/keyboard: use __free() Jiri Slaby (SUSE)
2025-11-19 10:01 ` Jiri Slaby (SUSE) [this message]
2025-11-19 10:01 ` [PATCH 08/10] tty: vt/keyboard: use guard()s Jiri Slaby (SUSE)
2025-11-19 10:01 ` [PATCH 09/10] serial: serial_core: simplify uart_ioctl() returns Jiri Slaby (SUSE)
2025-11-19 10:01 ` [PATCH 10/10] serial: serial_core: use guard()s Jiri Slaby (SUSE)

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=20251119100140.830761-8-jirislaby@kernel.org \
    --to=jirislaby@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@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