public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Cc: gregkh@linuxfoundation.org, linux-serial@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev
Subject: Re: [PATCH 34/36] tty: gdm724x: convert counts to size_t
Date: Tue, 15 Aug 2023 10:22:47 -0700	[thread overview]
Message-ID: <20230815172247.GA1690054@dev-arch.thelio-3990X> (raw)
In-Reply-To: <20230810091510.13006-35-jirislaby@kernel.org>

On Thu, Aug 10, 2023 at 11:15:08AM +0200, Jiri Slaby (SUSE) wrote:
> Unify the type of tty_operations::write() counters with the 'count'
> parameter. I.e. use size_t for them.
> 
> This includes changing constants to UL to keep min() and avoid min_t().

This patch appears to cause a warning/error on 32-bit architectures now
due to this part of the change, as size_t is 'unsigned int' there:

  In file included from include/linux/kernel.h:27,
                   from drivers/staging/gdm724x/gdm_tty.c:6:
  drivers/staging/gdm724x/gdm_tty.c: In function 'gdm_tty_write':
  include/linux/minmax.h:21:35: error: comparison of distinct pointer types lacks a cast [-Werror]
     21 |         (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
        |                                   ^~
  include/linux/minmax.h:27:18: note: in expansion of macro '__typecheck'
     27 |                 (__typecheck(x, y) && __no_side_effects(x, y))
        |                  ^~~~~~~~~~~
  include/linux/minmax.h:37:31: note: in expansion of macro '__safe_cmp'
     37 |         __builtin_choose_expr(__safe_cmp(x, y), \
        |                               ^~~~~~~~~~
  include/linux/minmax.h:68:25: note: in expansion of macro '__careful_cmp'
     68 | #define min(x, y)       __careful_cmp(x, y, <)
        |                         ^~~~~~~~~~~~~
  drivers/staging/gdm724x/gdm_tty.c:162:38: note: in expansion of macro 'min'
    162 |                 size_t sending_len = min(MUX_TX_MAX_SIZE, remain);
        |                                      ^~~
  cc1: all warnings being treated as errors

> Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
> Cc: linux-staging@lists.linux.dev
> ---
>  drivers/staging/gdm724x/gdm_tty.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c
> index b31f2afb0286..cbaaa8fa7474 100644
> --- a/drivers/staging/gdm724x/gdm_tty.c
> +++ b/drivers/staging/gdm724x/gdm_tty.c
> @@ -17,9 +17,9 @@
>  #define GDM_TTY_MAJOR 0
>  #define GDM_TTY_MINOR 32
>  
> -#define WRITE_SIZE 2048
> +#define WRITE_SIZE 2048UL
>  
> -#define MUX_TX_MAX_SIZE 2048
> +#define MUX_TX_MAX_SIZE 2048UL
>  
>  static inline bool gdm_tty_ready(struct gdm *gdm)
>  {
> @@ -152,9 +152,8 @@ static void gdm_tty_send_complete(void *arg)
>  static ssize_t gdm_tty_write(struct tty_struct *tty, const u8 *buf, size_t len)
>  {
>  	struct gdm *gdm = tty->driver_data;
> -	int remain = len;
> -	int sent_len = 0;
> -	int sending_len = 0;
> +	size_t remain = len;
> +	size_t sent_len = 0;
>  
>  	if (!gdm_tty_ready(gdm))
>  		return -ENODEV;
> @@ -163,7 +162,7 @@ static ssize_t gdm_tty_write(struct tty_struct *tty, const u8 *buf, size_t len)
>  		return 0;
>  
>  	while (1) {
> -		sending_len = min(MUX_TX_MAX_SIZE, remain);
> +		size_t sending_len = min(MUX_TX_MAX_SIZE, remain);
>  		gdm->tty_dev->send_func(gdm->tty_dev->priv_dev,
>  					(void *)(buf + sent_len),
>  					sending_len,
> -- 
> 2.41.0
> 

  parent reply	other threads:[~2023-08-15 17:22 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20230810091510.13006-1-jirislaby@kernel.org>
2023-08-10  9:15 ` [PATCH 34/36] tty: gdm724x: convert counts to size_t Jiri Slaby (SUSE)
2023-08-10  9:42   ` Dan Carpenter
2023-08-10 10:08     ` Jiri Slaby
2023-08-10 10:39     ` [PATCH 34-and-three-quarters/36] tty: gdm724x: simplify gdm_tty_write() Jiri Slaby (SUSE)
2023-08-11  9:11       ` Ilpo Järvinen
2023-08-15 17:22   ` Nathan Chancellor [this message]
2023-08-16  6:46     ` [PATCH 34/36] tty: gdm724x: convert counts to size_t Jiri Slaby
2023-08-16  8:40       ` David Laight
2023-08-16  8:58         ` Jiri Slaby
2023-08-16  9:18           ` David Laight

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=20230815172247.GA1690054@dev-arch.thelio-3990X \
    --to=nathan@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    /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