Re: [PATCH] usb: Replace a < b ? a : b construct with min_t(type, a, b) in adutux driver

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

 



On Tue, Jun 18, 2019 at 08:35:29AM -0700, dmg@xxxxxxxxxxxxxxxxx wrote:
> From: Daniel M German <dmg@xxxxxxxxxxxxxxxxx>
> 
> Use min_t to find the minimum of two values instead of using the ?: operator.
> 
> We use min_t instead of min to avoid the compilation warning 'comparison of
> distinct pointer types lacks a cast'.
> 
> This change does not alter functionality. It is merely cosmetic intended to
> improve the readability of the code.
> 
> Signed-off-by: Daniel M German <dmg@xxxxxxxxxxxxxxxxx>
> ---
>  drivers/usb/misc/adutux.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c
> index 9465fb95d70a..4a9fa3152f2a 100644
> --- a/drivers/usb/misc/adutux.c
> +++ b/drivers/usb/misc/adutux.c
> @@ -379,7 +379,7 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count,
>  
>  		if (data_in_secondary) {
>  			/* drain secondary buffer */
> -			int amount = bytes_to_read < data_in_secondary ? bytes_to_read : data_in_secondary;
> +			int amount = min_t(size_t, bytes_to_read, data_in_secondary);

Shouldn't amount and data_in_secondary be of size_t type?  Then you can
just use min() here, right?

thanks,

greg k-h



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux