All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: dmg@turingmachine.org
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH] usb: Replace a < b ? a : b construct with min_t(type, a, b) in adutux driver
Date: Tue, 18 Jun 2019 18:06:58 +0200	[thread overview]
Message-ID: <20190618160658.GA27611@kroah.com> (raw)
In-Reply-To: <20190618153529.11418-1-dmg@turingmachine.org>

On Tue, Jun 18, 2019 at 08:35:29AM -0700, dmg@turingmachine.org wrote:
> From: Daniel M German <dmg@turingmachine.org>
> 
> 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@turingmachine.org>
> ---
>  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

  reply	other threads:[~2019-06-18 16:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-18 15:35 [PATCH] usb: Replace a < b ? a : b construct with min_t(type, a, b) in adutux driver dmg
2019-06-18 16:06 ` Greg KH [this message]
2019-06-18 16:18   ` dmg
2019-06-18 17:22   ` dmg
2019-06-18 18:13     ` Greg KH
2019-06-19 16:39       ` dmg
2019-06-19 17:04         ` Greg KH

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=20190618160658.GA27611@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=dmg@turingmachine.org \
    --cc=linux-usb@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.