public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: "'Jiri Slaby (SUSE)'" <jirislaby@kernel.org>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>
Cc: "linux-serial@vger.kernel.org" <linux-serial@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"Nathan Chancellor" <nathan@kernel.org>,
	kernel test robot <lkp@intel.com>
Subject: RE: [PATCH] tty: gdm724x: use min_t() for size_t varable and a constant
Date: Thu, 17 Aug 2023 11:37:25 +0000	[thread overview]
Message-ID: <e082032238ae4d5e9af2c0ccdc79889f@AcuMS.aculab.com> (raw)
In-Reply-To: <20230816085322.22065-1-jirislaby@kernel.org>

From: Jiri Slaby (SUSE)
> Sent: Wednesday, August 16, 2023 9:53 AM
> 
> My thinking was that ulong is the same as size_t everywhere. No, size_t
> is uint on 32bit. So the below commit introduced a build warning on
> 32bit:
> .../gdm724x/gdm_tty.c:165:24: warning: comparison of distinct pointer types ('typeof (2048UL) *' (aka
> 'unsigned long *') and 'typeof (remain) *' (aka 'unsigned int *'))
> 
> To fix this, partially revert the commit (remove constants' suffixes)
> and switch to min_t() in this case instead.
> 
....
> -		size_t sending_len = min(MUX_TX_MAX_SIZE, remain);
> +		size_t sending_len = min_t(size_t, MUX_TX_MAX_SIZE, remain);

It would be slightly safer to use:
		min(remain, (size_t)MAX_TX_MAX_SIZE);
since that maintains the type check.
(It is also nicer to put the constant second.)

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


      parent reply	other threads:[~2023-08-17 11:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-16  8:53 [PATCH] tty: gdm724x: use min_t() for size_t varable and a constant Jiri Slaby (SUSE)
2023-08-16 11:45 ` Geert Uytterhoeven
2023-08-16 17:13 ` Nathan Chancellor
2023-08-17 11:37 ` David Laight [this message]

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=e082032238ae4d5e9af2c0ccdc79889f@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=nathan@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