[PATCH 2/4] dump/dump.c: reorder usage and assertion of block

Sergei Heifetz posted 4 patches 5 days, 14 hours ago
Maintainers: "Marc-André Lureau" <marcandre.lureau@redhat.com>, Ani Sinha <anisinha@redhat.com>, Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>, Paolo Bonzini <pbonzini@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>
There is a newer version of this series
[PATCH 2/4] dump/dump.c: reorder usage and assertion of block
Posted by Sergei Heifetz 5 days, 14 hours ago
Reorder the code so the assertion of block occurs before it is
used in the subsequent lines.

Signed-off-by: Sergei Heifetz <heifetz@yandex-team.com>
---
 dump/dump.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/dump/dump.c b/dump/dump.c
index f7a99a7af2..80ed6c8d21 100644
--- a/dump/dump.c
+++ b/dump/dump.c
@@ -1288,6 +1288,7 @@ static bool get_next_page(GuestPhysBlock **blockptr, uint64_t *pfnptr,
     /* block == NULL means the start of the iteration */
     if (!block) {
         block = QTAILQ_FIRST(&s->guest_phys_blocks.head);
+        assert(block);
         *blockptr = block;
         addr = block->target_start;
         *pfnptr = dump_paddr_to_pfn(s, addr);
@@ -1295,7 +1296,6 @@ static bool get_next_page(GuestPhysBlock **blockptr, uint64_t *pfnptr,
         *pfnptr += 1;
         addr = dump_pfn_to_paddr(s, *pfnptr);
     }
-    assert(block != NULL);
 
     while (1) {
         if (addr >= block->target_start && addr < block->target_end) {
-- 
2.34.1
Re: [PATCH 2/4] dump/dump.c: reorder usage and assertion of block
Posted by Laurent Vivier 5 days, 9 hours ago
Le 04/02/2026 à 08:57, Sergei Heifetz a écrit :
> Reorder the code so the assertion of block occurs before it is
> used in the subsequent lines.
> 
> Signed-off-by: Sergei Heifetz <heifetz@yandex-team.com>
> ---
>   dump/dump.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/dump/dump.c b/dump/dump.c
> index f7a99a7af2..80ed6c8d21 100644
> --- a/dump/dump.c
> +++ b/dump/dump.c
> @@ -1288,6 +1288,7 @@ static bool get_next_page(GuestPhysBlock **blockptr, uint64_t *pfnptr,
>       /* block == NULL means the start of the iteration */
>       if (!block) {
>           block = QTAILQ_FIRST(&s->guest_phys_blocks.head);
> +        assert(block);
>           *blockptr = block;
>           addr = block->target_start;
>           *pfnptr = dump_paddr_to_pfn(s, addr);
> @@ -1295,7 +1296,6 @@ static bool get_next_page(GuestPhysBlock **blockptr, uint64_t *pfnptr,
>           *pfnptr += 1;
>           addr = dump_pfn_to_paddr(s, *pfnptr);
>       }
> -    assert(block != NULL);
>   
>       while (1) {
>           if (addr >= block->target_start && addr < block->target_end) {

Reviewed-by: Laurent Vivier <laurent@vivier.eu>