Skip to contentSkip to conversation

emulate.c: Fix comppilation warning

PATCH In review Rajat Jain 2 participants 3 messages Jun 10, 2015

Subsystems (3)
lore
Share & tools
lore

Rajat Jain

author
#0 lore raw

PATCH v2 1/1 emulate.c: Fix comppilation warning

Fix the following warning:

arch/x86/kvm/emulate.c: In function '__do_insn_fetch_bytes':
arch/x86/kvm/emulate.c:814:47: warning: 'linear' may be used uninitialized in this function [-Wmaybe-uninitialized] arch/x86/kvm/emulate.c:793:16: note: 'linear' was declared here

---
v2: Fix the wrong email address.

 arch/x86/kvm/emulate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/emulate.c +1 -1
index 630bcb0..f06e0ca 100644
@@ -790,7 +790,7 @@ static int __do_insn_fetch_bytes(struct x86_emulate_ctxt *ctxt, int op_size)
 {
 	int rc;
 	unsigned size, max_size;
-	unsigned long linear;
+	unsigned long linear = 0;
 	int cur_size = ctxt->fetch.end - ctxt->fetch.data;
 	struct segmented_address addr = { .seg = VCPU_SREG_CS,
 					   .ea = ctxt->eip + cur_size };
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#1 lore raw
Quoted 5 lines · Rajat Jain

Fix the following warning:

arch/x86/kvm/emulate.c: In function '__do_insn_fetch_bytes':
arch/x86/kvm/emulate.c:814:47: warning: 'linear' may be used uninitialized in this function [-Wmaybe-uninitialized] arch/x86/kvm/emulate.c:793:16: note: 'linear' was declared here

Is this recent gcc behavior ? If yes, please mention that in the commit message.

Please follow convention for the subject line and fix the typo - "KVM: emulate: Fix compilation warning"

Thanks,
Bandan

Quoted 21 lines

---
v2: Fix the wrong email address.

 arch/x86/kvm/emulate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/emulate.c +1 -1
index 630bcb0..f06e0ca 100644
@@ -790,7 +790,7 @@ static int __do_insn_fetch_bytes(struct x86_emulate_ctxt *ctxt, int op_size)
 {
 	int rc;
 	unsigned size, max_size;
-	unsigned long linear;
+	unsigned long linear = 0;
 	int cur_size = ctxt->fetch.end - ctxt->fetch.data;
 	struct segmented_address addr = { .seg = VCPU_SREG_CS,
 					   .ea = ctxt->eip + cur_size };
author
#2 lore raw

Hello Bandan,

Quoted 10 lines · Bandan Das
Quoted 5 lines · Rajat Jain

Fix the following warning:

arch/x86/kvm/emulate.c: In function '__do_insn_fetch_bytes':
arch/x86/kvm/emulate.c:814:47: warning: 'linear' may be used uninitialized in this function [-Wmaybe-uninitialized] arch/x86/kvm/emulate.c:793:16: note: 'linear' was declared here

Is this recent gcc behavior ? If yes, please mention that in the commit message.

Sorry, I realized that I was using an internal version of gcc. I don't see the warning with gcc 4.8.2 that comes with ubuntu. So I guess we can ignore the patch then...

Thanks,

Rajat

Quoted 29 lines

Please follow convention for the subject line and fix the typo - "KVM: emulate: Fix compilation warning"

Thanks,
Bandan

Quoted 21 lines

---
v2: Fix the wrong email address.

 arch/x86/kvm/emulate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/emulate.c +1 -1
index 630bcb0..f06e0ca 100644
@@ -790,7 +790,7 @@ static int __do_insn_fetch_bytes(struct x86_emulate_ctxt *ctxt, int op_size)
 {
      int rc;
      unsigned size, max_size;
-     unsigned long linear;
+     unsigned long linear = 0;
      int cur_size = ctxt->fetch.end - ctxt->fetch.data;
      struct segmented_address addr = { .seg = VCPU_SREG_CS,
                                         .ea = ctxt->eip + cur_size };