From: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
To: gregkh@linuxfoundation.org
Cc: Kees Cook <keescook@chromium.org>,
linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
"Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Subject: [PATCH 04/11] tty: vt: use sizeof(*variable) where possible
Date: Thu, 12 Jan 2023 09:01:29 +0100 [thread overview]
Message-ID: <20230112080136.4929-4-jirislaby@kernel.org> (raw)
In-Reply-To: <20230112080136.4929-1-jirislaby@kernel.org>
Instead of sizeof(type), use sizeof(*variable) which is preferred. We
are going to remove the unicode's char32_t typedef, so this makes the
switch easier.
Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
---
drivers/tty/vt/vt.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 561c82e120cf..3ae0212f1aa7 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -330,11 +330,11 @@ static struct uni_screen *vc_uniscr_alloc(unsigned int cols, unsigned int rows)
{
struct uni_screen *uniscr;
void *p;
- unsigned int memsize, i;
+ unsigned int memsize, i, col_size = cols * sizeof(**uniscr->lines);
/* allocate everything in one go */
- memsize = cols * rows * sizeof(char32_t);
- memsize += rows * sizeof(char32_t *);
+ memsize = col_size * rows;
+ memsize += rows * sizeof(*uniscr->lines);
p = vzalloc(memsize);
if (!p)
return NULL;
@@ -344,7 +344,7 @@ static struct uni_screen *vc_uniscr_alloc(unsigned int cols, unsigned int rows)
p = uniscr->lines + rows;
for (i = 0; i < rows; i++) {
uniscr->lines[i] = p;
- p += cols * sizeof(char32_t);
+ p += col_size;
}
return uniscr;
}
@@ -469,7 +469,7 @@ static void vc_uniscr_copy_area(struct uni_screen *dst,
char32_t *src_line = src->lines[src_top_row];
char32_t *dst_line = dst->lines[dst_row];
- memcpy(dst_line, src_line, src_cols * sizeof(char32_t));
+ memcpy(dst_line, src_line, src_cols * sizeof(*src_line));
if (dst_cols - src_cols)
memset32(dst_line + src_cols, ' ', dst_cols - src_cols);
src_top_row++;
--
2.39.0
next prev parent reply other threads:[~2023-01-12 8:02 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-12 8:01 [PATCH 01/11] tty: vt: remove vc_uniscr_debug_check() Jiri Slaby (SUSE)
2023-01-12 8:01 ` [PATCH 02/11] tty: vt: drop get_vc_uniscr() Jiri Slaby (SUSE)
2023-01-12 8:41 ` Ilpo Järvinen
2023-01-12 8:01 ` [PATCH 03/11] tty: vt: remove reference to undefined NO_VC_UNI_SCREEN Jiri Slaby (SUSE)
2023-01-12 8:44 ` Ilpo Järvinen
2023-01-12 8:01 ` Jiri Slaby (SUSE) [this message]
2023-01-12 8:58 ` [PATCH 04/11] tty: vt: use sizeof(*variable) where possible Ilpo Järvinen
2023-01-12 8:01 ` [PATCH 05/11] tty: vt: remove char32_t typedef Jiri Slaby (SUSE)
2023-01-12 8:52 ` Ilpo Järvinen
2023-01-12 9:34 ` Ilpo Järvinen
2023-01-12 8:01 ` [PATCH 06/11] tty: vt: remove struct uni_screen Jiri Slaby (SUSE)
2023-01-12 9:42 ` Ilpo Järvinen
2023-01-12 8:01 ` [PATCH 07/11] tty: vt: replace BUG_ON() by WARN_ON_ONCE() Jiri Slaby (SUSE)
2023-01-12 9:42 ` Ilpo Järvinen
2023-01-12 8:01 ` [PATCH 08/11] tty: vt: simplify some unicode conditions Jiri Slaby (SUSE)
2023-01-12 9:52 ` Ilpo Järvinen
2023-01-12 8:01 ` [PATCH 09/11] tty: vt: separate array juggling to juggle_array() Jiri Slaby (SUSE)
2023-01-12 10:15 ` Ilpo Järvinen
2023-01-12 8:01 ` [PATCH 10/11] tty: vt: saner names for more scroll variables Jiri Slaby (SUSE)
2023-01-12 9:59 ` Ilpo Järvinen
2023-01-12 8:01 ` [PATCH 11/11] tty: vt: cache row count in con_scroll() Jiri Slaby (SUSE)
2023-01-12 10:00 ` Ilpo Järvinen
2023-01-12 8:43 ` [PATCH 01/11] tty: vt: remove vc_uniscr_debug_check() Ilpo Järvinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230112080136.4929-4-jirislaby@kernel.org \
--to=jirislaby@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.