qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: Chen Qun <kuhn.chenqun@huawei.com>
Cc: peter.maydell@linaro.org, zhang.zhanghailiang@huawei.com,
	qemu-trivial@nongnu.org, qemu-devel@nongnu.org,
	ganqixin@huawei.com, Euler Robot <euler.robot@huawei.com>
Subject: Re: [PATCH v2 4/5] plugins/loader: fix uninitialized variable warning in plugin_reset_uninstall()
Date: Wed, 11 Nov 2020 17:22:53 +0000	[thread overview]
Message-ID: <87d00j7qqa.fsf@linaro.org> (raw)
In-Reply-To: <20201111142203.2359370-5-kuhn.chenqun@huawei.com>


Chen Qun <kuhn.chenqun@huawei.com> writes:

> 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:
> plugins/loader.c: In function ‘plugin_reset_uninstall’:
> plugins/loader.c:382:15: warning: ‘ctx’ may be used uninitialized in this function [-Wmaybe-uninitialized]
>  382 |     data->ctx = ctx;
>      |     ~~~~~~~~~~^~~~~
>
> Add a default value for 'expire_time' to prevented the warning.
>
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
> ---
> Cc: "Alex Bennée" <alex.bennee@linaro.org>
> ---
>  plugins/loader.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/plugins/loader.c b/plugins/loader.c
> index 8ac5dbc20f..88593fe138 100644
> --- a/plugins/loader.c
> +++ b/plugins/loader.c
> @@ -367,7 +367,7 @@ void plugin_reset_uninstall(qemu_plugin_id_t id,
>                              bool reset)
>  {
>      struct qemu_plugin_reset_data *data;
> -    struct qemu_plugin_ctx *ctx;
> +    struct qemu_plugin_ctx *ctx = NULL;

This doesn't really fix anything because you would end up faulting if
you attempted to de-ref a NULL ctx. However...

>  
>      WITH_QEMU_LOCK_GUARD(&plugin.lock) {
>          ctx = plugin_id_to_ctx_locked(id);

...this can't fail. If the lookup failed and returned a NULL plugin then
we would abort(). So why can't the Euler Robot see that?

-- 
Alex Bennée


  reply	other threads:[~2020-11-11 17:24 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 [this message]
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
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=87d00j7qqa.fsf@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=euler.robot@huawei.com \
    --cc=ganqixin@huawei.com \
    --cc=kuhn.chenqun@huawei.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --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).