Re: [PATCH] spi: work around clang bug in SPI_BPW_RANGE_MASK()
From: Rasmus Villemoes
Date: Thu Mar 07 2019 - 08:09:31 EST
On 07/03/2019 11.56, Arnd Bergmann wrote:
> Clang-8 evaluates both sides of a ?: expression to check for
> valid arithmetic even in the side that is never taken. This
> results in a build warning:
>
> drivers/spi/spi-sh-msiof.c:1052:24: error: shift count >= width of type [-Werror,-Wshift-count-overflow]
> .bits_per_word_mask = SPI_BPW_RANGE_MASK(8, 32),
> ^~~~~~~~~~~~~~~~~~~~~~~~~
>
> Change it to shift one less than we want, and then shift one
> more bit afterwards. This should give the correct result for
> all valid input, since it has to be in the range 1..32 anyway.
Why not use GENMASK which is provided by the same header that #defines BIT?
Rasmus