Skip to content

Commit 1aef448

Browse files
sailer1205philmd
authored andcommitted
dump: 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 <[email protected]> Reviewed-by: Marc-André Lureau <[email protected]> Message-ID: <[email protected]> Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
1 parent 7cd9b9d commit 1aef448

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

dump/dump.c

+8-4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "migration/blocker.h"
3131
#include "hw/core/cpu.h"
3232
#include "win_dump.h"
33+
#include "qemu/range.h"
3334

3435
#include <zlib.h>
3536
#ifdef CONFIG_LZO
@@ -574,8 +575,10 @@ static void get_offset_range(hwaddr phys_addr,
574575

575576
QTAILQ_FOREACH(block, &s->guest_phys_blocks.head, next) {
576577
if (dump_has_filter(s)) {
577-
if (block->target_start >= s->filter_area_begin + s->filter_area_length ||
578-
block->target_end <= s->filter_area_begin) {
578+
if (!ranges_overlap(block->target_start,
579+
block->target_end - block->target_start,
580+
s->filter_area_begin,
581+
s->filter_area_length)) {
579582
/* This block is out of the range */
580583
continue;
581584
}
@@ -734,8 +737,9 @@ int64_t dump_filtered_memblock_start(GuestPhysBlock *block,
734737
{
735738
if (filter_area_length) {
736739
/* return -1 if the block is not within filter area */
737-
if (block->target_start >= filter_area_start + filter_area_length ||
738-
block->target_end <= filter_area_start) {
740+
if (!ranges_overlap(block->target_start,
741+
block->target_end - block->target_start,
742+
filter_area_start, filter_area_length)) {
739743
return -1;
740744
}
741745

0 commit comments

Comments
 (0)