All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fabiano Rosas <farosas@suse.de>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>, qemu-devel@nongnu.org
Cc: "Leonardo Bras" <leobras@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Peter Xu" <peterx@redhat.com>,
	"Juan Quintela" <quintela@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: Re: [PATCH] migration: Use g_autofree to simplify ram_dirty_bitmap_reload()
Date: Mon, 09 Oct 2023 12:07:36 -0300	[thread overview]
Message-ID: <871qe3g7gn.fsf@suse.de> (raw)
In-Reply-To: <20231008114001.95348-1-philmd@linaro.org>

Philippe Mathieu-Daudé <philmd@linaro.org> writes:

> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> Based-on: <ZR7e3cmxCH9LAdnS@x1n>
> ---
>  migration/ram.c | 15 ++++++---------
>  1 file changed, 6 insertions(+), 9 deletions(-)
>
> diff --git a/migration/ram.c b/migration/ram.c
> index 982fbbeee1..4cb948cfd0 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -4164,11 +4164,11 @@ bool ram_dirty_bitmap_reload(MigrationState *s, RAMBlock *block, Error **errp)
>  {
>      /* from_dst_file is always valid because we're within rp_thread */
>      QEMUFile *file = s->rp_state.from_dst_file;
> -    unsigned long *le_bitmap, nbits = block->used_length >> TARGET_PAGE_BITS;
> +    unsigned long *le_bitmap = NULL;

Aren't you missing the actual g_autofree here?

> +    unsigned long nbits = block->used_length >> TARGET_PAGE_BITS;
>      uint64_t local_size = DIV_ROUND_UP(nbits, 8);
>      uint64_t size, end_mark;
>      RAMState *rs = ram_state;
> -    bool result = false;
>  
>      trace_ram_dirty_bitmap_reload_begin(block->idstr);
>  
> @@ -4193,7 +4193,7 @@ bool ram_dirty_bitmap_reload(MigrationState *s, RAMBlock *block, Error **errp)
>      if (size != local_size) {
>          error_setg(errp, "ramblock '%s' bitmap size mismatch (0x%"PRIx64
>                     " != 0x%"PRIx64")", block->idstr, size, local_size);
> -        goto out;
> +        return false;
>      }
>  
>      size = qemu_get_buffer(file, (uint8_t *)le_bitmap, local_size);
> @@ -4203,13 +4203,13 @@ bool ram_dirty_bitmap_reload(MigrationState *s, RAMBlock *block, Error **errp)
>          error_setg(errp, "read bitmap failed for ramblock '%s': "
>                     "(size 0x%"PRIx64", got: 0x%"PRIx64")",
>                     block->idstr, local_size, size);
> -        goto out;
> +        return false;
>      }
>  
>      if (end_mark != RAMBLOCK_RECV_BITMAP_ENDING) {
>          error_setg(errp, "ramblock '%s' end mark incorrect: 0x%"PRIx64,
>                     block->idstr, end_mark);
> -        goto out;
> +        return false;
>      }
>  
>      /*
> @@ -4241,10 +4241,7 @@ bool ram_dirty_bitmap_reload(MigrationState *s, RAMBlock *block, Error **errp)
>       */
>      migration_rp_kick(s);
>  
> -    result = true;
> -out:
> -    g_free(le_bitmap);
> -    return result;
> +    return true;
>  }
>  
>  static int ram_resume_prepare(MigrationState *s, void *opaque)


  reply	other threads:[~2023-10-09 15:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-08 11:40 [PATCH] migration: Use g_autofree to simplify ram_dirty_bitmap_reload() Philippe Mathieu-Daudé
2023-10-09 15:07 ` Fabiano Rosas [this message]
2023-10-09 15:42   ` Philippe Mathieu-Daudé

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=871qe3g7gn.fsf@suse.de \
    --to=farosas@suse.de \
    --cc=armbru@redhat.com \
    --cc=leobras@redhat.com \
    --cc=peterx@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.