From: dmg <dmg@turingmachine.org>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH] usb: Replace a < b ? a : b construct with min_t(type, a, b) in drivers/usb
Date: Tue, 18 Jun 2019 08:00:28 -0700 [thread overview]
Message-ID: <87pnnbj5v7.fsf@mn.cs.uvic.ca> (raw)
In-Reply-To: <20190618064905.GA22457@kroah.com>
Greg KH <gregkh@linuxfoundation.org> writes:
> On Mon, Jun 17, 2019 at 04:30:50PM -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.
>
> Why is min_t() needed for all of these and not just min()?
The use of min triggers a compilation warning (see below), which min_t is supposed to
address (from min_t comment: 'min()/max() macros that also do strict type-checking.. See the
"unnecessary" pointer comparison.", from include/linux/kernel')
In file included from drivers/usb/misc/adutux.c:19:
drivers/usb/misc/adutux.c: In function ‘adu_read’:
./include/linux/kernel.h:818:29: warning: comparison of distinct pointer types lacks a cast
(!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
^~
./include/linux/kernel.h:832:4: note: in expansion of macro ‘__typecheck’
(__typecheck(x, y) && __no_side_effects(x, y))
^~~~~~~~~~~
./include/linux/kernel.h:842:24: note: in expansion of macro ‘__safe_cmp’
__builtin_choose_expr(__safe_cmp(x, y), \
^~~~~~~~~~
./include/linux/kernel.h:851:19: note: in expansion of macro ‘__careful_cmp’
#define min(x, y) __careful_cmp(x, y, <)
^~~~~~~~~~~~~
drivers/usb/misc/adutux.c:382:34: note: in expansion of macro ‘min’
int amount = min(bytes_to_read, data_in_secondary);
^~~
[...]
> Can you break this up into one patch per driver? That way you can
> include the proper maintainers/reviewers when you resend them.
>
I will split the patch as instructed.
> thanks,
>
> greg k-h
--
Daniel M. German "Beauty is the first test; there is no
permanent place in the world for ugly
G. H. Hardy -> mathematics."
http://turingmachine.org/
http://silvernegative.com/
dmg (at) uvic (dot) ca
replace (at) with @ and (dot) with .
next prev parent reply other threads:[~2019-06-18 15:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-17 23:30 [PATCH] usb: Replace a < b ? a : b construct with min_t(type, a, b) in drivers/usb dmg
2019-06-18 6:49 ` Greg KH
2019-06-18 15:00 ` dmg [this message]
2019-06-18 15:26 ` Greg KH
2019-06-18 7:15 ` Felipe Balbi
2019-06-18 10:03 ` David Laight
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=87pnnbj5v7.fsf@mn.cs.uvic.ca \
--to=dmg@turingmachine.org \
--cc=gregkh@linuxfoundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).