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

vt: keyboard, rename i to kb_func in vt_do_kdgkb_ioctl

There are too many one-letter variables in vt_do_kdgkb_ioctl which is
rather confusing.  Rename 'i' to 'kb_func' and change its type to be the
same as its originating value (struct kbsentry.kb_func) -- unsigned
char.
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20201029113222.32640-10-jslaby@suse.czSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent fe45d657
...@@ -2026,9 +2026,10 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm) ...@@ -2026,9 +2026,10 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
int sz, fnw_sz; int sz, fnw_sz;
int delta; int delta;
char *first_free, *fj, *fnw; char *first_free, *fj, *fnw;
int i, j, k; int j, k;
int ret; int ret;
unsigned long flags; unsigned long flags;
unsigned char kb_func;
if (!capable(CAP_SYS_TTY_CONFIG)) if (!capable(CAP_SYS_TTY_CONFIG))
perm = 0; perm = 0;
...@@ -2045,7 +2046,7 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm) ...@@ -2045,7 +2046,7 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
goto reterr; goto reterr;
} }
kbs->kb_string[sizeof(kbs->kb_string)-1] = '\0'; kbs->kb_string[sizeof(kbs->kb_string)-1] = '\0';
i = array_index_nospec(kbs->kb_func, MAX_NR_FUNC); kb_func = array_index_nospec(kbs->kb_func, MAX_NR_FUNC);
switch (cmd) { switch (cmd) {
case KDGKBSENT: { case KDGKBSENT: {
...@@ -2053,7 +2054,7 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm) ...@@ -2053,7 +2054,7 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
ssize_t len = sizeof(user_kdgkb->kb_string); ssize_t len = sizeof(user_kdgkb->kb_string);
spin_lock_irqsave(&func_buf_lock, flags); spin_lock_irqsave(&func_buf_lock, flags);
len = strlcpy(kbs->kb_string, func_table[i] ? : "", len); len = strlcpy(kbs->kb_string, func_table[kb_func] ? : "", len);
spin_unlock_irqrestore(&func_buf_lock, flags); spin_unlock_irqrestore(&func_buf_lock, flags);
ret = copy_to_user(user_kdgkb->kb_string, kbs->kb_string, ret = copy_to_user(user_kdgkb->kb_string, kbs->kb_string,
...@@ -2072,11 +2073,11 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm) ...@@ -2072,11 +2073,11 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
/* race aginst other writers */ /* race aginst other writers */
again: again:
spin_lock_irqsave(&func_buf_lock, flags); spin_lock_irqsave(&func_buf_lock, flags);
q = func_table[i]; q = func_table[kb_func];
/* fj pointer to next entry after 'q' */ /* fj pointer to next entry after 'q' */
first_free = funcbufptr + (funcbufsize - funcbufleft); first_free = funcbufptr + (funcbufsize - funcbufleft);
for (j = i+1; j < MAX_NR_FUNC && !func_table[j]; j++) for (j = kb_func + 1; j < MAX_NR_FUNC && !func_table[j]; j++)
; ;
if (j < MAX_NR_FUNC) if (j < MAX_NR_FUNC)
fj = func_table[j]; fj = func_table[j];
...@@ -2094,7 +2095,7 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm) ...@@ -2094,7 +2095,7 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
func_table[k] += delta; func_table[k] += delta;
} }
if (!q) if (!q)
func_table[i] = fj; func_table[kb_func] = fj;
funcbufleft -= delta; funcbufleft -= delta;
} else { /* allocate a larger buffer */ } else { /* allocate a larger buffer */
sz = 256; sz = 256;
...@@ -2113,7 +2114,7 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm) ...@@ -2113,7 +2114,7 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
} }
if (!q) if (!q)
func_table[i] = fj; func_table[kb_func] = fj;
/* copy data before insertion point to new location */ /* copy data before insertion point to new location */
if (fj > funcbufptr) if (fj > funcbufptr)
memmove(fnw, funcbufptr, fj - funcbufptr); memmove(fnw, funcbufptr, fj - funcbufptr);
...@@ -2135,7 +2136,7 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm) ...@@ -2135,7 +2136,7 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
funcbufsize = sz; funcbufsize = sz;
} }
/* finally insert item itself */ /* finally insert item itself */
strcpy(func_table[i], kbs->kb_string); strcpy(func_table[kb_func], kbs->kb_string);
spin_unlock_irqrestore(&func_buf_lock, flags); spin_unlock_irqrestore(&func_buf_lock, flags);
break; break;
} }
......
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