diff mbox series

[5/5] dump: Drop redundant check for empty dump

Message ID 20231030133712.2822276-6-armbru@redhat.com
State New
Headers show
Series dump: Minor fixes & improvements | expand

Commit Message

Markus Armbruster Oct. 30, 2023, 1:37 p.m. UTC
dump_init() first computes the size of the dump, taking the filter
area into account, and fails if its zero.  It then looks for memory in
the filter area, and fails if there is none.

This is redundant: if the size of the dump is zero, there is no
memory, and vice versa.  Delete this check.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 dump/dump.c | 26 --------------------------
 1 file changed, 26 deletions(-)

Comments

Marc-André Lureau Oct. 31, 2023, 10:23 a.m. UTC | #1
On Mon, Oct 30, 2023 at 5:37 PM Markus Armbruster <armbru@redhat.com> wrote:
>
> dump_init() first computes the size of the dump, taking the filter
> area into account, and fails if its zero.  It then looks for memory in
> the filter area, and fails if there is none.
>
> This is redundant: if the size of the dump is zero, there is no
> memory, and vice versa.  Delete this check.
>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

> ---
>  dump/dump.c | 26 --------------------------
>  1 file changed, 26 deletions(-)
>
> diff --git a/dump/dump.c b/dump/dump.c
> index d888e4bd3c..03627a4c17 100644
> --- a/dump/dump.c
> +++ b/dump/dump.c
> @@ -1674,26 +1674,6 @@ static void create_kdump_vmcore(DumpState *s, Error **errp)
>      }
>  }
>
> -static int validate_start_block(DumpState *s)
> -{
> -    GuestPhysBlock *block;
> -
> -    if (!dump_has_filter(s)) {
> -        return 0;
> -    }
> -
> -    QTAILQ_FOREACH(block, &s->guest_phys_blocks.head, next) {
> -        /* This block is out of the range */
> -        if (block->target_start >= s->filter_area_begin + s->filter_area_length ||
> -            block->target_end <= s->filter_area_begin) {
> -            continue;
> -        }
> -        return 0;
> -   }
> -
> -    return -1;
> -}
> -
>  static void get_max_mapnr(DumpState *s)
>  {
>      GuestPhysBlock *last_block;
> @@ -1842,12 +1822,6 @@ static void dump_init(DumpState *s, int fd, bool has_format,
>          goto cleanup;
>      }
>
> -    /* Is the filter filtering everything? */
> -    if (validate_start_block(s) == -1) {
> -        error_setg(errp, QERR_INVALID_PARAMETER, "begin");
> -        goto cleanup;
> -    }
> -
>      /* get dump info: endian, class and architecture.
>       * If the target architecture is not supported, cpu_get_dump_info() will
>       * return -1.
> --
> 2.41.0
>
>
diff mbox series

Patch

diff --git a/dump/dump.c b/dump/dump.c
index d888e4bd3c..03627a4c17 100644
--- a/dump/dump.c
+++ b/dump/dump.c
@@ -1674,26 +1674,6 @@  static void create_kdump_vmcore(DumpState *s, Error **errp)
     }
 }
 
-static int validate_start_block(DumpState *s)
-{
-    GuestPhysBlock *block;
-
-    if (!dump_has_filter(s)) {
-        return 0;
-    }
-
-    QTAILQ_FOREACH(block, &s->guest_phys_blocks.head, next) {
-        /* This block is out of the range */
-        if (block->target_start >= s->filter_area_begin + s->filter_area_length ||
-            block->target_end <= s->filter_area_begin) {
-            continue;
-        }
-        return 0;
-   }
-
-    return -1;
-}
-
 static void get_max_mapnr(DumpState *s)
 {
     GuestPhysBlock *last_block;
@@ -1842,12 +1822,6 @@  static void dump_init(DumpState *s, int fd, bool has_format,
         goto cleanup;
     }
 
-    /* Is the filter filtering everything? */
-    if (validate_start_block(s) == -1) {
-        error_setg(errp, QERR_INVALID_PARAMETER, "begin");
-        goto cleanup;
-    }
-
     /* get dump info: endian, class and architecture.
      * If the target architecture is not supported, cpu_get_dump_info() will
      * return -1.