* [PATCH] tests/plugin: prevent uninitialized warning
@ 2020-02-06 9:32 kuhn.chenqun
2020-02-06 10:19 ` Thomas Huth
2020-02-06 12:45 ` Alex Bennée
0 siblings, 2 replies; 5+ messages in thread
From: kuhn.chenqun @ 2020-02-06 9:32 UTC (permalink / raw)
To: qemu-devel, alex.bennee
Cc: qemu-trivial, Chen Qun, richard.henderson, zhang.zhanghailiang
From: Chen Qun <kuhn.chenqun@huawei.com>
According to the glibc function requirements, we need initialise
the variable. Otherwise there will be compilation warnings:
glib-autocleanups.h:28:3: warning: ‘out’ may be
used uninitialized in this function [-Wmaybe-uninitialized]
g_free (*pp);
^~~~~~~~~~~~
Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
---
tests/plugin/bb.c | 2 +-
tests/plugin/insn.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/plugin/bb.c b/tests/plugin/bb.c
index f30bea08dc..8b9da23a04 100644
--- a/tests/plugin/bb.c
+++ b/tests/plugin/bb.c
@@ -22,7 +22,7 @@ static bool do_inline;
static void plugin_exit(qemu_plugin_id_t id, void *p)
{
- g_autofree gchar *out;
+ g_autofree gchar *out = NULL;
out = g_strdup_printf("bb's: %" PRIu64", insns: %" PRIu64 "\n",
bb_count, insn_count);
qemu_plugin_outs(out);
diff --git a/tests/plugin/insn.c b/tests/plugin/insn.c
index 0a8f5a0000..c83b1c0157 100644
--- a/tests/plugin/insn.c
+++ b/tests/plugin/insn.c
@@ -44,7 +44,7 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
static void plugin_exit(qemu_plugin_id_t id, void *p)
{
- g_autofree gchar *out;
+ g_autofree gchar *out = NULL;
out = g_strdup_printf("insns: %" PRIu64 "\n", insn_count);
qemu_plugin_outs(out);
}
--
2.23.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] tests/plugin: prevent uninitialized warning
2020-02-06 9:32 [PATCH] tests/plugin: prevent uninitialized warning kuhn.chenqun
@ 2020-02-06 10:19 ` Thomas Huth
2020-02-06 12:45 ` Alex Bennée
1 sibling, 0 replies; 5+ messages in thread
From: Thomas Huth @ 2020-02-06 10:19 UTC (permalink / raw)
To: kuhn.chenqun, qemu-devel, alex.bennee
Cc: qemu-trivial, richard.henderson, zhang.zhanghailiang
On 06/02/2020 10.32, kuhn.chenqun@huawei.com wrote:
> From: Chen Qun <kuhn.chenqun@huawei.com>
>
> According to the glibc function requirements, we need initialise
> the variable. Otherwise there will be compilation warnings:
>
> glib-autocleanups.h:28:3: warning: ‘out’ may be
> used uninitialized in this function [-Wmaybe-uninitialized]
> g_free (*pp);
> ^~~~~~~~~~~~
>
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
> ---
> tests/plugin/bb.c | 2 +-
> tests/plugin/insn.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tests/plugin/bb.c b/tests/plugin/bb.c
> index f30bea08dc..8b9da23a04 100644
> --- a/tests/plugin/bb.c
> +++ b/tests/plugin/bb.c
> @@ -22,7 +22,7 @@ static bool do_inline;
>
> static void plugin_exit(qemu_plugin_id_t id, void *p)
> {
> - g_autofree gchar *out;
> + g_autofree gchar *out = NULL;
> out = g_strdup_printf("bb's: %" PRIu64", insns: %" PRIu64 "\n",
> bb_count, insn_count);
> qemu_plugin_outs(out);
> diff --git a/tests/plugin/insn.c b/tests/plugin/insn.c
> index 0a8f5a0000..c83b1c0157 100644
> --- a/tests/plugin/insn.c
> +++ b/tests/plugin/insn.c
> @@ -44,7 +44,7 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
>
> static void plugin_exit(qemu_plugin_id_t id, void *p)
> {
> - g_autofree gchar *out;
> + g_autofree gchar *out = NULL;
> out = g_strdup_printf("insns: %" PRIu64 "\n", insn_count);
> qemu_plugin_outs(out);
> }
Just a matter of taste, but I think in these simple cases, it would be
nicer to put everything in one line, e.g.:
g_autofree gchar *out = g_strdup_printf("insns: %" PRIu64 "\n",
insn_count);
Anyway,
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] tests/plugin: prevent uninitialized warning
2020-02-06 9:32 [PATCH] tests/plugin: prevent uninitialized warning kuhn.chenqun
2020-02-06 10:19 ` Thomas Huth
@ 2020-02-06 12:45 ` Alex Bennée
2020-02-06 13:25 ` Chenqun (kuhn)
1 sibling, 1 reply; 5+ messages in thread
From: Alex Bennée @ 2020-02-06 12:45 UTC (permalink / raw)
To: kuhn.chenqun
Cc: qemu-trivial, richard.henderson, qemu-devel, zhang.zhanghailiang
kuhn.chenqun@huawei.com writes:
> From: Chen Qun <kuhn.chenqun@huawei.com>
>
> According to the glibc function requirements, we need initialise
> the variable. Otherwise there will be compilation warnings:
>
> glib-autocleanups.h:28:3: warning: ‘out’ may be
> used uninitialized in this function [-Wmaybe-uninitialized]
> g_free (*pp);
> ^~~~~~~~~~~~
>
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
Queued to plugins/next with Thomas' single line suggestion, thanks.
> ---
> tests/plugin/bb.c | 2 +-
> tests/plugin/insn.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tests/plugin/bb.c b/tests/plugin/bb.c
> index f30bea08dc..8b9da23a04 100644
> --- a/tests/plugin/bb.c
> +++ b/tests/plugin/bb.c
> @@ -22,7 +22,7 @@ static bool do_inline;
>
> static void plugin_exit(qemu_plugin_id_t id, void *p)
> {
> - g_autofree gchar *out;
> + g_autofree gchar *out = NULL;
> out = g_strdup_printf("bb's: %" PRIu64", insns: %" PRIu64 "\n",
> bb_count, insn_count);
> qemu_plugin_outs(out);
> diff --git a/tests/plugin/insn.c b/tests/plugin/insn.c
> index 0a8f5a0000..c83b1c0157 100644
> --- a/tests/plugin/insn.c
> +++ b/tests/plugin/insn.c
> @@ -44,7 +44,7 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
>
> static void plugin_exit(qemu_plugin_id_t id, void *p)
> {
> - g_autofree gchar *out;
> + g_autofree gchar *out = NULL;
> out = g_strdup_printf("insns: %" PRIu64 "\n", insn_count);
> qemu_plugin_outs(out);
> }
--
Alex Bennée
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH] tests/plugin: prevent uninitialized warning
2020-02-06 12:45 ` Alex Bennée
@ 2020-02-06 13:25 ` Chenqun (kuhn)
2020-02-06 16:22 ` Alex Bennée
0 siblings, 1 reply; 5+ messages in thread
From: Chenqun (kuhn) @ 2020-02-06 13:25 UTC (permalink / raw)
To: Alex Bennée
Cc: qemu-trivial, richard.henderson, qemu-devel, Zhanghailiang
>-----Original Message-----
>From: Alex Bennée [mailto:alex.bennee@linaro.org]
>Sent: Thursday, February 6, 2020 8:46 PM
>To: Chenqun (kuhn) <kuhn.chenqun@huawei.com>
>Cc: qemu-devel@nongnu.org; Zhanghailiang
><zhang.zhanghailiang@huawei.com>; qemu-trivial@nongnu.org;
>richard.henderson@linaro.org
>Subject: Re: [PATCH] tests/plugin: prevent uninitialized warning
>
>
>kuhn.chenqun@huawei.com writes:
>
>> From: Chen Qun <kuhn.chenqun@huawei.com>
>>
>> According to the glibc function requirements, we need initialise the
>> variable. Otherwise there will be compilation warnings:
>>
>> glib-autocleanups.h:28:3: warning: ‘out’ may be used uninitialized in
>> this function [-Wmaybe-uninitialized]
>> g_free (*pp);
>> ^~~~~~~~~~~~
>>
>> Reported-by: Euler Robot <euler.robot@huawei.com>
>> Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
>
>Queued to plugins/next with Thomas' single line suggestion, thanks.
Thank you!
By the way, what is plugins/next connection address?
>
>> ---
>> tests/plugin/bb.c | 2 +-
>> tests/plugin/insn.c | 2 +-
>> 2 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/tests/plugin/bb.c b/tests/plugin/bb.c index
>> f30bea08dc..8b9da23a04 100644
>> --- a/tests/plugin/bb.c
>> +++ b/tests/plugin/bb.c
>> @@ -22,7 +22,7 @@ static bool do_inline;
>>
>> static void plugin_exit(qemu_plugin_id_t id, void *p) {
>> - g_autofree gchar *out;
>> + g_autofree gchar *out = NULL;
>> out = g_strdup_printf("bb's: %" PRIu64", insns: %" PRIu64 "\n",
>> bb_count, insn_count);
>> qemu_plugin_outs(out);
>> diff --git a/tests/plugin/insn.c b/tests/plugin/insn.c index
>> 0a8f5a0000..c83b1c0157 100644
>> --- a/tests/plugin/insn.c
>> +++ b/tests/plugin/insn.c
>> @@ -44,7 +44,7 @@ static void vcpu_tb_trans(qemu_plugin_id_t id,
>> struct qemu_plugin_tb *tb)
>>
>> static void plugin_exit(qemu_plugin_id_t id, void *p) {
>> - g_autofree gchar *out;
>> + g_autofree gchar *out = NULL;
>> out = g_strdup_printf("insns: %" PRIu64 "\n", insn_count);
>> qemu_plugin_outs(out);
>> }
>
>
>--
>Alex Bennée
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] tests/plugin: prevent uninitialized warning
2020-02-06 13:25 ` Chenqun (kuhn)
@ 2020-02-06 16:22 ` Alex Bennée
0 siblings, 0 replies; 5+ messages in thread
From: Alex Bennée @ 2020-02-06 16:22 UTC (permalink / raw)
To: Chenqun (kuhn); +Cc: qemu-trivial, richard.henderson, qemu-devel, Zhanghailiang
Chenqun (kuhn) <kuhn.chenqun@huawei.com> writes:
>>-----Original Message-----
>>From: Alex Bennée [mailto:alex.bennee@linaro.org]
>>Sent: Thursday, February 6, 2020 8:46 PM
>>To: Chenqun (kuhn) <kuhn.chenqun@huawei.com>
>>Cc: qemu-devel@nongnu.org; Zhanghailiang
>><zhang.zhanghailiang@huawei.com>; qemu-trivial@nongnu.org;
>>richard.henderson@linaro.org
>>Subject: Re: [PATCH] tests/plugin: prevent uninitialized warning
>>
>>
>>kuhn.chenqun@huawei.com writes:
>>
>>> From: Chen Qun <kuhn.chenqun@huawei.com>
>>>
>>> According to the glibc function requirements, we need initialise the
>>> variable. Otherwise there will be compilation warnings:
>>>
>>> glib-autocleanups.h:28:3: warning: ‘out’ may be used uninitialized in
>>> this function [-Wmaybe-uninitialized]
>>> g_free (*pp);
>>> ^~~~~~~~~~~~
>>>
>>> Reported-by: Euler Robot <euler.robot@huawei.com>
>>> Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
>>
>>Queued to plugins/next with Thomas' single line suggestion, thanks.
>
> Thank you!
> By the way, what is plugins/next connection address?
My tree is on github:
https://github.com/stsquad/qemu/tree/plugins/next
>
>>
>>> ---
>>> tests/plugin/bb.c | 2 +-
>>> tests/plugin/insn.c | 2 +-
>>> 2 files changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/tests/plugin/bb.c b/tests/plugin/bb.c index
>>> f30bea08dc..8b9da23a04 100644
>>> --- a/tests/plugin/bb.c
>>> +++ b/tests/plugin/bb.c
>>> @@ -22,7 +22,7 @@ static bool do_inline;
>>>
>>> static void plugin_exit(qemu_plugin_id_t id, void *p) {
>>> - g_autofree gchar *out;
>>> + g_autofree gchar *out = NULL;
>>> out = g_strdup_printf("bb's: %" PRIu64", insns: %" PRIu64 "\n",
>>> bb_count, insn_count);
>>> qemu_plugin_outs(out);
>>> diff --git a/tests/plugin/insn.c b/tests/plugin/insn.c index
>>> 0a8f5a0000..c83b1c0157 100644
>>> --- a/tests/plugin/insn.c
>>> +++ b/tests/plugin/insn.c
>>> @@ -44,7 +44,7 @@ static void vcpu_tb_trans(qemu_plugin_id_t id,
>>> struct qemu_plugin_tb *tb)
>>>
>>> static void plugin_exit(qemu_plugin_id_t id, void *p) {
>>> - g_autofree gchar *out;
>>> + g_autofree gchar *out = NULL;
>>> out = g_strdup_printf("insns: %" PRIu64 "\n", insn_count);
>>> qemu_plugin_outs(out);
>>> }
>>
>>
>>--
>>Alex Bennée
--
Alex Bennée
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-02-06 16:24 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-06 9:32 [PATCH] tests/plugin: prevent uninitialized warning kuhn.chenqun
2020-02-06 10:19 ` Thomas Huth
2020-02-06 12:45 ` Alex Bennée
2020-02-06 13:25 ` Chenqun (kuhn)
2020-02-06 16:22 ` Alex Bennée
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).