Skip to content

Commit 101f227

Browse files
Jiri Slabygregkh
authored andcommitted
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: Jiri Slaby <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent ba08cf4 commit 101f227

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

drivers/tty/vt/selection.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,9 @@ int set_selection_kernel(struct tiocl_selection *v, struct tty_struct *tty)
191191
struct vc_data *vc = vc_cons[fg_console].d;
192192
int new_sel_start, new_sel_end, spc;
193193
char *bp, *obp;
194-
int i, ps, pe, multiplier;
194+
int i, ps, pe;
195195
u32 c;
196-
int mode, ret = 0;
196+
int ret = 0;
197197

198198
poke_blanked_console();
199199

@@ -224,11 +224,7 @@ int set_selection_kernel(struct tiocl_selection *v, struct tty_struct *tty)
224224
clear_selection();
225225
sel_cons = vc_cons[fg_console].d;
226226
}
227-
mode = vt_do_kdgkbmode(fg_console);
228-
if (mode == K_UNICODE)
229-
use_unicode = 1;
230-
else
231-
use_unicode = 0;
227+
use_unicode = vt_do_kdgkbmode(fg_console) == K_UNICODE;
232228

233229
switch (v->sel_mode)
234230
{
@@ -312,8 +308,8 @@ int set_selection_kernel(struct tiocl_selection *v, struct tty_struct *tty)
312308
sel_end = new_sel_end;
313309

314310
/* Allocate a new buffer before freeing the old one ... */
315-
multiplier = use_unicode ? 4 : 1; /* chars can take up to 4 bytes */
316-
bp = kmalloc_array((sel_end - sel_start) / 2 + 1, multiplier,
311+
/* chars can take up to 4 bytes with unicode */
312+
bp = kmalloc_array((sel_end - sel_start) / 2 + 1, use_unicode ? 4 : 1,
317313
GFP_KERNEL);
318314
if (!bp) {
319315
printk(KERN_WARNING "selection: kmalloc() failed\n");

0 commit comments

Comments
 (0)