[PATCH v3] net: stmmac: compare p->des0 and p->des1 with __le32 type values

Min-Hua Chen minhuadotchen at gmail.com
Mon May 22 08:36:15 PDT 2023


hi Edward,

>>> On Fri, 19 May 2023 19:50:28 +0800 Min-Hua Chen wrote:
>>>> -		if ((p->des0 == 0xffffffff) && (p->des1 == 0xffffffff))
>>>> +		if (p->des0 == cpu_to_le32(0xffffffff) &&
>>>> +		    p->des1 == cpu_to_le32(0xffffffff))
>>>
>>> Can you try to fix the sparse tool instead? I believe it already
>>> ignores such errors for the constant of 0, maybe it can be taught 
>>> to ignore all "isomorphic" values?
>>>
>> 
>> I downloaded the source code of sparse and I'm afraid that I cannot make
>> 0xFFFFFFFF ignored easily. I've tried ~0 instead of 0xFFFFFF,
>> but it did not work with current sparse.
>> 
>> 0 is a special case mentioned in [1].
>
>I believe you can do something like
>    if ((p->des0 == ~(__le32)0) && (p->des1 == ~(__le32)0))
> and sparse will accept that, because the cast is allowed under the
> special case.
>HTH,
>-ed

I tested ~(__le32)0 and it worked: sparse accpets this.
Thanks for sharing this.

cheers,
Min-Hua



More information about the linux-arm-kernel mailing list