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 <[email protected]>
---
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
The old->refcount is guaranteed to be > 1, so we can directly call
con_allocate_new() to make the code more obvious.
Signed-off-by: Jiri Slaby <[email protected]>
---
drivers/tty/vt/consolemap.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/tty/vt/consolemap.c b/drivers/tty/vt/consolemap.c
index 14d3fbff015c..f97f7ee6268b 100644
--- a/drivers/tty/vt/consolemap.c
+++ b/drivers/tty/vt/consolemap.c
@@ -580,14 +580,10 @@ static struct uni_pagedict *con_unshare_unimap(struct vc_data *vc,
int ret;
u16 uni = 0;
- ret = con_do_clear_unimap(vc);
+ ret = con_allocate_new(vc);
if (ret)
return ERR_PTR(ret);
- /*
- * Since refcount was > 1, con_clear_unimap() allocated a new
- * uni_pagedict for this vc. Re: old != new
- */
new = *vc->vc_uni_pagedir_loc;
/*
--
2.36.1