From: David Laight <David.Laight@ACULAB.COM>
To: David Laight <David.Laight@ACULAB.COM>,
LKML <linux-kernel@vger.kernel.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: Steven Rostedt <rostedt@goodmis.org>,
'Joe Perches' <joe@perches.com>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: RE: [PATCH 1/1] minmax.h: Slightly relax the type checking done by min() and max().
Date: Mon, 28 Nov 2022 09:13:50 +0000 [thread overview]
Message-ID: <6fc56385a90742c7ad21a68403dc27df@AcuMS.aculab.com> (raw)
In-Reply-To: <58cac72242e54380971cfa842f824470@AcuMS.aculab.com>
From: David Laight
> Sent: 25 November 2022 15:01
>
> Slightly relax the type checking done by min() and max().
> - Promote signed/unsiged char/short to int prior to the type test.
> This matches what the compiler does before doing the comparison.
> - Skip the type test if either argument is a positive 'int' constant.
> Instead cast the constant to 'int', the compiler may promote it
> back to 'unsigned int' when doing the test.
>
> Reduces the need to use min_t/max_t() and the possibly unwanted
> side effects if a type that is too small is specified.
>
...
> +#define __cmp(x, y, op) __cmp_maybe_int(__maybe_int_cast(x), __maybe_int_cast(y), op)
>
> #define __cmp_once(x, y, unique_x, unique_y, op) ({ \
> typeof(x) unique_x = (x); \
self nak.
That has to be done as:
typeof(__maybe_int_cast(x)) unique_x = (x);
I will send a V2.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
prev parent reply other threads:[~2022-11-28 9:14 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-25 15:00 David Laight
2022-11-27 20:36 ` Linus Torvalds
2022-11-27 21:42 ` David Laight
2022-11-27 21:54 ` Linus Torvalds
2022-11-27 22:26 ` David Laight
2022-11-28 2:42 ` Linus Torvalds
2022-11-28 9:10 ` David Laight
2022-11-28 19:42 ` Linus Torvalds
2022-12-22 22:32 ` [RFC PATCH v2 0/1] " David Laight
2022-12-22 22:33 ` Subject: [RFC PATCH v2 1/1] " David Laight
2022-11-28 9:13 ` David Laight [this message]
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=6fc56385a90742c7ad21a68403dc27df@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=torvalds@linux-foundation.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
all inboxes | Powered by JetHome®