[RFC PATCH 2/7] lmb: Simplify lmb_addrs_overlap()
Heinrich Schuchardt
xypron.glpk at gmx.de
Sun Dec 8 12:25:31 CET 2024
Am 8. Dezember 2024 11:52:05 MEZ schrieb Ilias Apalodimas <ilias.apalodimas at linaro.org>:
>There's no point subtracting -1 from the calculated addresses and then
>check for a <= b. Just remove the -1 and check for a < b.
I once thought that, too. But it makes a difference for end= U(L)LONG_MAX.
Best regards
Heinrich
>
>Signed-off-by: Ilias Apalodimas <ilias.apalodimas at linaro.org>
>---
> lib/lmb.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
>diff --git a/lib/lmb.c b/lib/lmb.c
>index a7ecbb58831f..c7bf5120696f 100644
>--- a/lib/lmb.c
>+++ b/lib/lmb.c
>@@ -36,10 +36,10 @@ DECLARE_GLOBAL_DATA_PTR;
> static long lmb_addrs_overlap(phys_addr_t base1, phys_size_t size1,
> phys_addr_t base2, phys_size_t size2)
> {
>- const phys_addr_t base1_end = base1 + size1 - 1;
>- const phys_addr_t base2_end = base2 + size2 - 1;
>+ const phys_addr_t base1_end = base1 + size1;
>+ const phys_addr_t base2_end = base2 + size2;
>
>- return ((base1 <= base2_end) && (base2 <= base1_end));
>+ return ((base1 < base2_end) && (base2 < base1_end));
> }
>
> static long lmb_addrs_adjacent(phys_addr_t base1, phys_size_t size1,
More information about the U-Boot
mailing list