mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 04:13:53 -06:00
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>
This commit is contained in:
parent
2a48b590f7
commit
13c59a0e9e
1 changed files with 2 additions and 2 deletions
|
@ -12,6 +12,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
|
#include "qemu/range.h"
|
||||||
#include "qapi/error.h"
|
#include "qapi/error.h"
|
||||||
|
|
||||||
#include "sysemu/memory_mapping.h"
|
#include "sysemu/memory_mapping.h"
|
||||||
|
@ -353,8 +354,7 @@ void memory_mapping_filter(MemoryMappingList *list, int64_t begin,
|
||||||
MemoryMapping *cur, *next;
|
MemoryMapping *cur, *next;
|
||||||
|
|
||||||
QTAILQ_FOREACH_SAFE(cur, &list->head, next, next) {
|
QTAILQ_FOREACH_SAFE(cur, &list->head, next, next) {
|
||||||
if (cur->phys_addr >= begin + length ||
|
if (!ranges_overlap(cur->phys_addr, cur->length, begin, length)) {
|
||||||
cur->phys_addr + cur->length <= begin) {
|
|
||||||
QTAILQ_REMOVE(&list->head, cur, next);
|
QTAILQ_REMOVE(&list->head, cur, next);
|
||||||
g_free(cur);
|
g_free(cur);
|
||||||
list->num--;
|
list->num--;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue