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

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: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20220607104946.18710-7-jslaby@suse.czSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f827c754
...@@ -131,7 +131,7 @@ static void vc_refresh(struct vc_data *vc) ...@@ -131,7 +131,7 @@ static void vc_refresh(struct vc_data *vc)
for (i = 0; i < WIDTH; i++) { for (i = 0; i < WIDTH; i++) {
u16 glyph = screen_glyph(vc, u16 glyph = screen_glyph(vc,
2 * (vc_x + i) + vc_y * vc->vc_size_row); 2 * (vc_x + i) + vc_y * vc->vc_size_row);
buf[i] = inverse_translate(vc, glyph, 1); buf[i] = inverse_translate(vc, glyph, true);
} }
braille_write(buf); braille_write(buf);
} }
......
...@@ -470,7 +470,7 @@ static u16 get_char(struct vc_data *vc, u16 *pos, u_char *attribs) ...@@ -470,7 +470,7 @@ static u16 get_char(struct vc_data *vc, u16 *pos, u_char *attribs)
c |= 0x100; c |= 0x100;
} }
ch = inverse_translate(vc, c, 1); ch = inverse_translate(vc, c, true);
*attribs = (w & 0xff00) >> 8; *attribs = (w & 0xff00) >> 8;
} }
return ch; return ch;
......
...@@ -281,12 +281,12 @@ unsigned short *set_translate(int m, struct vc_data *vc) ...@@ -281,12 +281,12 @@ unsigned short *set_translate(int m, struct vc_data *vc)
* was active. * was active.
* Still, it is now possible to a certain extent to cut and paste non-ASCII. * Still, it is now possible to a certain extent to cut and paste non-ASCII.
*/ */
u16 inverse_translate(const struct vc_data *conp, int glyph, int use_unicode) u16 inverse_translate(const struct vc_data *conp, u16 glyph, bool use_unicode)
{ {
struct uni_pagedict *p; struct uni_pagedict *p;
int m; int m;
if (glyph < 0 || glyph >= MAX_GLYPH) if (glyph >= MAX_GLYPH)
return 0; return 0;
p = *conp->vc_uni_pagedir_loc; p = *conp->vc_uni_pagedir_loc;
......
...@@ -68,7 +68,8 @@ sel_pos(int n, bool unicode) ...@@ -68,7 +68,8 @@ sel_pos(int n, bool unicode)
{ {
if (unicode) if (unicode)
return screen_glyph_unicode(vc_sel.cons, n / 2); return screen_glyph_unicode(vc_sel.cons, n / 2);
return inverse_translate(vc_sel.cons, screen_glyph(vc_sel.cons, n), 0); return inverse_translate(vc_sel.cons, screen_glyph(vc_sel.cons, n),
false);
} }
/** /**
......
...@@ -4741,7 +4741,7 @@ u32 screen_glyph_unicode(const struct vc_data *vc, int n) ...@@ -4741,7 +4741,7 @@ u32 screen_glyph_unicode(const struct vc_data *vc, int n)
if (uniscr) if (uniscr)
return uniscr->lines[n / vc->vc_cols][n % vc->vc_cols]; return uniscr->lines[n / vc->vc_cols][n % vc->vc_cols];
return inverse_translate(vc, screen_glyph(vc, n * 2), 1); return inverse_translate(vc, screen_glyph(vc, n * 2), true);
} }
EXPORT_SYMBOL_GPL(screen_glyph_unicode); EXPORT_SYMBOL_GPL(screen_glyph_unicode);
......
...@@ -17,15 +17,15 @@ ...@@ -17,15 +17,15 @@
struct vc_data; struct vc_data;
#ifdef CONFIG_CONSOLE_TRANSLATIONS #ifdef CONFIG_CONSOLE_TRANSLATIONS
u16 inverse_translate(const struct vc_data *conp, int glyph, int use_unicode); u16 inverse_translate(const struct vc_data *conp, u16 glyph, bool use_unicode);
unsigned short *set_translate(int m, struct vc_data *vc); unsigned short *set_translate(int m, struct vc_data *vc);
int conv_uni_to_pc(struct vc_data *conp, long ucs); int conv_uni_to_pc(struct vc_data *conp, long ucs);
u32 conv_8bit_to_uni(unsigned char c); u32 conv_8bit_to_uni(unsigned char c);
int conv_uni_to_8bit(u32 uni); int conv_uni_to_8bit(u32 uni);
void console_map_init(void); void console_map_init(void);
#else #else
static inline u16 inverse_translate(const struct vc_data *conp, int glyph, static inline u16 inverse_translate(const struct vc_data *conp, u16 glyph,
int use_unicode) bool use_unicode)
{ {
return glyph; return glyph;
} }
......
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