Skip to contentSkip to conversation

KVM: Fix warning in emulator_cmpxchg_emulated

PATCH In review Sasha Levin 2 participants 3 messages Dec 8, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: Fix warning in emulator_cmpxchg_emulated

Make sure 'exchanged' is initialized. Fixes the following warning:

arch/x86/kvm/x86.c: In function 'emulator_cmpxchg_emulated':
arch/x86/kvm/x86.c:3794:7: warning: 'exchanged' may be used uninitialized in this function

---
 arch/x86/kvm/x86.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/kvm/x86.c +1 -1
index eeeaf2e..9338afc 100644
@@ -3791,7 +3791,7 @@ static int emulator_cmpxchg_emulated(struct x86_emulate_ctxt *ctxt,
 	gpa_t gpa;
 	struct page *page;
 	char *kaddr;
-	bool exchanged;
+	bool exchanged = false;
 
 	/* guests cmpxchg8b have to be emulated atomically */
 	if (bytes > 8 || (bytes & (bytes - 1)))
Signature · 1 line
1.7.8
#1 lore raw
Quoted 15 lines · Sasha Levin

Make sure 'exchanged' is initialized. Fixes the following warning:

arch/x86/kvm/x86.c: In function 'emulator_cmpxchg_emulated':
arch/x86/kvm/x86.c:3794:7: warning: 'exchanged' may be used uninitialized in this function

---
 arch/x86/kvm/x86.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/kvm/x86.c +0 -0
index eeeaf2e..9338afc 100644

arch/x86/kvm/x86.c static int emulator_cmpxchg_emulated(struct x86_emulate_ctxt *ctxt, · line 3797

Quoted 8 lines
arch/x86/kvm/x86.c +1 -1
@@ -3791,7 +3791,7 @@ static int emulator_cmpxchg_emulated(struct x86_emulate_ctxt *ctxt,
 	gpa_t gpa;
 	struct page *page;
 	char *kaddr;
-	bool exchanged;
+	bool exchanged = false;
 
 	/* guests cmpxchg8b have to be emulated atomically */
 	if (bytes > 8 || (bytes & (bytes - 1)))

Isn't BUG() tagged as no-return in the kernel? Because this initialization is obviously unneeded.

Jan

#2 lore raw
Quoted 22 lines · Jan Kiszka
Quoted 21 lines · Sasha Levin

Make sure 'exchanged' is initialized. Fixes the following warning:

arch/x86/kvm/x86.c: In function 'emulator_cmpxchg_emulated':
arch/x86/kvm/x86.c:3794:7: warning: 'exchanged' may be used uninitialized in this function

---
 arch/x86/kvm/x86.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/kvm/x86.c +1 -1
index eeeaf2e..9338afc 100644
@@ -3791,7 +3791,7 @@ static int emulator_cmpxchg_emulated(struct x86_emulate_ctxt *ctxt,
 	gpa_t gpa;
 	struct page *page;
 	char *kaddr;
-	bool exchanged;
+	bool exchanged = false;
 
Quoted 5 lines

arch/x86/kvm/x86.c static int emulator_cmpxchg_emulated(struct x86_emulate_ctxt *ctxt, · line 3797

Quoted 2 lines
arch/x86/kvm/x86.c +0 -0
 	/* guests cmpxchg8b have to be emulated atomically */
 	if (bytes > 8 || (bytes & (bytes - 1)))

Isn't BUG() tagged as no-return in the kernel? Because this initialization is obviously unneeded.

It looks like __builtin_unreachable() requires a gcc newer than mine.

Signature · 1 line
Sasha.