linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 01/36] tty/vt: consolemap: use ARRAY_SIZE()
@ 2022-06-07 10:49 Jiri Slaby
  2022-06-07 10:49 ` [PATCH 02/36] tty/vt: consolemap: rename and document struct uni_pagedir Jiri Slaby
                   ` (35 more replies)
  0 siblings, 36 replies; 74+ messages in thread
From: Jiri Slaby @ 2022-06-07 10:49 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby

The code uses constants as bounds in loops. Use ARRAY_SIZE() with
appropriate parameters instead. This makes the loop bounds obvious.

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 d815ac98b39e..839d75d1a6c0 100644
--- a/drivers/tty/vt/consolemap.c
+++ b/drivers/tty/vt/consolemap.c
@@ -408,7 +408,7 @@ static void con_release_unimap(struct uni_pagedir *p)
 		}
 		p->uni_pgdir[i] = NULL;
 	}
-	for (i = 0; i < 4; i++) {
+	for (i = 0; i < ARRAY_SIZE(p->inverse_translations); i++) {
 		kfree(p->inverse_translations[i]);
 		p->inverse_translations[i] = NULL;
 	}
@@ -798,7 +798,7 @@ u32 conv_8bit_to_uni(unsigned char c)
 int conv_uni_to_8bit(u32 uni)
 {
 	int c;
-	for (c = 0; c < 0x100; c++)
+	for (c = 0; c < ARRAY_SIZE(translations[USER_MAP]); c++)
 		if (translations[USER_MAP][c] == uni ||
 		   (translations[USER_MAP][c] == (c | 0xf000) && uni == c))
 			return c;
-- 
2.36.1


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

end of thread, other threads:[~2022-06-09  8:54 UTC | newest]

Thread overview: 74+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-07 10:49 [PATCH 01/36] tty/vt: consolemap: use ARRAY_SIZE() Jiri Slaby
2022-06-07 10:49 ` [PATCH 02/36] tty/vt: consolemap: rename and document struct uni_pagedir Jiri Slaby
2022-06-07 12:36   ` Ilpo Järvinen
2022-06-08  5:42     ` Jiri Slaby
2022-06-07 10:49 ` [PATCH 03/36] tty/vt: consolemap: define UNI_* macros for constants Jiri Slaby
2022-06-07 13:21   ` Ilpo Järvinen
2022-06-08  6:55     ` Jiri Slaby
2022-06-08  9:54       ` Ilpo Järvinen
2022-06-07 10:49 ` [PATCH 04/36] tty/vt: consolemap: decrypt inverse_translate() Jiri Slaby
2022-06-07 12:54   ` Ilpo Järvinen
2022-06-07 10:49 ` [PATCH 05/36] tty/vt: consolemap: remove extern from function decls Jiri Slaby
2022-06-07 13:33   ` Ilpo Järvinen
2022-06-07 10:49 ` [PATCH 06/36] tty/vt: consolemap: convert macros to static inlines Jiri Slaby
2022-06-07 13:31   ` Ilpo Järvinen
2022-06-07 10:49 ` [PATCH 07/36] tty/vt: consolemap: make parameters of inverse_translate() saner Jiri Slaby
2022-06-07 13:32   ` Ilpo Järvinen
2022-06-07 10:49 ` [PATCH 08/36] tty/vt: consolemap: one line = one statement Jiri Slaby
2022-06-07 13:35   ` Ilpo Järvinen
2022-06-07 10:49 ` [PATCH 09/36] tty/vt: consolemap: use | for binary addition Jiri Slaby
2022-06-07 13:36   ` Ilpo Järvinen
2022-06-07 13:40     ` Ilpo Järvinen
2022-06-07 10:49 ` [PATCH 10/36] tty/vt: consolemap: introduce UNI_*() macros Jiri Slaby
2022-06-07 13:47   ` Ilpo Järvinen
2022-06-08  6:59     ` Jiri Slaby
2022-06-08  7:30       ` Jiri Slaby
2022-06-08  8:02         ` Ilpo Järvinen
2022-06-08  8:18           ` Jiri Slaby
2022-06-07 10:49 ` [PATCH 11/36] tty/vt: consolemap: zero uni_pgdir using kcalloc() Jiri Slaby
2022-06-07 13:51   ` Ilpo Järvinen
2022-06-07 10:49 ` [PATCH 12/36] tty/vt: consolemap: use sizeof(*pointer) instead of sizeof(type) Jiri Slaby
2022-06-07 14:00   ` Ilpo Järvinen
2022-06-07 18:13     ` Jiri Slaby
2022-06-08  7:23       ` Ilpo Järvinen
2022-06-07 10:49 ` [PATCH 13/36] tty/vt: consolemap: make con_set_unimap() more readable Jiri Slaby
2022-06-07 14:06   ` Ilpo Järvinen
2022-06-07 10:49 ` [PATCH 14/36] tty/vt: consolemap: make con_get_unimap() " Jiri Slaby
2022-06-07 14:11   ` Ilpo Järvinen
2022-06-07 10:49 ` [PATCH 15/36] tty/vt: consolemap: make p1 increment less confusing in con_get_unimap() Jiri Slaby
2022-06-07 10:49 ` [PATCH 16/36] tty/vt: consolemap: check put_user() " Jiri Slaby
2022-06-07 14:19   ` Ilpo Järvinen
2022-06-08  7:40     ` Jiri Slaby
2022-06-08  8:13       ` Ilpo Järvinen
2022-06-08 10:38       ` Andy Shevchenko
2022-06-08 10:43         ` Greg Kroah-Hartman
2022-06-08  8:02   ` David Laight
2022-06-08  8:11     ` Jiri Slaby
2022-06-08  8:13       ` Jiri Slaby
2022-06-09  8:51       ` Jiri Slaby
2022-06-07 10:49 ` [PATCH 17/36] tty/vt: consolemap: introduce enum translation_map and use it Jiri Slaby
2022-06-07 10:49 ` [PATCH 18/36] tty/vt: consolemap: remove glyph < 0 check from set_inverse_trans_unicode() Jiri Slaby
2022-06-07 10:49 ` [PATCH 19/36] tty/vt: consolemap: extract dict unsharing to con_unshare_unimap() Jiri Slaby
2022-06-07 14:30   ` Ilpo Järvinen
2022-06-07 10:49 ` [PATCH 20/36] tty/vt: consolemap: saner variable names in set_inverse_trans_unicode() Jiri Slaby
2022-06-07 14:34   ` Ilpo Järvinen
2022-06-07 10:49 ` [PATCH 21/36] tty/vt: consolemap: saner variable names in conv_uni_to_pc() Jiri Slaby
2022-06-07 10:49 ` [PATCH 22/36] tty/vt: consolemap: saner variable names in con_insert_unipair() Jiri Slaby
2022-06-07 10:49 ` [PATCH 23/36] tty/vt: consolemap: saner variable names in con_unify_unimap() Jiri Slaby
2022-06-07 10:49 ` [PATCH 24/36] tty/vt: consolemap: saner variable names in con_do_clear_unimap() Jiri Slaby
2022-06-07 10:49 ` [PATCH 25/36] tty/vt: consolemap: saner variable names in con_unshare_unimap() Jiri Slaby
2022-06-07 10:49 ` [PATCH 26/36] tty/vt: consolemap: saner variable names in con_release_unimap() Jiri Slaby
2022-06-07 10:49 ` [PATCH 27/36] tty/vt: consolemap: saner variable names in con_copy_unimap() Jiri Slaby
2022-06-07 10:49 ` [PATCH 28/36] tty/vt: consolemap: saner variable names in con_get_unimap() Jiri Slaby
2022-06-07 10:49 ` [PATCH 29/36] tty/vt: consolemap: saner variable names in con_set_unimap() Jiri Slaby
2022-06-07 10:49 ` [PATCH 30/36] tty/vt: consolemap: saner variable names in con_set_default_unimap() Jiri Slaby
2022-06-07 10:49 ` [PATCH 31/36] tty/vt: consolemap: make conv_uni_to_pc() more readable Jiri Slaby
2022-06-07 10:49 ` [PATCH 32/36] tty/vt: consolemap: remove superfluous whitespace Jiri Slaby
2022-06-07 10:49 ` [PATCH 33/36] tty/vt: consolemap: change refcount only if needed in con_do_clear_unimap() Jiri Slaby
2022-06-07 15:31   ` Ilpo Järvinen
2022-06-08  7:44     ` Jiri Slaby
2022-06-07 10:49 ` [PATCH 34/36] tty/vt: consolemap: extract con_allocate_new() from con_do_clear_unimap() Jiri Slaby
2022-06-07 10:49 ` [PATCH 35/36] tty/vt: consolemap: use con_allocate_new() in con_unshare_unimap() Jiri Slaby
2022-06-07 10:49 ` [PATCH 36/36] tty/vt: consolemap: walk the buffer only once in con_set_trans_old() Jiri Slaby
2022-06-07 16:25   ` Ilpo Järvinen
2022-06-07 12:36 ` [PATCH 01/36] tty/vt: consolemap: use ARRAY_SIZE() Ilpo Järvinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).