From: Alexey Dobriyan <adobriyan@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: viro@zeniv.linux.org.uk, ndesaulniers@google.com,
nathan@kernel.org, jstitt007@gmail.com,
akpm@linux-foundation.org
Subject: Re: + include-uapi-linux-swabh-move-explicit-cast-outside-ternary.patch added to mm-nonmm-unstable branch
Date: Thu, 9 Jun 2022 23:42:27 +0300 [thread overview]
Message-ID: <YqJbMzUnzF2WEmU5@localhost.localdomain> (raw)
In-Reply-To: <20220609172933.D8187C34114@smtp.kernel.org>
On Thu, Jun 09, 2022 at 10:29:33AM -0700, Andrew Morton wrote:
> A cast inside __builtin_constant_p doesn't do anything since it should
> evaluate as constant at compile time irrespective of this cast. Instead,
> I moved this cast outside the ternary to ensure the return type is as
> expected.
> --- a/include/uapi/linux/swab.h~include-uapi-linux-swabh-move-explicit-cast-outside-ternary
> +++ a/include/uapi/linux/swab.h
> @@ -102,7 +102,7 @@ static inline __attribute_const__ __u32
> #define __swab16(x) (__u16)__builtin_bswap16((__u16)(x))
> #else
> #define __swab16(x) \
> - (__builtin_constant_p((__u16)(x)) ? \
> + (__u16)(__builtin_constant_p(x) ? \
This cast is necessary.
> ___constant_swab16(x) : \
> __fswab16(x))
> #endif
> @@ -115,7 +115,7 @@ static inline __attribute_const__ __u32
> #define __swab32(x) (__u32)__builtin_bswap32((__u32)(x))
> #else
> #define __swab32(x) \
> - (__builtin_constant_p((__u32)(x)) ? \
> + (__u32)(__builtin_constant_p(x) ? \
> ___constant_swab32(x) : \
> __fswab32(x))
> #endif
> @@ -128,7 +128,7 @@ static inline __attribute_const__ __u32
> #define __swab64(x) (__u64)__builtin_bswap64((__u64)(x))
> #else
> #define __swab64(x) \
> - (__builtin_constant_p((__u64)(x)) ? \
> + (__u64)(__builtin_constant_p(x) ? \
> ___constant_swab64(x) : \
> __fswab64(x))
These two aren't? typeof(c ? u32 : u32) is u32.
next parent reply other threads:[~2022-06-09 20:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20220609172933.D8187C34114@smtp.kernel.org>
2022-06-09 20:42 ` Alexey Dobriyan [this message]
2022-06-09 21:01 ` Nick Desaulniers
2022-06-09 21:08 ` Andrew Morton
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=YqJbMzUnzF2WEmU5@localhost.localdomain \
--to=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=jstitt007@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=viro@zeniv.linux.org.uk \
/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®