qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Marc-André Lureau" <marcandre.lureau@redhat.com>
To: Yao Xingtao <yaoxt.fnst@fujitsu.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH 12/13] dump: make range overlap check more readable
Date: Mon, 22 Jul 2024 11:01:11 +0400	[thread overview]
Message-ID: <CAMxuvawSh7H3yhN2nB91ggCebEhwo0n_92EBX=hhAK==WbnoUQ@mail.gmail.com> (raw)
In-Reply-To: <20240722040742.11513-13-yaoxt.fnst@fujitsu.com>

[-- Attachment #1: Type: text/plain, Size: 2025 bytes --]

On Mon, Jul 22, 2024 at 8:10 AM Yao Xingtao <yaoxt.fnst@fujitsu.com> wrote:

> 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>


> ---
>  dump/dump.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/dump/dump.c b/dump/dump.c
> index 84064d890d2c..45e84428aea5 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
>
>

[-- Attachment #2: Type: text/html, Size: 2991 bytes --]

  reply	other threads:[~2024-07-22  7:02 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-22  4:07 [PATCH 00/13] make range overlap check more readable Yao Xingtao via
2024-07-22  4:07 ` [PATCH 01/13] range: Make ranges_overlap() return bool Yao Xingtao via
2024-07-22  6:54   ` Philippe Mathieu-Daudé
2024-07-22  4:07 ` [PATCH 02/13] arm/boot: make range overlap check more readable Yao Xingtao via
2024-07-22  6:54   ` Philippe Mathieu-Daudé
2024-07-22  4:07 ` [PATCH 03/13] core/loader: " Yao Xingtao via
2024-07-22  4:07 ` [PATCH 04/13] cxl/mailbox: " Yao Xingtao via
2024-07-22  6:56   ` Philippe Mathieu-Daudé
2024-07-22  4:07 ` [PATCH 05/13] display/sm501: " Yao Xingtao via
2024-07-22  4:07 ` [PATCH 06/13] aspeed_smc: " Yao Xingtao via
2024-07-22  7:11   ` Philippe Mathieu-Daudé
2024-07-22  4:07 ` [PATCH 07/13] qtest/fuzz: " Yao Xingtao via
2024-07-22  5:03   ` Alexander Bulekov
2024-07-22  7:10   ` Philippe Mathieu-Daudé
2024-07-22  4:07 ` [PATCH 08/13] sparc/ldst_helper: " Yao Xingtao via
2024-07-22 12:18   ` Philippe Mathieu-Daudé
2024-07-22  4:07 ` [PATCH 09/13] system/memory_mapping: " Yao Xingtao via
2024-07-22  7:21   ` Philippe Mathieu-Daudé
2024-07-22  9:13   ` David Hildenbrand
2024-07-22  4:07 ` [PATCH 10/13] block/vhdx: " Yao Xingtao via
2024-07-22  4:07 ` [PATCH 11/13] crypto/block-luks: " Yao Xingtao via
2024-07-22  7:13   ` Philippe Mathieu-Daudé
2024-07-22  7:57   ` Daniel P. Berrangé
2024-07-22  4:07 ` [PATCH 12/13] dump: " Yao Xingtao via
2024-07-22  7:01   ` Marc-André Lureau [this message]
2024-07-22  4:07 ` [PATCH 13/13] block/qcow2-cluster: " Yao Xingtao via
2024-08-20  3:15   ` Xingtao Yao (Fujitsu) via
2024-07-22  6:42 ` [PATCH 00/13] " Philippe Mathieu-Daudé
2024-07-22  6:59   ` Xingtao Yao (Fujitsu) via
2024-07-22  7:37     ` Philippe Mathieu-Daudé
2024-07-22  7:40       ` Xingtao Yao (Fujitsu) via
2024-09-07  5:50         ` Philippe Mathieu-Daudé
2024-07-25 15:13     ` Peter Maydell
2024-07-26  0:16       ` Xingtao Yao (Fujitsu) via
2024-07-26  9:37         ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAMxuvawSh7H3yhN2nB91ggCebEhwo0n_92EBX=hhAK==WbnoUQ@mail.gmail.com' \
    --to=marcandre.lureau@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=yaoxt.fnst@fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).