summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2022-06-07 13:49:23 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-06-10 14:37:01 +0300
commit6e4e8d74664a2bf46c74dfcf0d8a600acbbc4d6d (patch)
treecf7df5ae0e0b107bac7814c063d6c10a9903bd5e /drivers
parentacf90b4d52e6965cbc3b115a68e0f063f703719c (diff)
downloadlinux-6e4e8d74664a2bf46c74dfcf0d8a600acbbc4d6d.tar.xz
tty/vt: consolemap: make con_set_unimap() more readable
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. 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-13-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/tty/vt/consolemap.c42
1 files 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.
*/