Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tty/vt: consolemap: make parameters of inverse_translate() saner

- int use_unicode -> bool: it's used as bool at some places already, so
make it explicit.
- int glyph -> u16: every caller passes a u16 in. So make it explicit
too. And remove a negative check from inverse_translate() as it never
could be negative.

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20220607104946.18710-7-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jiri Slaby and committed by
Greg Kroah-Hartman
d9ebb906 f827c754

+10 -9
+1 -1
drivers/accessibility/braille/braille_console.c
··· 131 131 for (i = 0; i < WIDTH; i++) { 132 132 u16 glyph = screen_glyph(vc, 133 133 2 * (vc_x + i) + vc_y * vc->vc_size_row); 134 - buf[i] = inverse_translate(vc, glyph, 1); 134 + buf[i] = inverse_translate(vc, glyph, true); 135 135 } 136 136 braille_write(buf); 137 137 }
+1 -1
drivers/accessibility/speakup/main.c
··· 470 470 c |= 0x100; 471 471 } 472 472 473 - ch = inverse_translate(vc, c, 1); 473 + ch = inverse_translate(vc, c, true); 474 474 *attribs = (w & 0xff00) >> 8; 475 475 } 476 476 return ch;
+2 -2
drivers/tty/vt/consolemap.c
··· 281 281 * was active. 282 282 * Still, it is now possible to a certain extent to cut and paste non-ASCII. 283 283 */ 284 - u16 inverse_translate(const struct vc_data *conp, int glyph, int use_unicode) 284 + u16 inverse_translate(const struct vc_data *conp, u16 glyph, bool use_unicode) 285 285 { 286 286 struct uni_pagedict *p; 287 287 int m; 288 288 289 - if (glyph < 0 || glyph >= MAX_GLYPH) 289 + if (glyph >= MAX_GLYPH) 290 290 return 0; 291 291 292 292 p = *conp->vc_uni_pagedir_loc;
+2 -1
drivers/tty/vt/selection.c
··· 68 68 { 69 69 if (unicode) 70 70 return screen_glyph_unicode(vc_sel.cons, n / 2); 71 - return inverse_translate(vc_sel.cons, screen_glyph(vc_sel.cons, n), 0); 71 + return inverse_translate(vc_sel.cons, screen_glyph(vc_sel.cons, n), 72 + false); 72 73 } 73 74 74 75 /**
+1 -1
drivers/tty/vt/vt.c
··· 4741 4741 4742 4742 if (uniscr) 4743 4743 return uniscr->lines[n / vc->vc_cols][n % vc->vc_cols]; 4744 - return inverse_translate(vc, screen_glyph(vc, n * 2), 1); 4744 + return inverse_translate(vc, screen_glyph(vc, n * 2), true); 4745 4745 } 4746 4746 EXPORT_SYMBOL_GPL(screen_glyph_unicode); 4747 4747
+3 -3
include/linux/consolemap.h
··· 17 17 struct vc_data; 18 18 19 19 #ifdef CONFIG_CONSOLE_TRANSLATIONS 20 - u16 inverse_translate(const struct vc_data *conp, int glyph, int use_unicode); 20 + u16 inverse_translate(const struct vc_data *conp, u16 glyph, bool use_unicode); 21 21 unsigned short *set_translate(int m, struct vc_data *vc); 22 22 int conv_uni_to_pc(struct vc_data *conp, long ucs); 23 23 u32 conv_8bit_to_uni(unsigned char c); 24 24 int conv_uni_to_8bit(u32 uni); 25 25 void console_map_init(void); 26 26 #else 27 - static inline u16 inverse_translate(const struct vc_data *conp, int glyph, 28 - int use_unicode) 27 + static inline u16 inverse_translate(const struct vc_data *conp, u16 glyph, 28 + bool use_unicode) 29 29 { 30 30 return glyph; 31 31 }