aboutsummaryrefslogtreecommitdiff
path: root/system
diff options
context:
space:
mode:
authorYao Xingtao <yaoxt.fnst@fujitsu.com>2024-07-22 00:07:38 -0400
committerPhilippe Mathieu-Daudé <philmd@linaro.org>2024-07-23 20:30:36 +0200
commit13c59a0e9efad5154ff4aba46d5d645c99af8fcf (patch)
tree2be55c7c0dd6a5f07339a855b8f046774cc827e8 /system
parent2a48b590f7479b93623e650642aee2fce015bbd3 (diff)
system/memory_mapping: make range overlap check more readable
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> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: David Hildenbrand <david@redhat.com> Message-ID: <20240722040742.11513-10-yaoxt.fnst@fujitsu.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Diffstat (limited to 'system')
-rw-r--r--system/memory_mapping.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/system/memory_mapping.c b/system/memory_mapping.c
index 6f884c5b90..ca2390eb80 100644
--- a/system/memory_mapping.c
+++ b/system/memory_mapping.c
@@ -12,6 +12,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/range.h"
#include "qapi/error.h"
#include "sysemu/memory_mapping.h"
@@ -353,8 +354,7 @@ void memory_mapping_filter(MemoryMappingList *list, int64_t begin,
MemoryMapping *cur, *next;
QTAILQ_FOREACH_SAFE(cur, &list->head, next, next) {
- if (cur->phys_addr >= begin + length ||
- cur->phys_addr + cur->length <= begin) {
+ if (!ranges_overlap(cur->phys_addr, cur->length, begin, length)) {
QTAILQ_REMOVE(&list->head, cur, next);
g_free(cur);
list->num--;