Re: [PATCH] implement constant-folding in __builtin_bswap*()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Aug 11, 2016 at 6:39 PM, Johannes Berg
<johannes@xxxxxxxxxxxxxxxx> wrote:
> Since gcc does this, it's apparently valid to write
>
>  switch (x) {
>  case __builtin_bswap16(12):
>    break;
>  }
>
> but sparse will flag it as an error today.
>
> The constant folding used to be done in the kernel's htons() and
> friends, but due to gcc bugs that isn't done anymore since
> commit 7322dd755e7d ("byteswap: try to avoid __builtin_constant_p
> gcc bug").
>
> To get rid of the sparse errors on every such instance now, just
> add constant folding to __builtin_bswap*() in sparse.

Sorry for the really late review.

This looks good. I would like to apply it. Can you please add some
test case for the function prototype you introduced, just like the way
kernel use it?

Thanks

Chris
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux