RE: [PATCH] tty: gdm724x: use min_t() for size_t varable and a constant

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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)




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux