lkml.org 
[lkml]   [2022]   [Jun]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 13/36] tty/vt: consolemap: make con_set_unimap() more readable
Date
The indentation was completely broken in con_set_unimap(). Reorder the
code using 'if (!cond) continue;'s so that the code makes sense. Not
that it is perfect now, but it can be followed at least. More cleanup to
come. And remove all those useless whitespaces at the EOLs too.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
drivers/tty/vt/consolemap.c | 42 ++++++++++++++++++++-----------------
1 file changed, 23 insertions(+), 19 deletions(-)

diff --git a/drivers/tty/vt/consolemap.c b/drivers/tty/vt/consolemap.c
index 79a62dcca046..3730a1c0f223 100644
--- a/drivers/tty/vt/consolemap.c
+++ b/drivers/tty/vt/consolemap.c
@@ -580,23 +580,21 @@ int con_set_unimap(struct vc_data *vc, ushort ct, struct unipair __user *list)

/* Save original vc_unipagdir_loc in case we allocate a new one */
p = *vc->vc_uni_pagedir_loc;
-
if (!p) {
err = -EINVAL;
-
goto out_unlock;
}
-
+
if (p->refcount > 1) {
int j, k;
u16 **p1, *p2, l;
-
+
err1 = con_do_clear_unimap(vc);
if (err1) {
err = err1;
goto out_unlock;
}
-
+
/*
* Since refcount was > 1, con_clear_unimap() allocated a
* a new uni_pagedict for this vc. Re: p != q
@@ -611,13 +609,26 @@ int con_set_unimap(struct vc_data *vc, ushort ct, struct unipair __user *list)
*/
l = 0; /* unicode value */
for (i = 0; i < UNI_DIRS; i++) {
- p1 = p->uni_pgdir[i];
- if (p1)
+ p1 = p->uni_pgdir[i];
+ if (!p1) {
+ /* Account for empty table */
+ l += UNI_DIR_ROWS * UNI_ROW_GLYPHS;
+ continue;
+ }
+
for (j = 0; j < UNI_DIR_ROWS; j++) {
- p2 = p1[j];
- if (p2) {
- for (k = 0; k < UNI_ROW_GLYPHS; k++, l++)
- if (p2[k] != 0xffff) {
+ p2 = p1[j];
+ if (!p2) {
+ /*
+ * Account for row of 64 empty entries
+ */
+ l += UNI_ROW_GLYPHS;
+ continue;
+ }
+
+ for (k = 0; k < UNI_ROW_GLYPHS; k++, l++) {
+ if (p2[k] == 0xffff)
+ continue;
/*
* Found one, copy entry for unicode
* l with fontpos value p2[k].
@@ -632,15 +643,8 @@ int con_set_unimap(struct vc_data *vc, ushort ct, struct unipair __user *list)
goto out_unlock;
}
}
- } else {
- /* Account for row of 64 empty entries */
- l += UNI_ROW_GLYPHS;
}
}
- else
- /* Account for empty table */
- l += UNI_DIR_ROWS * UNI_ROW_GLYPHS;
- }

/*
* Finished copying font table, set vc_uni_pagedir to new table
@@ -658,7 +662,7 @@ int con_set_unimap(struct vc_data *vc, ushort ct, struct unipair __user *list)
if (err1)
err = err1;
}
-
+
/*
* Merge with fontmaps of any other virtual consoles.
*/
--
2.36.1
\
 
 \ /
  Last update: 2022-06-07 12:52    [W:0.315 / U:0.796 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site