Commit 101f227c authored by Jiri Slaby's avatar Jiri Slaby Committed by Greg Kroah-Hartman

vt: selection, remove 2 local variables from set_selection_kernel

multiplier and mode are not actually needed:
* multiplier is used only in kmalloc_array, so use "use_unicode ? 4 : 1"
  directly
* mode is used only to assign a bool in this manner:
  if (cond)
    x = true;
  else
    x = false;
  So do "x = cond" directly.
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20200219073951.16151-3-jslaby@suse.czSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent ba08cf45
...@@ -191,9 +191,9 @@ int set_selection_kernel(struct tiocl_selection *v, struct tty_struct *tty) ...@@ -191,9 +191,9 @@ int set_selection_kernel(struct tiocl_selection *v, struct tty_struct *tty)
struct vc_data *vc = vc_cons[fg_console].d; struct vc_data *vc = vc_cons[fg_console].d;
int new_sel_start, new_sel_end, spc; int new_sel_start, new_sel_end, spc;
char *bp, *obp; char *bp, *obp;
int i, ps, pe, multiplier; int i, ps, pe;
u32 c; u32 c;
int mode, ret = 0; int ret = 0;
poke_blanked_console(); poke_blanked_console();
...@@ -224,11 +224,7 @@ int set_selection_kernel(struct tiocl_selection *v, struct tty_struct *tty) ...@@ -224,11 +224,7 @@ int set_selection_kernel(struct tiocl_selection *v, struct tty_struct *tty)
clear_selection(); clear_selection();
sel_cons = vc_cons[fg_console].d; sel_cons = vc_cons[fg_console].d;
} }
mode = vt_do_kdgkbmode(fg_console); use_unicode = vt_do_kdgkbmode(fg_console) == K_UNICODE;
if (mode == K_UNICODE)
use_unicode = 1;
else
use_unicode = 0;
switch (v->sel_mode) switch (v->sel_mode)
{ {
...@@ -312,8 +308,8 @@ int set_selection_kernel(struct tiocl_selection *v, struct tty_struct *tty) ...@@ -312,8 +308,8 @@ int set_selection_kernel(struct tiocl_selection *v, struct tty_struct *tty)
sel_end = new_sel_end; sel_end = new_sel_end;
/* Allocate a new buffer before freeing the old one ... */ /* Allocate a new buffer before freeing the old one ... */
multiplier = use_unicode ? 4 : 1; /* chars can take up to 4 bytes */ /* chars can take up to 4 bytes with unicode */
bp = kmalloc_array((sel_end - sel_start) / 2 + 1, multiplier, bp = kmalloc_array((sel_end - sel_start) / 2 + 1, use_unicode ? 4 : 1,
GFP_KERNEL); GFP_KERNEL);
if (!bp) { if (!bp) {
printk(KERN_WARNING "selection: kmalloc() failed\n"); printk(KERN_WARNING "selection: kmalloc() failed\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment