[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 17/28] dump: make range overlap check more readable
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 17/28] dump: make range overlap check more readable |
Date: |
Tue, 23 Jul 2024 22:38:44 +0200 |
From: Yao Xingtao <yaoxt.fnst@fujitsu.com>
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: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20240722040742.11513-13-yaoxt.fnst@fujitsu.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
dump/dump.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/dump/dump.c b/dump/dump.c
index 84064d890d2..45e84428aea 100644
--- a/dump/dump.c
+++ b/dump/dump.c
@@ -30,6 +30,7 @@
#include "migration/blocker.h"
#include "hw/core/cpu.h"
#include "win_dump.h"
+#include "qemu/range.h"
#include <zlib.h>
#ifdef CONFIG_LZO
@@ -574,8 +575,10 @@ static void get_offset_range(hwaddr phys_addr,
QTAILQ_FOREACH(block, &s->guest_phys_blocks.head, next) {
if (dump_has_filter(s)) {
- if (block->target_start >= s->filter_area_begin +
s->filter_area_length ||
- block->target_end <= s->filter_area_begin) {
+ if (!ranges_overlap(block->target_start,
+ block->target_end - block->target_start,
+ s->filter_area_begin,
+ s->filter_area_length)) {
/* This block is out of the range */
continue;
}
@@ -734,8 +737,9 @@ int64_t dump_filtered_memblock_start(GuestPhysBlock *block,
{
if (filter_area_length) {
/* return -1 if the block is not within filter area */
- if (block->target_start >= filter_area_start + filter_area_length ||
- block->target_end <= filter_area_start) {
+ if (!ranges_overlap(block->target_start,
+ block->target_end - block->target_start,
+ filter_area_start, filter_area_length)) {
return -1;
}
--
2.41.0
- [PULL 09/28] docs/interop/firmware.json: convert "Example" section, (continued)
- [PULL 09/28] docs/interop/firmware.json: convert "Example" section, Philippe Mathieu-Daudé, 2024/07/23
- [PULL 10/28] hw/i2c/mpc_i2c: Fix mmio region size, Philippe Mathieu-Daudé, 2024/07/23
- [PULL 11/28] hw/mips/loongson3_virt: remove useless type cast, Philippe Mathieu-Daudé, 2024/07/23
- [PULL 12/28] util/range: Make ranges_overlap() return bool, Philippe Mathieu-Daudé, 2024/07/23
- [PULL 15/28] system/memory_mapping: make range overlap check more readable, Philippe Mathieu-Daudé, 2024/07/23
- [PULL 14/28] sparc/ldst_helper: make range overlap check more readable, Philippe Mathieu-Daudé, 2024/07/23
- [PULL 13/28] cxl/mailbox: make range overlap check more readable, Philippe Mathieu-Daudé, 2024/07/23
- [PULL 16/28] crypto/block-luks: make range overlap check more readable, Philippe Mathieu-Daudé, 2024/07/23
- [PULL 18/28] hw/nubus/virtio-mmio: Fix missing ERRP_GUARD() in realize handler, Philippe Mathieu-Daudé, 2024/07/23
- [PULL 19/28] hw/char/goldfish: Use DMA memory API, Philippe Mathieu-Daudé, 2024/07/23
- [PULL 17/28] dump: make range overlap check more readable,
Philippe Mathieu-Daudé <=
- [PULL 20/28] chardev/char-fe: Document returned value on error, Philippe Mathieu-Daudé, 2024/07/23
- [PULL 21/28] util/fifo8: Fix style, Philippe Mathieu-Daudé, 2024/07/23
- [PULL 22/28] util/fifo8: Use fifo8_reset() in fifo8_create(), Philippe Mathieu-Daudé, 2024/07/23
- [PULL 23/28] util/fifo8: Rename fifo8_peek_buf() -> fifo8_peek_bufptr(), Philippe Mathieu-Daudé, 2024/07/23
- [PULL 24/28] util/fifo8: Rename fifo8_pop_buf() -> fifo8_pop_bufptr(), Philippe Mathieu-Daudé, 2024/07/23
- [PULL 25/28] util/fifo8: Expose fifo8_pop_buf(), Philippe Mathieu-Daudé, 2024/07/23
- [PULL 27/28] MAINTAINERS: Cover guest-agent in QAPI schema, Philippe Mathieu-Daudé, 2024/07/23
- [PULL 28/28] MAINTAINERS: Add myself as a reviewer of machine core, Philippe Mathieu-Daudé, 2024/07/23
- [PULL 26/28] util/fifo8: Introduce fifo8_drop(), Philippe Mathieu-Daudé, 2024/07/23
- Re: [PULL 00/28] Misc HW+ patches for 2024-07-23, Richard Henderson, 2024/07/24