* [PATCH kvmtool] arm: Initialize target in kvm_cpu__arch_init
@ 2023-09-27 11:21 Mostafa Saleh
2023-09-27 12:21 ` Zenghui Yu
0 siblings, 1 reply; 3+ messages in thread
From: Mostafa Saleh @ 2023-09-27 11:21 UTC (permalink / raw)
To: kvm, will, julien.thierry.kdev; +Cc: Mostafa Saleh
After updating my toolchain to:
aarch64-linux-gnu-gcc (Debian 13.2.0-2) 13.2.0
I hit compilation error:
arm/kvm-cpu.c: In function ‘kvm_cpu__arch_init’:
arm/kvm-cpu.c:119:41: error: ‘target’ may be used uninitialized [-Werror=maybe-uninitialized]
119 | vcpu->cpu_compatible = target->compatible;
| ~~~~~~^~~~~~~~~~~~
arm/kvm-cpu.c:40:32: note: ‘target’ was declared here
40 | struct kvm_arm_target *target;
| ^~~~~~
target is guaranteed to be initialized, as targets would be registered
from other compilation units (arm/aarch(32|64)/arm-cpu.c).
Initializing the variable to NULL is sufficient to silence the compiler.
Signed-off-by: Mostafa Saleh <smostafa@google.com>
---
arm/kvm-cpu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arm/kvm-cpu.c b/arm/kvm-cpu.c
index 98bc5fd..57f92ee 100644
--- a/arm/kvm-cpu.c
+++ b/arm/kvm-cpu.c
@@ -37,7 +37,7 @@ int kvm_cpu__register_kvm_arm_target(struct kvm_arm_target *target)
struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm, unsigned long cpu_id)
{
- struct kvm_arm_target *target;
+ struct kvm_arm_target *target = NULL;
struct kvm_cpu *vcpu;
int coalesced_offset, mmap_size, err = -1;
unsigned int i;
--
2.42.0.582.g8ccd20d70d-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH kvmtool] arm: Initialize target in kvm_cpu__arch_init
2023-09-27 11:21 [PATCH kvmtool] arm: Initialize target in kvm_cpu__arch_init Mostafa Saleh
@ 2023-09-27 12:21 ` Zenghui Yu
2023-09-27 12:31 ` Mostafa Saleh
0 siblings, 1 reply; 3+ messages in thread
From: Zenghui Yu @ 2023-09-27 12:21 UTC (permalink / raw)
To: Mostafa Saleh; +Cc: kvm, will, julien.thierry.kdev
On 2023/9/27 19:21, Mostafa Saleh wrote:
> arm/kvm-cpu.c: In function ‘kvm_cpu__arch_init’:
> arm/kvm-cpu.c:119:41: error: ‘target’ may be used uninitialized [-Werror=maybe-uninitialized]
> 119 | vcpu->cpu_compatible = target->compatible;
> | ~~~~~~^~~~~~~~~~~~
> arm/kvm-cpu.c:40:32: note: ‘target’ was declared here
> 40 | struct kvm_arm_target *target;
> | ^~~~~~
Already addressed by 426e875213d3 ("arm/kvm-cpu: Fix new build
warning").
Zenghui
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH kvmtool] arm: Initialize target in kvm_cpu__arch_init
2023-09-27 12:21 ` Zenghui Yu
@ 2023-09-27 12:31 ` Mostafa Saleh
0 siblings, 0 replies; 3+ messages in thread
From: Mostafa Saleh @ 2023-09-27 12:31 UTC (permalink / raw)
To: Zenghui Yu; +Cc: kvm, will, julien.thierry.kdev
Hi Zenghui,
On Wed, Sep 27, 2023 at 08:21:47PM +0800, Zenghui Yu wrote:
> On 2023/9/27 19:21, Mostafa Saleh wrote:
> > arm/kvm-cpu.c: In function ‘kvm_cpu__arch_init’:
> > arm/kvm-cpu.c:119:41: error: ‘target’ may be used uninitialized [-Werror=maybe-uninitialized]
> > 119 | vcpu->cpu_compatible = target->compatible;
> > | ~~~~~~^~~~~~~~~~~~
> > arm/kvm-cpu.c:40:32: note: ‘target’ was declared here
> > 40 | struct kvm_arm_target *target;
> > | ^~~~~~
>
> Already addressed by 426e875213d3 ("arm/kvm-cpu: Fix new build
> warning").
Oh, I see that now, I was on the wrong branch, thanks for pointing
this!
> Zenghui
Thanks,
Mostafa
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-09-27 12:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-27 11:21 [PATCH kvmtool] arm: Initialize target in kvm_cpu__arch_init Mostafa Saleh
2023-09-27 12:21 ` Zenghui Yu
2023-09-27 12:31 ` Mostafa Saleh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox