[PATCH v2] arm: fix clang build warning in include/asm/memory.h

Yipeng Zou zouyipeng at huawei.com
Fri Apr 12 19:31:36 PDT 2024


在 2024/3/28 16:16, Linus Walleij 写道:
> On Thu, Mar 21, 2024 at 2:36 AM Yipeng Zou<zouyipeng at huawei.com>  wrote:
>
>> There is a build error has been founded with build in clang-15.0.4:
>>
>> ./arch/arm/include/asm/memory.h:358:12: error: result of comparison "phys addr_t’ (aka 'unsigned int’) > 4294967295 is always false [-Werror, -Wtautological-type-limit-compare]
>>                               if (addr > (u32)~0)
>>                                   ~~~~ ^ ~~~~~~~
>>
>> It will be always goes fail without CONFIG_PHYS_ADDR_T_64BIT.
>>
>> Directly silence it by Use CONFIG_PHYS_ADDR_T_64BIT.
>>
>> Fixes: 981b6714dbd2 ("ARM: provide improved virt_to_idmap() functionality")
>> Signed-off-by: Yipeng Zou<zouyipeng at huawei.com>
>> ---
>> V2: IDMAP_INVALID_ADDR was used in other place, keep it defined.
>>   arch/arm/include/asm/memory.h | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
>> index ef2aa79ece5a..07c7e759d04c 100644
>> --- a/arch/arm/include/asm/memory.h
>> +++ b/arch/arm/include/asm/memory.h
>> @@ -353,8 +353,10 @@ static inline unsigned long phys_to_idmap(phys_addr_t addr)
>>   {
>>          if (IS_ENABLED(CONFIG_MMU) && arch_phys_to_idmap_offset) {
>>                  addr += arch_phys_to_idmap_offset;
>> +#ifdef CONFIG_PHYS_ADDR_T_64BIT
>>                  if (addr > (u32)~0)
> What about my suggestion:
>
> #include <linux/limits.h>
>
> if (addr > U32_MAX)
>
> ?
>
> Yours,
> Linus Walleij

Hi:

     I just miss it, sorry for that.

     Yes indeed, is clearer by use U32_MAX here.

     Add it in V3 thanks for review.

     V3: 
https://lore.kernel.org/all/20240413022843.1730174-1-zouyipeng@huawei.com/

> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

-- 
Regards,
Yipeng Zou




More information about the linux-arm-kernel mailing list