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

tty/vt: consolemap: make conv_uni_to_pc() more readable

1) Fetch *conp->vc_uni_pagedir_loc first and do the NULL check on the local
   variable.
2) Decouple the large "if" into few smaller "if"s.
3) Remove a \n from the definition line.

This makes the code more readable.
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20220607104946.18710-31-jslaby@suse.czSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 1a086f5d
...@@ -849,8 +849,7 @@ int conv_uni_to_8bit(u32 uni) ...@@ -849,8 +849,7 @@ int conv_uni_to_8bit(u32 uni)
return -1; return -1;
} }
int int conv_uni_to_pc(struct vc_data *conp, long ucs)
conv_uni_to_pc(struct vc_data *conp, long ucs)
{ {
struct uni_pagedict *dict; struct uni_pagedict *dict;
u16 **dir, *row, glyph; u16 **dir, *row, glyph;
...@@ -869,17 +868,24 @@ conv_uni_to_pc(struct vc_data *conp, long ucs) ...@@ -869,17 +868,24 @@ conv_uni_to_pc(struct vc_data *conp, long ucs)
*/ */
else if ((ucs & ~UNI_DIRECT_MASK) == UNI_DIRECT_BASE) else if ((ucs & ~UNI_DIRECT_MASK) == UNI_DIRECT_BASE)
return ucs & UNI_DIRECT_MASK; return ucs & UNI_DIRECT_MASK;
if (!*conp->vc_uni_pagedir_loc)
return -3;
dict = *conp->vc_uni_pagedir_loc; dict = *conp->vc_uni_pagedir_loc;
if ((dir = dict->uni_pgdir[UNI_DIR(ucs)]) && if (!dict)
(row = dir[UNI_ROW(ucs)]) && return -3;
(glyph = row[UNI_GLYPH(ucs)]) < MAX_GLYPH)
return glyph; dir = dict->uni_pgdir[UNI_DIR(ucs)];
if (!dir)
return -4;
row = dir[UNI_ROW(ucs)];
if (!row)
return -4;
glyph = row[UNI_GLYPH(ucs)];
if (glyph >= MAX_GLYPH)
return -4;
return -4; /* not found */ 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