All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: jianchunfu <jianchunfu@cmss.chinamobile.com>
Cc: richard.henderson@linaro.org, qemu-devel@nongnu.org, quintela@redhat.com
Subject: Re: [PATCH] migration/dirtyrate: Replace malloc with g_new
Date: Mon, 11 Apr 2022 12:30:49 +0100	[thread overview]
Message-ID: <YlQRaSNLx72WS1TN@work-vm> (raw)
In-Reply-To: <20220411094703.7000-1-jianchunfu@cmss.chinamobile.com>

* jianchunfu (jianchunfu@cmss.chinamobile.com) wrote:
> Using macro g_new() to handling potential memory allocation failures
> in dirtyrate.
> 
> Signed-off-by: jianchunfu <jianchunfu@cmss.chinamobile.com>
> ---
>  migration/dirtyrate.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/migration/dirtyrate.c b/migration/dirtyrate.c
> index aace12a787..0e59aacbb0 100644
> --- a/migration/dirtyrate.c
> +++ b/migration/dirtyrate.c
> @@ -522,10 +522,10 @@ static void calculate_dirtyrate_dirty_ring(struct DirtyRateConfig config)
>          nvcpu++;
>      }
>  
> -    dirty_pages = malloc(sizeof(*dirty_pages) * nvcpu);
> +    dirty_pages = g_new(DirtyPageRecord, nvcpu);
>  
>      DirtyStat.dirty_ring.nvcpu = nvcpu;
> -    DirtyStat.dirty_ring.rates = malloc(sizeof(DirtyRateVcpu) * nvcpu);
> +    DirtyStat.dirty_ring.rates = g_new(DirtyRateVcpu, nvcpu);
>  
>      dirtyrate_global_dirty_log_start();

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

>  
> -- 
> 2.18.4
> 
> 
> 
-- 
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



  reply	other threads:[~2022-04-11 11:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-11  9:47 [PATCH] migration/dirtyrate: Replace malloc with g_new jianchunfu
2022-04-11 11:30 ` Dr. David Alan Gilbert [this message]
2022-04-11 18:08 ` Richard Henderson
2022-04-11 21:44 ` 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=YlQRaSNLx72WS1TN@work-vm \
    --to=dgilbert@redhat.com \
    --cc=jianchunfu@cmss.chinamobile.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=richard.henderson@linaro.org \
    /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.