summaryrefslogtreecommitdiff
path: root/drivers/tty/vt
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2022-06-07 13:49:24 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-06-10 14:37:02 +0300
commit6364d391363a0ac498a852ff4bec32d82e913ee8 (patch)
treeabdf874a2c944af54460be2f9d4e24342571faf6 /drivers/tty/vt
parent6e4e8d74664a2bf46c74dfcf0d8a600acbbc4d6d (diff)
downloadlinux-6364d391363a0ac498a852ff4bec32d82e913ee8.tar.xz
tty/vt: consolemap: make con_get_unimap() more readable
The indentation is completely broken in con_get_unimap(). Reorder the code using "if (!cond) continue;"s so that the code makes sense. Switch also the "p" assignment and add a short path using goto. This makes the code readable again. 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-14-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/vt')
-rw-r--r--drivers/tty/vt/consolemap.c38
1 files changed, 22 insertions, 16 deletions
diff --git a/drivers/tty/vt/consolemap.c b/drivers/tty/vt/consolemap.c
index 3730a1c0f223..84c8043a36d0 100644
--- a/drivers/tty/vt/consolemap.c
+++ b/drivers/tty/vt/consolemap.c
@@ -768,7 +768,8 @@ EXPORT_SYMBOL(con_copy_unimap);
* Read the console unicode data for this console. Called from the ioctl
* handlers.
*/
-int con_get_unimap(struct vc_data *vc, ushort ct, ushort __user *uct, struct unipair __user *list)
+int con_get_unimap(struct vc_data *vc, ushort ct, ushort __user *uct,
+ struct unipair __user *list)
{
int i, j, k, ret = 0;
ushort ect;
@@ -783,27 +784,32 @@ int con_get_unimap(struct vc_data *vc, ushort ct, ushort __user *uct, struct uni
console_lock();
ect = 0;
- if (*vc->vc_uni_pagedir_loc) {
- p = *vc->vc_uni_pagedir_loc;
- for (i = 0; i < UNI_DIRS; i++) {
+ p = *vc->vc_uni_pagedir_loc;
+ if (!p)
+ goto unlock;
+
+ for (i = 0; i < UNI_DIRS; i++) {
p1 = p->uni_pgdir[i];
- if (p1)
- for (j = 0; j < UNI_DIR_ROWS; j++) {
+ if (!p1)
+ continue;
+
+ for (j = 0; j < UNI_DIR_ROWS; j++) {
p2 = *(p1++);
- if (p2)
- for (k = 0; k < UNI_ROW_GLYPHS; k++, p2++) {
- if (*p2 >= MAX_GLYPH)
- continue;
- if (ect < ct) {
- unilist[ect].unicode =
- UNI(i, j, k);
- unilist[ect].fontpos = *p2;
- }
- ect++;
+ if (!p2)
+ continue;
+
+ for (k = 0; k < UNI_ROW_GLYPHS; k++, p2++) {
+ if (*p2 >= MAX_GLYPH)
+ continue;
+ if (ect < ct) {
+ unilist[ect].unicode = UNI(i, j, k);
+ unilist[ect].fontpos = *p2;
}
+ ect++;
}
}
}
+unlock:
console_unlock();
if (copy_to_user(list, unilist, min(ect, ct) * sizeof(*unilist)))
ret = -EFAULT;