Was just running sparse for something unrelated and noticed these:
drivers/net/wireless/iwlwifi/iwl-rx.c:832:2: warning: cast truncates bits from constant value (1c00 becomes 0)
drivers/net/wireless/iwlwifi/iwl-rx.c:836:2: warning: cast truncates bits from constant value (6f080000 becomes 0)
drivers/net/wireless/iwlwifi/iwl-rx.c:836:2: warning: cast truncates bits from constant value (6f080000 becomes 0)
drivers/net/wireless/iwlwifi/iwl-rx.c:856:3: warning: cast truncates bits from constant value (4001 becomes 1)
drivers/net/wireless/iwlwifi/iwl-rx.c:860:3: warning: cast truncates bits from constant value (a000 becomes 0)
drivers/net/wireless/iwlwifi/iwl-rx.c:864:3: warning: cast truncates bits from constant value (c000 becomes 0)
johannes
On Thu, 2008-07-10 at 13:45 +0300, Tomas Winkler wrote:
> On Thu, Jul 10, 2008 at 12:10 PM, Johannes Berg
> <[email protected]> wrote:
> > Was just running sparse for something unrelated and noticed these:
> >
> > drivers/net/wireless/iwlwifi/iwl-rx.c:832:2: warning: cast truncates bits from constant value (1c00 becomes 0)
> > drivers/net/wireless/iwlwifi/iwl-rx.c:836:2: warning: cast truncates bits from constant value (6f080000 becomes 0)
> > drivers/net/wireless/iwlwifi/iwl-rx.c:836:2: warning: cast truncates bits from constant value (6f080000 becomes 0)
> > drivers/net/wireless/iwlwifi/iwl-rx.c:856:3: warning: cast truncates bits from constant value (4001 becomes 1)
> > drivers/net/wireless/iwlwifi/iwl-rx.c:860:3: warning: cast truncates bits from constant value (a000 becomes 0)
> > drivers/net/wireless/iwlwifi/iwl-rx.c:864:3: warning: cast truncates bits from constant value (c000 becomes 0)
>
> Yeah I've actually wanted to ask someone how to solve. This comes from
> radio tap code, frankly currently very low priority on my list.
> Not sure why but only calling directly to put_unalinged_le32 fixes
> this warning. In general put_unaligned should be expanded to this
> macro.
Yeah I was also just looking at it and couldn't make sense of it. It
seems sparse gets confused about the pointer type or something.
> I will submit patch that solves this.
Cool, thanks.
johannes
"Tomas Winkler" <[email protected]> writes:
> On Thu, Jul 10, 2008 at 12:10 PM, Johannes Berg
> <[email protected]> wrote:
>> Was just running sparse for something unrelated and noticed these:
>>
>> drivers/net/wireless/iwlwifi/iwl-rx.c:832:2: warning: cast truncates=
bits from constant value (1c00 becomes 0)
>> drivers/net/wireless/iwlwifi/iwl-rx.c:836:2: warning: cast truncates=
bits from constant value (6f080000 becomes 0)
>> drivers/net/wireless/iwlwifi/iwl-rx.c:836:2: warning: cast truncates=
bits from constant value (6f080000 becomes 0)
>> drivers/net/wireless/iwlwifi/iwl-rx.c:856:3: warning: cast truncates=
bits from constant value (4001 becomes 1)
>> drivers/net/wireless/iwlwifi/iwl-rx.c:860:3: warning: cast truncates=
bits from constant value (a000 becomes 0)
>> drivers/net/wireless/iwlwifi/iwl-rx.c:864:3: warning: cast truncates=
bits from constant value (c000 becomes 0)
>
> Yeah I've actually wanted to ask someone how to solve. This comes fro=
m
> radio tap code, frankly currently very low priority on my list.
> Not sure why but only calling directly to put_unalinged_le32 fixes
> this warning. In general put_unaligned should be expanded to this
> macro.
Only after constant folding. The put_unaligned macro itself contains
calls to all put_unaligned_be?? variants with corresponding casts, and
sparse does no constant folding here, apparently.
Andreas.
--=20
Andreas Schwab, SuSE Labs, [email protected]
SuSE Linux Products GmbH, Maxfeldstra=DFe 5, 90409 N=FCrnberg, Germany
PGP key fingerprint =3D 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4=
ED5
"And now for something completely different."
On Thu, Jul 10, 2008 at 12:10 PM, Johannes Berg
<[email protected]> wrote:
> Was just running sparse for something unrelated and noticed these:
>
> drivers/net/wireless/iwlwifi/iwl-rx.c:832:2: warning: cast truncates bits from constant value (1c00 becomes 0)
> drivers/net/wireless/iwlwifi/iwl-rx.c:836:2: warning: cast truncates bits from constant value (6f080000 becomes 0)
> drivers/net/wireless/iwlwifi/iwl-rx.c:836:2: warning: cast truncates bits from constant value (6f080000 becomes 0)
> drivers/net/wireless/iwlwifi/iwl-rx.c:856:3: warning: cast truncates bits from constant value (4001 becomes 1)
> drivers/net/wireless/iwlwifi/iwl-rx.c:860:3: warning: cast truncates bits from constant value (a000 becomes 0)
> drivers/net/wireless/iwlwifi/iwl-rx.c:864:3: warning: cast truncates bits from constant value (c000 becomes 0)
Yeah I've actually wanted to ask someone how to solve. This comes from
radio tap code, frankly currently very low priority on my list.
Not sure why but only calling directly to put_unalinged_le32 fixes
this warning. In general put_unaligned should be expanded to this
macro.
I will submit patch that solves this.
Thanks
Tomas