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

tty/vt: consolemap: saner variable names in con_unshare_unimap()

The function uses too vague variable names like i, j, k for iterators, p,
q, p1, p2 for pointers etc.

Rename all these, so that it is clear what is going on:
- dict: for dictionaries.
- d, r, g: for dir, row, glyph iterators -- these are unsigned now.
- dir, row: for directory and row pointers.
- glyph: for the glyph.
- and so on...

This is a lot of shuffling, but the result pays off, IMO.
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20220607104946.18710-25-jslaby@suse.czSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 01ddc0da
...@@ -562,12 +562,12 @@ int con_clear_unimap(struct vc_data *vc) ...@@ -562,12 +562,12 @@ int con_clear_unimap(struct vc_data *vc)
} }
static struct uni_pagedict *con_unshare_unimap(struct vc_data *vc, static struct uni_pagedict *con_unshare_unimap(struct vc_data *vc,
struct uni_pagedict *p) struct uni_pagedict *old)
{ {
struct uni_pagedict *q; struct uni_pagedict *new;
u16 **p1, *p2, l; unsigned int d, r, g;
int ret; int ret;
int i, j, k; u16 uni = 0;
ret = con_do_clear_unimap(vc); ret = con_do_clear_unimap(vc);
if (ret) if (ret)
...@@ -575,52 +575,51 @@ static struct uni_pagedict *con_unshare_unimap(struct vc_data *vc, ...@@ -575,52 +575,51 @@ static struct uni_pagedict *con_unshare_unimap(struct vc_data *vc,
/* /*
* Since refcount was > 1, con_clear_unimap() allocated a new * Since refcount was > 1, con_clear_unimap() allocated a new
* uni_pagedict for this vc. Re: p != q * uni_pagedict for this vc. Re: old != new
*/ */
q = *vc->vc_uni_pagedir_loc; new = *vc->vc_uni_pagedir_loc;
/* /*
* uni_pgdir is a 32*32*64 table with rows allocated when its first * uni_pgdir is a 32*32*64 table with rows allocated when its first
* entry is added. The unicode value must still be incremented for * entry is added. The unicode value must still be incremented for
* empty rows. We are copying entries from "p" (old) to "q" (new). * empty rows. We are copying entries from "old" to "new".
*/ */
l = 0; /* unicode value */ for (d = 0; d < UNI_DIRS; d++) {
for (i = 0; i < UNI_DIRS; i++) { u16 **dir = old->uni_pgdir[d];
p1 = p->uni_pgdir[i]; if (!dir) {
if (!p1) {
/* Account for empty table */ /* Account for empty table */
l += UNI_DIR_ROWS * UNI_ROW_GLYPHS; uni += UNI_DIR_ROWS * UNI_ROW_GLYPHS;
continue; continue;
} }
for (j = 0; j < UNI_DIR_ROWS; j++) { for (r = 0; r < UNI_DIR_ROWS; r++) {
p2 = p1[j]; u16 *row = dir[r];
if (!p2) { if (!row) {
/* Account for row of 64 empty entries */ /* Account for row of 64 empty entries */
l += UNI_ROW_GLYPHS; uni += UNI_ROW_GLYPHS;
continue; continue;
} }
for (k = 0; k < UNI_ROW_GLYPHS; k++, l++) { for (g = 0; g < UNI_ROW_GLYPHS; g++, uni++) {
if (p2[k] == 0xffff) if (row[g] == 0xffff)
continue; continue;
/* /*
* Found one, copy entry for unicode l with * Found one, copy entry for unicode uni with
* fontpos value p2[k]. * fontpos value row[g].
*/ */
ret = con_insert_unipair(q, l, p2[k]); ret = con_insert_unipair(new, uni, row[g]);
if (ret) { if (ret) {
p->refcount++; old->refcount++;
*vc->vc_uni_pagedir_loc = p; *vc->vc_uni_pagedir_loc = old;
con_release_unimap(q); con_release_unimap(new);
kfree(q); kfree(new);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
} }
} }
} }
return q; return new;
} }
int con_set_unimap(struct vc_data *vc, ushort ct, struct unipair __user *list) int con_set_unimap(struct vc_data *vc, ushort ct, struct unipair __user *list)
......
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