qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Chen Qun <kuhn.chenqun@huawei.com>
Cc: peter.maydell@linaro.org, zhang.zhanghailiang@huawei.com,
	"Juan Quintela" <quintela@redhat.com>,
	qemu-trivial@nongnu.org, qemu-devel@nongnu.org,
	ganqixin@huawei.com, "Euler Robot" <euler.robot@huawei.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: Re: [PATCH v2 5/5] migration: fix uninitialized variable warning in migrate_send_rp_req_pages()
Date: Thu, 12 Nov 2020 14:49:33 +0000	[thread overview]
Message-ID: <20201112144933.GD13424@work-vm> (raw)
In-Reply-To: <20201111142203.2359370-6-kuhn.chenqun@huawei.com>

* Chen Qun (kuhn.chenqun@huawei.com) wrote:
> After the WITH_QEMU_LOCK_GUARD macro is added, the compiler cannot identify
>  that the statements in the macro must be executed. As a result, some variables
>  assignment statements in the macro may be considered as unexecuted by the compiler.
> 
> When the -Wmaybe-uninitialized capability is enabled on GCC9,the compiler showed warning:
> migration/migration.c: In function ‘migrate_send_rp_req_pages’:
> migration/migration.c:384:8: warning: ‘received’ may be used uninitialized in this function [-Wmaybe-uninitialized]
>  384 |     if (received) {
>      |        ^
> 
> Add a default value for 'received' to prevented the warning.
> 
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

Queuing this one via migration

> ---
> Cc: Juan Quintela <quintela@redhat.com>
> Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> ---
>  migration/migration.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/migration/migration.c b/migration/migration.c
> index 9bb4fee5ac..de90486a61 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -361,7 +361,7 @@ int migrate_send_rp_req_pages(MigrationIncomingState *mis,
>                                RAMBlock *rb, ram_addr_t start, uint64_t haddr)
>  {
>      void *aligned = (void *)(uintptr_t)(haddr & (-qemu_ram_pagesize(rb)));
> -    bool received;
> +    bool received = false;
>  
>      WITH_QEMU_LOCK_GUARD(&mis->page_request_mutex) {
>          received = ramblock_recv_bitmap_test_byte_offset(rb, start);
> -- 
> 2.27.0
> 
> 
-- 
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



  reply	other threads:[~2020-11-12 14:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-11 14:21 [PATCH v2 0/5] fix uninitialized variable warning Chen Qun
2020-11-11 14:21 ` [PATCH v2 1/5] hw/rdma/rdma_backend: fix uninitialized variable warning in rdma_poll_cq() Chen Qun
2020-11-11 14:22 ` [PATCH v2 2/5] util/qemu-timer: fix uninitialized variable warning in timer_mod_anticipate_ns() Chen Qun
2020-11-11 14:22 ` [PATCH v2 3/5] util/qemu-timer: fix uninitialized variable warning for expire_time Chen Qun
2020-11-11 14:22 ` [PATCH v2 4/5] plugins/loader: fix uninitialized variable warning in plugin_reset_uninstall() Chen Qun
2020-11-11 17:22   ` Alex Bennée
2020-11-13  5:53     ` Chenqun (kuhn)
2020-11-11 14:22 ` [PATCH v2 5/5] migration: fix uninitialized variable warning in migrate_send_rp_req_pages() Chen Qun
2020-11-12 14:49   ` Dr. David Alan Gilbert [this message]
2020-12-11  2:39 ` [PATCH v2 0/5] fix uninitialized variable warning Chenqun (kuhn)

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=20201112144933.GD13424@work-vm \
    --to=dgilbert@redhat.com \
    --cc=euler.robot@huawei.com \
    --cc=ganqixin@huawei.com \
    --cc=kuhn.chenqun@huawei.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=zhang.zhanghailiang@huawei.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).