public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/7] tty/vt: consolemap: use ARRAY_SIZE(), part II.
@ 2022-06-14  7:57 Jiri Slaby
  2022-06-14  7:57 ` [PATCH 2/7] tty/vt: consolemap: remove unused parameter from set_inverse_trans_unicode() Jiri Slaby
                   ` (7 more replies)
  0 siblings, 8 replies; 22+ messages in thread
From: Jiri Slaby @ 2022-06-14  7:57 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

The code still uses constants (macros) as bounds in loops after commit
17945d317a52 (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.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/vt/consolemap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/vt/consolemap.c b/drivers/tty/vt/consolemap.c
index fff97ae87e00..8aa7a48b3647 100644
--- a/drivers/tty/vt/consolemap.c
+++ b/drivers/tty/vt/consolemap.c
@@ -232,7 +232,7 @@ static void set_inverse_transl(struct vc_data *conp, struct uni_pagedict *p,
 	}
 	memset(q, 0, MAX_GLYPH);
 
-	for (j = 0; j < E_TABSZ; j++) {
+	for (j = 0; j < ARRAY_SIZE(translations[i]); j++) {
 		glyph = conv_uni_to_pc(conp, t[j]);
 		if (glyph >= 0 && glyph < MAX_GLYPH && q[glyph] < 32) {
 			/* prefer '-' above SHY etc. */
@@ -367,7 +367,7 @@ int con_get_trans_old(unsigned char __user * arg)
 	unsigned char outbuf[E_TABSZ];
 
 	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]);
 		outbuf[i] = (ch & ~0xff) ? 0 : ch;
-- 
2.36.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2022-06-14  9:06 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-14  7:57 [PATCH 1/7] tty/vt: consolemap: use ARRAY_SIZE(), part II Jiri Slaby
2022-06-14  7:57 ` [PATCH 2/7] tty/vt: consolemap: remove unused parameter from set_inverse_trans_unicode() Jiri Slaby
2022-06-14  7:57 ` [PATCH 3/7] tty/vt: consolemap: saner variable names in set_inverse_trans_unicode() Jiri Slaby
2022-06-14  7:57 ` [PATCH 4/7] tty/vt: consolemap: saner variable names in set_inverse_transl() Jiri Slaby
2022-06-14  8:35   ` Ilpo Järvinen
2022-06-14  8:40     ` Jiri Slaby
2022-06-14  7:57 ` [PATCH 5/7] tty/vt: consolemap: rename struct vc_data::vc_uni_pagedir* Jiri Slaby
2022-06-14  8:38   ` Ilpo Järvinen
2022-06-14  7:57 ` [PATCH 6/7] tty/vt: consolemap: improve UNI_*() macros definitions Jiri Slaby
2022-06-14  7:57 ` [PATCH 7/7] tty/vt: consolemap: remove dflt reset from con_do_clear_unimap() Jiri Slaby
2022-06-14  8:41   ` Ilpo Järvinen
2022-06-14  8:17 ` [PATCH 1/7] tty/vt: consolemap: use ARRAY_SIZE(), part II Ilpo Järvinen
2022-06-14  8:32   ` Ilpo Järvinen
2022-06-14  9:03   ` Jiri Slaby
2022-06-14  9:05 ` [PATCH v2 1/8] " Jiri Slaby
2022-06-14  9:05   ` [PATCH v2 2/8] tty/vt: consolemap: remove unused parameter from set_inverse_trans_unicode() Jiri Slaby
2022-06-14  9:05   ` [PATCH v2 3/8] tty/vt: consolemap: saner variable names in set_inverse_trans_unicode() Jiri Slaby
2022-06-14  9:05   ` [PATCH v2 4/8] tty/vt: consolemap: saner variable names in set_inverse_transl() Jiri Slaby
2022-06-14  9:05   ` [PATCH v2 5/8] tty/vt: consolemap: rename struct vc_data::vc_uni_pagedir* Jiri Slaby
2022-06-14  9:05   ` [PATCH v2 6/8] tty/vt: consolemap: improve UNI_*() macros definitions Jiri Slaby
2022-06-14  9:05   ` [PATCH v2 7/8] tty/vt: consolemap: remove dflt reset from con_do_clear_unimap() Jiri Slaby
2022-06-14  9:05   ` [PATCH v2 8/8] tty/vt: consolemap: use E_TABSZ for the translations size Jiri Slaby

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox