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

Linus Walleij linus.walleij at linaro.org
Fri Mar 15 06:16:23 PDT 2024


On Fri, Mar 15, 2024 at 11:08 AM Russell King (Oracle)
<linux at armlinux.org.uk> wrote:
> On Fri, Mar 15, 2024 at 08:40:28AM +0100, Linus Walleij wrote:
> > +1 and I would probably use this as well:
> >
> > <linux/limits.h>
> >
> > #define IDMAP_INVALID_ADDR    PHYS_ADDR_MAX
> >
> > if (IS_ENABLED(CONFIG_PHYS_ADDR_T_64BIT) && addr > PHYS_ADDR_MAX)
> >     addr = IDMAP_INVALID_ADDR;
> >
> > Because then it is clear what is going on: we are capping to the max physical
> > address.
> >
> > PHYS_ADDR_MAX is defined to (~(phys_addr_t)0) which on
> > ARM is (~(u32)0).
>
> ... which is _not_ the same as (u32)~0, so using PHYS_ADDR_MAX is not
> appropriate.

Attention to detail! Thanks Russell.

However U32_MAX is
#define U32_MAX         ((u32)~0U)

So that should work and also convey the attention I think?

Yours,
Linus Walleij



More information about the linux-arm-kernel mailing list