[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <e082032238ae4d5e9af2c0ccdc79889f@AcuMS.aculab.com>
Date: Thu, 17 Aug 2023 11:37:25 +0000
From: David Laight <David.Laight@...LAB.COM>
To: "'Jiri Slaby (SUSE)'" <jirislaby@...nel.org>,
"gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>
CC: "linux-serial@...r.kernel.org" <linux-serial@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"Nathan Chancellor" <nathan@...nel.org>,
kernel test robot <lkp@...el.com>
Subject: RE: [PATCH] tty: gdm724x: use min_t() for size_t varable and a
constant
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)
Powered by blists - more mailing lists