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

tty/vt: consolemap: use ARRAY_SIZE(), part II.

The code still uses constants (macros) as bounds in loops after commit
17945d31 (tty/vt: consolemap: use ARRAY_SIZE()). The contants are at
least macros used also in the definition of the arrays. But use
ARRAY_SIZE() on two more places to ensure the loops never run out of
bounds even if the array definition change.
Reviewed-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20220614090537.15557-1-jslaby@suse.czSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent df36f3e3
...@@ -232,7 +232,7 @@ static void set_inverse_transl(struct vc_data *conp, struct uni_pagedict *p, ...@@ -232,7 +232,7 @@ static void set_inverse_transl(struct vc_data *conp, struct uni_pagedict *p,
} }
memset(q, 0, MAX_GLYPH); memset(q, 0, MAX_GLYPH);
for (j = 0; j < E_TABSZ; j++) { for (j = 0; j < ARRAY_SIZE(translations[m]); j++) {
glyph = conv_uni_to_pc(conp, t[j]); glyph = conv_uni_to_pc(conp, t[j]);
if (glyph >= 0 && glyph < MAX_GLYPH && q[glyph] < 32) { if (glyph >= 0 && glyph < MAX_GLYPH && q[glyph] < 32) {
/* prefer '-' above SHY etc. */ /* prefer '-' above SHY etc. */
...@@ -367,7 +367,7 @@ int con_get_trans_old(unsigned char __user * arg) ...@@ -367,7 +367,7 @@ int con_get_trans_old(unsigned char __user * arg)
unsigned char outbuf[E_TABSZ]; unsigned char outbuf[E_TABSZ];
console_lock(); console_lock();
for (i = 0; i < E_TABSZ ; i++) for (i = 0; i < ARRAY_SIZE(outbuf); i++)
{ {
ch = conv_uni_to_pc(vc_cons[fg_console].d, p[i]); ch = conv_uni_to_pc(vc_cons[fg_console].d, p[i]);
outbuf[i] = (ch & ~0xff) ? 0 : ch; outbuf[i] = (ch & ~0xff) ? 0 : ch;
......
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