diff mbox series

[03/13] core/loader: make range overlap check more readable

Message ID 20240722040742.11513-4-yaoxt.fnst@fujitsu.com (mailing list archive)
State New, archived
Headers show
Series make range overlap check more readable | expand

Commit Message

Xingtao Yao (Fujitsu) July 22, 2024, 4:07 a.m. UTC
use ranges_overlap() instead of open-coding the overlap check to improve
the readability of the code.

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

Patch

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)