* [PATCH] monitor: fix maybe-uninitialized
@ 2019-12-11 14:23 Paolo Bonzini
2019-12-11 16:10 ` Markus Armbruster
0 siblings, 1 reply; 2+ messages in thread
From: Paolo Bonzini @ 2019-12-11 14:23 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
../monitor/misc.c: In function ‘mon_get_cpu_sync’:
/home/elmarco/src/qq/include/sysemu/hw_accel.h:22:9: error: ‘cpu’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
22 | kvm_cpu_synchronize_state(cpu);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../monitor/misc.c:397:15: note: ‘cpu’ was declared here
397 | CPUState *cpu;
| ^~~
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
monitor/misc.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/monitor/misc.c b/monitor/misc.c
index 3baa15f..a74cff3 100644
--- a/monitor/misc.c
+++ b/monitor/misc.c
@@ -394,7 +394,7 @@ int monitor_set_cpu(int cpu_index)
/* Callers must hold BQL. */
static CPUState *mon_get_cpu_sync(bool synchronize)
{
- CPUState *cpu;
+ CPUState *cpu = NULL;
if (cur_mon->mon_cpu_path) {
cpu = (CPUState *) object_resolve_path_type(cur_mon->mon_cpu_path,
@@ -411,6 +411,7 @@ static CPUState *mon_get_cpu_sync(bool synchronize)
monitor_set_cpu(first_cpu->cpu_index);
cpu = first_cpu;
}
+ assert(cpu != NULL);
if (synchronize) {
cpu_synchronize_state(cpu);
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] monitor: fix maybe-uninitialized
2019-12-11 14:23 [PATCH] monitor: fix maybe-uninitialized Paolo Bonzini
@ 2019-12-11 16:10 ` Markus Armbruster
0 siblings, 0 replies; 2+ messages in thread
From: Markus Armbruster @ 2019-12-11 16:10 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-trivial, Marc-André Lureau, qemu-devel
Paolo Bonzini <pbonzini@redhat.com> writes:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> ../monitor/misc.c: In function ‘mon_get_cpu_sync’:
> /home/elmarco/src/qq/include/sysemu/hw_accel.h:22:9: error: ‘cpu’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> 22 | kvm_cpu_synchronize_state(cpu);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ../monitor/misc.c:397:15: note: ‘cpu’ was declared here
> 397 | CPUState *cpu;
> | ^~~
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> monitor/misc.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/monitor/misc.c b/monitor/misc.c
> index 3baa15f..a74cff3 100644
> --- a/monitor/misc.c
> +++ b/monitor/misc.c
> @@ -394,7 +394,7 @@ int monitor_set_cpu(int cpu_index)
> /* Callers must hold BQL. */
> static CPUState *mon_get_cpu_sync(bool synchronize)
> {
> - CPUState *cpu;
> + CPUState *cpu = NULL;
>
> if (cur_mon->mon_cpu_path) {
> cpu = (CPUState *) object_resolve_path_type(cur_mon->mon_cpu_path,
> @@ -411,6 +411,7 @@ static CPUState *mon_get_cpu_sync(bool synchronize)
> monitor_set_cpu(first_cpu->cpu_index);
> cpu = first_cpu;
> }
> + assert(cpu != NULL);
> if (synchronize) {
> cpu_synchronize_state(cpu);
> }
Reviewed-by: Markus Armbruster <armbru@redhat.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-12-11 16:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-11 14:23 [PATCH] monitor: fix maybe-uninitialized Paolo Bonzini
2019-12-11 16:10 ` Markus Armbruster
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).