use ranges_overlap() instead of open-coding the overlap check to improve
the readability of the code.

Signed-off-by: Yao Xingtao <yaoxt.f...@fujitsu.com>
---
 hw/core/loader.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/hw/core/loader.c b/hw/core/loader.c
index 31593a117171..dac0df561b16 100644
--- a/hw/core/loader.c
+++ b/hw/core/loader.c
@@ -63,6 +63,7 @@
 #include "qemu/cutils.h"
 #include "sysemu/runstate.h"
 #include "tcg/debuginfo.h"
+#include "qemu/range.h"
 
 #include <zlib.h>
 
@@ -1278,7 +1279,8 @@ static bool roms_overlap(Rom *last_rom, Rom *this_rom)
         return false;
     }
     return last_rom->as == this_rom->as &&
-        last_rom->addr + last_rom->romsize > this_rom->addr;
+        ranges_overlap(last_rom->addr, last_rom->romsize,
+                       this_rom->addr, this_rom->romsize);
 }
 
 static const char *rom_as_name(Rom *rom)
-- 
2.41.0


Reply via email to