linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Kees Cook <keescook@chromium.org>,
	linux-serial <linux-serial@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 05/11] tty: vt: remove char32_t typedef
Date: Thu, 12 Jan 2023 10:52:08 +0200 (EET)	[thread overview]
Message-ID: <afbdfd8a-5c2d-ca6d-9a9d-a377ddac57e@linux.intel.com> (raw)
In-Reply-To: <20230112080136.4929-5-jirislaby@kernel.org>

[-- Attachment #1: Type: text/plain, Size: 4552 bytes --]

On Thu, 12 Jan 2023, Jiri Slaby (SUSE) wrote:

> It boils down to uint32_t, so use u32 directly, instead. This makes the
> code more obvious.
> 
> Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
> ---
>  drivers/tty/vt/vt.c | 26 ++++++++++++--------------
>  1 file changed, 12 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
> index 3ae0212f1aa7..86c18522231b 100644
> --- a/drivers/tty/vt/vt.c
> +++ b/drivers/tty/vt/vt.c
> @@ -316,14 +316,12 @@ void schedule_console_callback(void)
>   * Code to manage unicode-based screen buffers
>   */
>  
> -typedef uint32_t char32_t;
> -
>  /*
>   * Our screen buffer is preceded by an array of line pointers so that
>   * scrolling only implies some pointer shuffling.
>   */
>  struct uni_screen {
> -	char32_t *lines[0];
> +	u32 *lines[0];
>  };
>  
>  static struct uni_screen *vc_uniscr_alloc(unsigned int cols, unsigned int rows)
> @@ -360,7 +358,7 @@ static void vc_uniscr_set(struct vc_data *vc, struct uni_screen *new_uniscr)
>  	vc->vc_uni_screen = new_uniscr;
>  }
>  
> -static void vc_uniscr_putc(struct vc_data *vc, char32_t uc)
> +static void vc_uniscr_putc(struct vc_data *vc, u32 uc)
>  {
>  	struct uni_screen *uniscr = vc->vc_uni_screen;
>  
> @@ -373,7 +371,7 @@ static void vc_uniscr_insert(struct vc_data *vc, unsigned int nr)
>  	struct uni_screen *uniscr = vc->vc_uni_screen;
>  
>  	if (uniscr) {
> -		char32_t *ln = uniscr->lines[vc->state.y];
> +		u32 *ln = uniscr->lines[vc->state.y];
>  		unsigned int x = vc->state.x, cols = vc->vc_cols;
>  
>  		memmove(&ln[x + nr], &ln[x], (cols - x - nr) * sizeof(*ln));
> @@ -386,7 +384,7 @@ static void vc_uniscr_delete(struct vc_data *vc, unsigned int nr)
>  	struct uni_screen *uniscr = vc->vc_uni_screen;
>  
>  	if (uniscr) {
> -		char32_t *ln = uniscr->lines[vc->state.y];
> +		u32 *ln = uniscr->lines[vc->state.y];
>  		unsigned int x = vc->state.x, cols = vc->vc_cols;
>  
>  		memcpy(&ln[x], &ln[x + nr], (cols - x - nr) * sizeof(*ln));
> @@ -400,7 +398,7 @@ static void vc_uniscr_clear_line(struct vc_data *vc, unsigned int x,
>  	struct uni_screen *uniscr = vc->vc_uni_screen;
>  
>  	if (uniscr) {
> -		char32_t *ln = uniscr->lines[vc->state.y];
> +		u32 *ln = uniscr->lines[vc->state.y];
>  
>  		memset32(&ln[x], ' ', nr);
>  	}
> @@ -435,7 +433,7 @@ static void vc_uniscr_scroll(struct vc_data *vc, unsigned int t, unsigned int b,
>  			d = sz - nr;
>  		}
>  		for (i = 0; i < gcd(d, sz); i++) {
> -			char32_t *tmp = uniscr->lines[t + i];
> +			u32 *tmp = uniscr->lines[t + i];
>  			j = i;
>  			while (1) {
>  				k = j + d;
> @@ -466,8 +464,8 @@ static void vc_uniscr_copy_area(struct uni_screen *dst,
>  		return;
>  
>  	while (src_top_row < src_bot_row) {
> -		char32_t *src_line = src->lines[src_top_row];
> -		char32_t *dst_line = dst->lines[dst_row];
> +		u32 *src_line = src->lines[src_top_row];
> +		u32 *dst_line = dst->lines[dst_row];
>  
>  		memcpy(dst_line, src_line, src_cols * sizeof(*src_line));
>  		if (dst_cols - src_cols)
> @@ -476,7 +474,7 @@ static void vc_uniscr_copy_area(struct uni_screen *dst,
>  		dst_row++;
>  	}
>  	while (dst_row < dst_rows) {
> -		char32_t *dst_line = dst->lines[dst_row];
> +		u32 *dst_line = dst->lines[dst_row];
>  
>  		memset32(dst_line, ' ', dst_cols);
>  		dst_row++;
> @@ -516,7 +514,7 @@ int vc_uniscr_check(struct vc_data *vc)
>  	p = (unsigned short *)vc->vc_origin;
>  	mask = vc->vc_hi_font_mask | 0xff;
>  	for (y = 0; y < vc->vc_rows; y++) {
> -		char32_t *line = uniscr->lines[y];
> +		u32 *line = uniscr->lines[y];
>  		for (x = 0; x < vc->vc_cols; x++) {
>  			u16 glyph = scr_readw(p++) & mask;
>  			line[x] = inverse_translate(vc, glyph, true);
> @@ -550,7 +548,7 @@ void vc_uniscr_copy_line(const struct vc_data *vc, void *dest, bool viewed,
>  		 */
>  		row = (pos - vc->vc_origin) / vc->vc_size_row;
>  		col = ((pos - vc->vc_origin) % vc->vc_size_row) / 2;
> -		memcpy(dest, &uniscr->lines[row][col], nr * sizeof(char32_t));
> +		memcpy(dest, &uniscr->lines[row][col], nr * sizeof(u32));
>  	} else {
>  		/*
>  		 * Scrollback is active. For now let's simply backtranslate
> @@ -560,7 +558,7 @@ void vc_uniscr_copy_line(const struct vc_data *vc, void *dest, bool viewed,
>  		 */
>  		u16 *p = (u16 *)pos;
>  		int mask = vc->vc_hi_font_mask | 0xff;
> -		char32_t *uni_buf = dest;
> +		u32 *uni_buf = dest;
>  		while (nr--) {
>  			u16 glyph = scr_readw(p++) & mask;
>  			*uni_buf++ = inverse_translate(vc, glyph, true);
> 

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

-- 
 i.

  reply	other threads:[~2023-01-12  8:54 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 ` [PATCH 04/11] tty: vt: use sizeof(*variable) where possible Jiri Slaby (SUSE)
2023-01-12  8:58   ` 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 [this message]
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=afbdfd8a-5c2d-ca6d-9a9d-a377ddac57e@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.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 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).