Skip to content

Commit d139b31

Browse files
Jiri Slaby (SUSE)gregkh
authored andcommitted
tty: vt/keyboard: simplify returns from vt_do_kbkeycode_ioctl()
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> Link: https://patch.msgid.link/20251119100140.830761-8-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent bfb2456 commit d139b31

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

drivers/tty/vt/keyboard.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1879,27 +1879,27 @@ int vt_do_kdskbmeta(unsigned int console, unsigned int arg)
18791879
return ret;
18801880
}
18811881

1882-
int vt_do_kbkeycode_ioctl(int cmd, struct kbkeycode __user *user_kbkc,
1883-
int perm)
1882+
int vt_do_kbkeycode_ioctl(int cmd, struct kbkeycode __user *user_kbkc, int perm)
18841883
{
18851884
struct kbkeycode tmp;
1886-
int kc = 0;
1885+
int kc;
18871886

18881887
if (copy_from_user(&tmp, user_kbkc, sizeof(struct kbkeycode)))
18891888
return -EFAULT;
1889+
18901890
switch (cmd) {
18911891
case KDGETKEYCODE:
18921892
kc = getkeycode(tmp.scancode);
1893-
if (kc >= 0)
1894-
kc = put_user(kc, &user_kbkc->keycode);
1895-
break;
1893+
if (kc < 0)
1894+
return kc;
1895+
return put_user(kc, &user_kbkc->keycode);
18961896
case KDSETKEYCODE:
18971897
if (!perm)
18981898
return -EPERM;
1899-
kc = setkeycode(tmp.scancode, tmp.keycode);
1900-
break;
1899+
return setkeycode(tmp.scancode, tmp.keycode);
19011900
}
1902-
return kc;
1901+
1902+
return 0;
19031903
}
19041904

19051905
static unsigned short vt_kdgkbent(unsigned char kbdmode, unsigned char idx,

0 commit comments

Comments
 (0)