vt_ioctl: eliminate use of uival and ucval

They were used for the first parameter of put_user. But put_user accepts
constants in the parameter and also determines the type only by the
second parameter. So we can safely drop these helpers and simplify the
code a bit.

Including the removal of set_int label.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20200615074910.19267-30-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Jiri Slaby 2020-06-15 09:49:02 +02:00 committed by Greg Kroah-Hartman
parent 0ce8179e24
commit eca734d8f0

View File

@ -353,8 +353,6 @@ int vt_ioctl(struct tty_struct *tty,
struct vc_data *vc = tty->driver_data; struct vc_data *vc = tty->driver_data;
struct console_font_op op; /* used in multiple places here */ struct console_font_op op; /* used in multiple places here */
unsigned int console = vc->vc_num; unsigned int console = vc->vc_num;
unsigned char ucval;
unsigned int uival;
void __user *up = (void __user *)arg; void __user *up = (void __user *)arg;
int i, perm; int i, perm;
int ret; int ret;
@ -406,8 +404,7 @@ int vt_ioctl(struct tty_struct *tty,
/* /*
* this is naïve. * this is naïve.
*/ */
ucval = KB_101; return put_user(KB_101, (char __user *)arg);
return put_user(ucval, (char __user *)arg);
/* /*
* These cannot be implemented on any machine that implements * These cannot be implemented on any machine that implements
@ -495,8 +492,7 @@ int vt_ioctl(struct tty_struct *tty,
break; break;
case KDGETMODE: case KDGETMODE:
uival = vc->vc_mode; return put_user(vc->vc_mode, (int __user *)arg);
goto setint;
case KDMAPDISP: case KDMAPDISP:
case KDUNMAPDISP: case KDUNMAPDISP:
@ -516,8 +512,7 @@ int vt_ioctl(struct tty_struct *tty,
break; break;
case KDGKBMODE: case KDGKBMODE:
uival = vt_do_kdgkbmode(console); return put_user(vt_do_kdgkbmode(console), (int __user *)arg);
return put_user(uival, (int __user *)arg);
/* this could be folded into KDSKBMODE, but for compatibility /* this could be folded into KDSKBMODE, but for compatibility
reasons it is not so easy to fold KDGKBMETA into KDGKBMODE */ reasons it is not so easy to fold KDGKBMETA into KDGKBMODE */
@ -526,9 +521,7 @@ int vt_ioctl(struct tty_struct *tty,
case KDGKBMETA: case KDGKBMETA:
/* FIXME: should review whether this is worth locking */ /* FIXME: should review whether this is worth locking */
uival = vt_do_kdgkbmeta(console); return put_user(vt_do_kdgkbmeta(console), (int __user *)arg);
setint:
return put_user(uival, (int __user *)arg);
case KDGETKEYCODE: case KDGETKEYCODE:
case KDSETKEYCODE: case KDSETKEYCODE:
@ -650,8 +643,8 @@ int vt_ioctl(struct tty_struct *tty,
if (!vt_in_use(i)) if (!vt_in_use(i))
break; break;
console_unlock(); console_unlock();
uival = i < MAX_NR_CONSOLES ? (i+1) : -1; i = i < MAX_NR_CONSOLES ? (i+1) : -1;
goto setint; return put_user(i, (int __user *)arg);
/* /*
* ioctl(fd, VT_ACTIVATE, num) will cause us to switch to vt # num, * ioctl(fd, VT_ACTIVATE, num) will cause us to switch to vt # num,