Re: [PATCH v2] include/uapi/linux/swab.h: move explicit cast outside ternary

From: Nick Desaulniers
Date: Wed Jun 08 2022 - 17:19:42 EST


On Tue, Jun 7, 2022 at 5:14 PM Justin Stitt <jstitt007@xxxxxxxxx> 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.
>
> For instance, if __HAVE_BUILTIN_BSWAP16__ was not defined then __swab16 is
> actually returning an `int` not a `u16` due to integer promotion as described
> by Nick in this thread. This has repercussions when building with clang

Also, "this thread" won't make much sense when applied if someone is
looking at git log. Consider phrasing this instead as "in the lore
link below" then include another link tag to

Link: https://lore.kernel.org/llvm/CAKwvOdmXeRbFjkHgFXps4pLH6Q6pGWRNOqA85=h2aFnR=uaggg@xxxxxxxxxxxxxx/

Though, I think it's simply more concise to just include what Al said,
and drop this sentence altogether. You can send me v3 privately as an
RFC and I'll greenlight it before you resend to the list.
--
Thanks,
~Nick Desaulniers