From: Max Filippov <jcmvbkbc@gmail.com>
To: Chen Qun <kuhn.chenqun@huawei.com>
Cc: QEMU Trivial <qemu-trivial@nongnu.org>,
Euler Robot <euler.robot@huawei.com>,
qemu-devel <qemu-devel@nongnu.org>,
ganqixin@huawei.com, zhang.zhanghailiang@huawei.com
Subject: Re: [PATCH 1/6] target/xtensa: fix uninitialized variable warning
Date: Tue, 3 Nov 2020 01:21:43 -0800 [thread overview]
Message-ID: <CAMo8BfK5wDgvzWFsC0WHyztUCiGR0dGnJgJiAVt5aG7nt8PsDw@mail.gmail.com> (raw)
In-Reply-To: <20201103015228.2250547-2-kuhn.chenqun@huawei.com>
On Mon, Nov 2, 2020 at 5:52 PM Chen Qun <kuhn.chenqun@huawei.com> wrote:
>
> The compiler cannot determine whether the return values of the xtensa_operand_is_register(isa, opc, opnd)
> and xtensa_operand_is_visible(isa, opc, opnd) functions are the same.
It doesn't have to because 1) they definitely are not the same, but
2) it doesn't matter.
> So,it assumes that 'rf' is not assigned, but it's used.
The assumption is wrong. rf is used under the 'if (register_file)'
condition and register_file is initialized to NULL and then set
to something non-NULL based on the value of rf here:
958 if (xtensa_operand_is_register(isa, opc, opnd)) {
959 rf = xtensa_operand_regfile(isa, opc, opnd);
960 register_file = dc->config->regfile[rf];
> The compiler showed warning:
> target/xtensa/translate.c: In function ‘disas_xtensa_insn’:
> target/xtensa/translate.c:985:43: warning: ‘rf’ may be used uninitialized in this function [-Wmaybe-uninitialized]
> 985 | arg[vopnd].num_bits = xtensa_regfile_num_bits(isa, rf);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Add a default value for 'rf' to prevented the warning.
I don't see it doing default build with gcc 8.3. But then I don't see
-Wmaybe-uninitialized in the compiler command line either.
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
> ---
> Cc: Max Filippov <jcmvbkbc@gmail.com>
> ---
> target/xtensa/translate.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c
> index 944a157747..eea851bbe7 100644
> --- a/target/xtensa/translate.c
> +++ b/target/xtensa/translate.c
> @@ -953,7 +953,7 @@ static void disas_xtensa_insn(CPUXtensaState *env, DisasContext *dc)
>
> for (opnd = vopnd = 0; opnd < opnds; ++opnd) {
> void **register_file = NULL;
> - xtensa_regfile rf;
> + xtensa_regfile rf = -1;
Please use XTENSA_UNDEFINED instead if you still think this
is worth changing.
--
Thanks.
-- Max
next prev parent reply other threads:[~2020-11-03 9:23 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-03 1:52 [PATCH 0/6] fix uninitialized variable warning Chen Qun
2020-11-03 1:52 ` [PATCH 1/6] target/xtensa: " Chen Qun
2020-11-03 2:27 ` Philippe Mathieu-Daudé
2020-11-03 9:21 ` Max Filippov [this message]
2020-11-04 3:03 ` Chenqun (kuhn)
2020-11-03 1:52 ` [PATCH 2/6] hw/rdma/rdma_backend: fix uninitialized variable warning in rdma_poll_cq() Chen Qun
2020-11-03 16:41 ` Marcel Apfelbaum
2020-11-03 19:49 ` Yuval Shaia
2020-11-03 1:52 ` [PATCH 3/6] util/qemu-timer: fix uninitialized variable warning in timer_mod_anticipate_ns() Chen Qun
2020-11-03 2:13 ` Philippe Mathieu-Daudé
2020-11-03 1:52 ` [PATCH 4/6] util/qemu-timer: fix uninitialized variable warning for expire_time Chen Qun
2020-11-03 1:52 ` [PATCH 5/6] plugins/loader: fix uninitialized variable warning in plugin_reset_uninstall() Chen Qun
2020-11-03 2:18 ` Philippe Mathieu-Daudé
2020-11-03 2:34 ` Chenqun (kuhn)
2020-11-03 1:52 ` [PATCH 6/6] migration: fix uninitialized variable warning in migrate_send_rp_req_pages() Chen Qun
2020-11-03 2:22 ` Philippe Mathieu-Daudé
2020-11-03 10:15 ` [PATCH 0/6] fix uninitialized variable warning Peter Maydell
2020-11-03 10:44 ` 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=CAMo8BfK5wDgvzWFsC0WHyztUCiGR0dGnJgJiAVt5aG7nt8PsDw@mail.gmail.com \
--to=jcmvbkbc@gmail.com \
--cc=euler.robot@huawei.com \
--cc=ganqixin@huawei.com \
--cc=kuhn.chenqun@huawei.com \
--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).