Skip to contentSkip to conversation

Fix a number of unused-but-set-variable warnings (new with gcc-4.6)

PATCH In review Hans de Goede 6 participants 20 messages May 3, 2011 – Jun 14, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix a number of unused-but-set-variable warnings (new with gcc-4.6)

---
 target-i386/kvm.c |    4 ++--
 tcg/tcg.c         |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
target-i386/kvm.c +2 -2
index a13599d..e9e8d54 100644
@@ -950,7 +950,7 @@ static int kvm_get_xsave(CPUState *env)
 #ifdef KVM_CAP_XSAVE
     struct kvm_xsave* xsave;
     int ret, i;
-    uint16_t cwd, swd, twd, fop;
+    uint16_t cwd, swd, twd;
 
     if (!kvm_has_xsave()) {
         return kvm_get_fpu(env);
@@ -966,7 +966,7 @@ static int kvm_get_xsave(CPUState *env)
     cwd = (uint16_t)xsave->region[0];
     swd = (uint16_t)(xsave->region[0] >> 16);
     twd = (uint16_t)xsave->region[1];
-    fop = (uint16_t)(xsave->region[1] >> 16);
+    /* fop = (uint16_t)(xsave->region[1] >> 16); */
     env->fpstt = (swd >> 11) & 7;
     env->fpus = swd;
     env->fpuc = cwd;
tcg/tcg.c +2 -2
index 8748c05..11a8daf 100644
@@ -585,7 +585,7 @@ void tcg_register_helper(void *func, const char *name)
 void tcg_gen_callN(TCGContext *s, TCGv_ptr func, unsigned int flags,
                    int sizemask, TCGArg ret, int nargs, TCGArg *args)
 {
-#ifdef TCG_TARGET_I386
+#if defined TCG_TARGET_I386 && TCG_TARGET_REG_BITS < 64 
     int call_type;
 #endif
     int i;
@@ -612,7 +612,7 @@ void tcg_gen_callN(TCGContext *s, TCGv_ptr func, unsigned int flags,
 
     *gen_opc_ptr++ = INDEX_op_call;
     nparam = gen_opparam_ptr++;
-#ifdef TCG_TARGET_I386
+#if defined TCG_TARGET_I386 && TCG_TARGET_REG_BITS < 64 
     call_type = (flags & TCG_CALL_TYPE_MASK);
 #endif
     if (ret != TCG_CALL_DUMMY_ARG) {
Signature · 1 line
1.7.5
#1 lore raw

Hi Hans,

target-i386/kvm.c static int kvm_get_xsave(CPUState *env) · line 969

Quoted 11 lines · Hans de Goede
target-i386/kvm.c +1 -1
index a13599d..e9e8d54 100644
@@ -950,7 +950,7 @@ static int kvm_get_xsave(CPUState *env)
@@ -966,7 +966,7 @@ static int kvm_get_xsave(CPUState *env)
     cwd = (uint16_t)xsave->region[0];
     swd = (uint16_t)(xsave->region[0] >> 16);
     twd = (uint16_t)xsave->region[1];
-    fop = (uint16_t)(xsave->region[1] >> 16);
+    /* fop = (uint16_t)(xsave->region[1] >> 16); */

Wouldn't it be better to drop this line?

tcg/tcg.c void tcg_register_helper(void *func, const char *name) · line 588

Quoted 13 lines
target-i386/kvm.c +0 -0
     env->fpstt = (swd >> 11) & 7;
     env->fpus = swd;
     env->fpuc = cwd;
tcg/tcg.c +1 -1
index 8748c05..11a8daf 100644
@@ -585,7 +585,7 @@ void tcg_register_helper(void *func, const char *name)
 void tcg_gen_callN(TCGContext *s, TCGv_ptr func, unsigned int flags,
                    int sizemask, TCGArg ret, int nargs, TCGArg *args)
 {
-#ifdef TCG_TARGET_I386
+#if defined TCG_TARGET_I386 && TCG_TARGET_REG_BITS < 64 

This function uses #if defined(TCG_TARGET_I386) in other places, so I'd use parentheses here for consistency.

tcg/tcg.c void tcg_gen_callN(TCGContext *s, TCGv_ptr func, unsigned int flags, · line 615

Quoted 9 lines
tcg/tcg.c +1 -1
     int call_type;
 #endif
     int i;
@@ -612,7 +612,7 @@ void tcg_gen_callN(TCGContext *s, TCGv_ptr func, unsigned int flags,
 
     *gen_opc_ptr++ = INDEX_op_call;
     nparam = gen_opparam_ptr++;
-#ifdef TCG_TARGET_I386
+#if defined TCG_TARGET_I386 && TCG_TARGET_REG_BITS < 64 

Same here.

Apart from that, I also need this patch to be able to build qemu on fedora 15 :)

Christophe

#2 lore raw
Quoted 46 lines · Christophe Fergeau

Hi Hans,

target-i386/kvm.c static int kvm_get_xsave(CPUState *env) · line 969

Quoted 11 lines · Hans de Goede
target-i386/kvm.c +1 -1
index a13599d..e9e8d54 100644
@@ -950,7 +950,7 @@ static int kvm_get_xsave(CPUState *env)
@@ -966,7 +966,7 @@ static int kvm_get_xsave(CPUState *env)
     cwd = (uint16_t)xsave->region[0];
     swd = (uint16_t)(xsave->region[0] >> 16);
     twd = (uint16_t)xsave->region[1];
-    fop = (uint16_t)(xsave->region[1] >> 16);
+    /* fop = (uint16_t)(xsave->region[1] >> 16); */

Wouldn't it be better to drop this line?

tcg/tcg.c void tcg_register_helper(void *func, const char *name) · line 588

Quoted 13 lines
target-i386/kvm.c +0 -0
     env->fpstt = (swd >> 11) & 7;
     env->fpus = swd;
     env->fpuc = cwd;
tcg/tcg.c +1 -1
index 8748c05..11a8daf 100644
@@ -585,7 +585,7 @@ void tcg_register_helper(void *func, const char *name)
 void tcg_gen_callN(TCGContext *s, TCGv_ptr func, unsigned int flags,
                    int sizemask, TCGArg ret, int nargs, TCGArg *args)
 {
-#ifdef TCG_TARGET_I386
+#if defined TCG_TARGET_I386 && TCG_TARGET_REG_BITS < 64 

This function uses #if defined(TCG_TARGET_I386) in other places, so I'd use parentheses here for consistency.

tcg/tcg.c void tcg_gen_callN(TCGContext *s, TCGv_ptr func, unsigned int flags, · line 615

Quoted 9 lines
tcg/tcg.c +1 -1
     int call_type;
 #endif
     int i;
@@ -612,7 +612,7 @@ void tcg_gen_callN(TCGContext *s, TCGv_ptr func, unsigned int flags,
 
     *gen_opc_ptr++ = INDEX_op_call;
     nparam = gen_opparam_ptr++;
-#ifdef TCG_TARGET_I386
+#if defined TCG_TARGET_I386 && TCG_TARGET_REG_BITS < 64 

Same here.

Quoted 3 lines

Apart from that, I also need this patch to be able to build qemu on fedora 15 :)

You should also probably split the patch in two parts, as it touch totally different parts of QEMU, and thus is going to be reviewed/applied by different person. I am fine with the TCG part after the comments from Christophe, so I'll apply it as soon as the new version is out.

Signature · 2 lines
Aurelien Jarno	                        GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net
Acked-by on v1 1/1
#3 lore raw
In reply to Hans de Goede
Quoted 4 lines · Hans de Goede
---
 target-i386/kvm.c |    4 ++--
 tcg/tcg.c         |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

Thanks; just got hit by this.

However, there are a couple of whitespace issues:

Quoted 12 lines
tcg/tcg.c +1 -1
@@ -585,7 +585,7 @@ void tcg_register_helper(void *func, const char *name)
 void tcg_gen_callN(TCGContext *s, TCGv_ptr func, unsigned int flags,
                    int sizemask, TCGArg ret, int nargs, TCGArg *args)
 {
-#ifdef TCG_TARGET_I386
+#if defined TCG_TARGET_I386 && TCG_TARGET_REG_BITS < 64 
     int call_type;
 #endif
     int i;

tcg/tcg.c void tcg_gen_callN(TCGContext *s, TCGv_ptr func, unsigned int flags, · line 618

Quoted 8 lines
tcg/tcg.c +1 -1
@@ -612,7 +612,7 @@ void tcg_gen_callN(TCGContext *s, TCGv_ptr func, unsigned int flags,
 
     *gen_opc_ptr++ = INDEX_op_call;
     nparam = gen_opparam_ptr++;
-#ifdef TCG_TARGET_I386
+#if defined TCG_TARGET_I386 && TCG_TARGET_REG_BITS < 64 
     call_type = (flags & TCG_CALL_TYPE_MASK);
 #endif
     if (ret != TCG_CALL_DUMMY_ARG) {

Both these lines have a trailing space.

Care to resubmit with Anthony in CC? You can add:

Amit

#4 lore raw

cover Fix unused-but-set-variable warnings

Hi,

Here are Hans's patches split and with the various issues that were pointed out fixed. I'm not sure how I'm supposed to handle acks, original author, ... when reworking patches this way, let me know if I should proceed differently.

Christophe

Christophe Fergeau (2):
tcg: Fix unused-but-set-variable warning
kvm: Fix unused-but-set-variable warning

 target-i386/kvm.c |    3 +--
 tcg/tcg.c         |    4 ++--
 2 files changed, 3 insertions(+), 4 deletions(-)
Signature · 1 line
1.7.5.2
#5 lore raw

PATCH 1/2 tcg: Fix unused-but-set-variable warning

Based on a patch from Hans de Goede <[email protected]>

This warning is new in gcc 4.6.

---
 tcg/tcg.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
tcg/tcg.c +2 -2
index 8748c05..e53b54c 100644
@@ -585,7 +585,7 @@ void tcg_register_helper(void *func, const char *name)
 void tcg_gen_callN(TCGContext *s, TCGv_ptr func, unsigned int flags,
                    int sizemask, TCGArg ret, int nargs, TCGArg *args)
 {
-#ifdef TCG_TARGET_I386
+#if defined(TCG_TARGET_I386) && TCG_TARGET_REG_BITS < 64
     int call_type;
 #endif
     int i;
@@ -612,7 +612,7 @@ void tcg_gen_callN(TCGContext *s, TCGv_ptr func, unsigned int flags,
 
     *gen_opc_ptr++ = INDEX_op_call;
     nparam = gen_opparam_ptr++;
-#ifdef TCG_TARGET_I386
+#if defined(TCG_TARGET_I386) && TCG_TARGET_REG_BITS < 64
     call_type = (flags & TCG_CALL_TYPE_MASK);
 #endif
     if (ret != TCG_CALL_DUMMY_ARG) {
Signature · 1 line
1.7.5.2
#6 lore raw

PATCH 2/2 kvm: Fix unused-but-set-variable warning

In reply to Christophe Fergeau

Based on a patch from Hans de Goede <[email protected]>

This warning is new in gcc 4.6.

---
 target-i386/kvm.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
target-i386/kvm.c +1 -2
index faedc6c..58a70bc 100644
@@ -970,7 +970,7 @@ static int kvm_get_xsave(CPUState *env)
 #ifdef KVM_CAP_XSAVE
     struct kvm_xsave* xsave;
     int ret, i;
-    uint16_t cwd, swd, twd, fop;
+    uint16_t cwd, swd, twd;
 
     if (!kvm_has_xsave()) {
         return kvm_get_fpu(env);
@@ -986,7 +986,6 @@ static int kvm_get_xsave(CPUState *env)
     cwd = (uint16_t)xsave->region[0];
     swd = (uint16_t)(xsave->region[0] >> 16);
     twd = (uint16_t)xsave->region[1];
-    fop = (uint16_t)(xsave->region[1] >> 16);
     env->fpstt = (swd >> 11) & 7;
     env->fpus = swd;
     env->fpuc = cwd;
Signature · 1 line
1.7.5.2
#7 lore raw

Re: [Qemu-devel] [PATCH 0/2] Fix unused-but-set-variable warnings

In reply to Christophe Fergeau
Quoted 6 lines · Christophe Fergeau

Hi,

Here are Hans's patches split and with the various issues that were pointed out fixed. I'm not sure how I'm supposed to handle acks, original author, ... when reworking patches this way, let me know if I should proceed differently.

You should keep From: as the same person, keep his Signed-off-by, add your Signed-off-by and mention what you have changed in the series.

Thanks for re-sending this, btw.

Amit

#8 lore raw

Re: [Qemu-devel] [PATCH 0/2] Fix unused-but-set-variable warnings

Quoted 2 lines · Amit Shah

You should keep From: as the same person, keep his Signed-off-by, add your Signed-off-by and mention what you have changed in the series.

Hans's patches didn't have a S-o-b. I can resend the same patches again with my S-o-b (I'm fine with doing this without Hans's since I came up with exactly the same patches independently from Hans) and detailing the changes from the initial patch. Does that sound good?

Christophe

#9 lore raw

Re: [Qemu-devel] [PATCH 0/2] Fix unused-but-set-variable warnings

Quoted 8 lines · Christophe Fergeau
Quoted 2 lines · Amit Shah

You should keep From: as the same person, keep his Signed-off-by, add your Signed-off-by and mention what you have changed in the series.

Hans's patches didn't have a S-o-b. I can resend the same patches again with my S-o-b (I'm fine with doing this without Hans's since I came up with exactly the same patches independently from Hans) and detailing the changes from the initial patch. Does that sound good?

Yes, that's fine.

Amit

#10 lore raw

v3 cover Fix unused-but-set-variable warnings

Here is another version of these patches.

Christophe

Changes:
v3
- added S-o-b

v2
- split patches
- removed whitespace at end of lines in tcm.
- changed #if defined XXX to #if defined(XXX)
- removed commented out line from kvm.c in the 1st patch

v1
- initial version from Hans

Christophe Fergeau (2):
tcg: Fix unused-but-set-variable warning
kvm: Fix unused-but-set-variable warning

 target-i386/kvm.c |    3 +--
 tcg/tcg.c         |    4 ++--
 2 files changed, 3 insertions(+), 4 deletions(-)
Signature · 1 line
1.7.5.2
#11 lore raw

PATCH v3 1/2 tcg: Fix unused-but-set-variable warning

Based on a patch from Hans de Goede <[email protected]>

This warning is new in gcc 4.6.

---
 tcg/tcg.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
tcg/tcg.c +2 -2
index 8748c05..e53b54c 100644
@@ -585,7 +585,7 @@ void tcg_register_helper(void *func, const char *name)
 void tcg_gen_callN(TCGContext *s, TCGv_ptr func, unsigned int flags,
                    int sizemask, TCGArg ret, int nargs, TCGArg *args)
 {
-#ifdef TCG_TARGET_I386
+#if defined(TCG_TARGET_I386) && TCG_TARGET_REG_BITS < 64
     int call_type;
 #endif
     int i;
@@ -612,7 +612,7 @@ void tcg_gen_callN(TCGContext *s, TCGv_ptr func, unsigned int flags,
 
     *gen_opc_ptr++ = INDEX_op_call;
     nparam = gen_opparam_ptr++;
-#ifdef TCG_TARGET_I386
+#if defined(TCG_TARGET_I386) && TCG_TARGET_REG_BITS < 64
     call_type = (flags & TCG_CALL_TYPE_MASK);
 #endif
     if (ret != TCG_CALL_DUMMY_ARG) {
Signature · 1 line
1.7.5.2
#12 lore raw

Re: [Qemu-devel] [PATCH-v3 1/2] tcg: Fix unused-but-set-variable warning

Quoted 9 lines · Christophe Fergeau

Based on a patch from Hans de Goede <[email protected]>

This warning is new in gcc 4.6.

---
 tcg/tcg.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Thanks, applied.

Quoted 27 lines
tcg/tcg.c +2 -2
index 8748c05..e53b54c 100644
@@ -585,7 +585,7 @@ void tcg_register_helper(void *func, const char *name)
 void tcg_gen_callN(TCGContext *s, TCGv_ptr func, unsigned int flags,
                    int sizemask, TCGArg ret, int nargs, TCGArg *args)
 {
-#ifdef TCG_TARGET_I386
+#if defined(TCG_TARGET_I386) && TCG_TARGET_REG_BITS < 64
     int call_type;
 #endif
     int i;
@@ -612,7 +612,7 @@ void tcg_gen_callN(TCGContext *s, TCGv_ptr func, unsigned int flags,
 
     *gen_opc_ptr++ = INDEX_op_call;
     nparam = gen_opparam_ptr++;
-#ifdef TCG_TARGET_I386
+#if defined(TCG_TARGET_I386) && TCG_TARGET_REG_BITS < 64
     call_type = (flags & TCG_CALL_TYPE_MASK);
 #endif
     if (ret != TCG_CALL_DUMMY_ARG) {
Signature · 1 line
1.7.5.2
Signature · 2 lines
Aurelien Jarno                          GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net
#13 lore raw

PATCH v3 2/2 kvm: Fix unused-but-set-variable warning

In reply to Christophe Fergeau

Based on a patch from Hans de Goede <[email protected]>

This warning is new in gcc 4.6.

---
 target-i386/kvm.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
target-i386/kvm.c +1 -2
index faedc6c..58a70bc 100644
@@ -970,7 +970,7 @@ static int kvm_get_xsave(CPUState *env)
 #ifdef KVM_CAP_XSAVE
     struct kvm_xsave* xsave;
     int ret, i;
-    uint16_t cwd, swd, twd, fop;
+    uint16_t cwd, swd, twd;
 
     if (!kvm_has_xsave()) {
         return kvm_get_fpu(env);
@@ -986,7 +986,6 @@ static int kvm_get_xsave(CPUState *env)
     cwd = (uint16_t)xsave->region[0];
     swd = (uint16_t)(xsave->region[0] >> 16);
     twd = (uint16_t)xsave->region[1];
-    fop = (uint16_t)(xsave->region[1] >> 16);
     env->fpstt = (swd >> 11) & 7;
     env->fpus = swd;
     env->fpuc = cwd;
Signature · 1 line
1.7.5.2
#14 lore raw

Re: [Qemu-devel] [PATCH-v3 2/2] kvm: Fix unused-but-set-variable warning

Ping?

Quoted 35 lines · Christophe Fergeau

Based on a patch from Hans de Goede <[email protected]>

This warning is new in gcc 4.6.

---
 target-i386/kvm.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
target-i386/kvm.c +1 -2
index faedc6c..58a70bc 100644
@@ -970,7 +970,7 @@ static int kvm_get_xsave(CPUState *env)
 #ifdef KVM_CAP_XSAVE
     struct kvm_xsave* xsave;
     int ret, i;
-    uint16_t cwd, swd, twd, fop;
+    uint16_t cwd, swd, twd;
 
     if (!kvm_has_xsave()) {
         return kvm_get_fpu(env);
@@ -986,7 +986,6 @@ static int kvm_get_xsave(CPUState *env)
     cwd = (uint16_t)xsave->region[0];
     swd = (uint16_t)(xsave->region[0] >> 16);
     twd = (uint16_t)xsave->region[1];
-    fop = (uint16_t)(xsave->region[1] >> 16);
     env->fpstt = (swd >> 11) & 7;
     env->fpus = swd;
     env->fpuc = cwd;
Signature · 1 line
1.7.5.2
#15 lore raw

Re: [Qemu-devel] [PATCH-v3 2/2] kvm: Fix unused-but-set-variable warning

Quoted 1 line · Christophe Fergeau

Ping?

Let me add these patches to the trivial-patches tree since they haven't been picked up.

Stefan

#16 lore raw

Re: [Qemu-devel] [PATCH-v3 2/2] kvm: Fix unused-but-set-variable warning

In reply to Christophe Fergeau
Quoted 9 lines · Christophe Fergeau

Based on a patch from Hans de Goede <[email protected]>

This warning is new in gcc 4.6.

---
 target-i386/kvm.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

Thanks, applied to the trivial patches tree:
http://repo.or.cz/w/qemu/stefanha.git/shortlog/refs/heads/trivial-patches

Stefan

#17 lore raw

Re: [Qemu-devel] [PATCH-v3 2/2] kvm: Fix unused-but-set-variable warning

Quoted 5 lines · Stefan Hajnoczi
Quoted 4 lines · Christophe Fergeau

Based on a patch from Hans de Goede <[email protected]>

This warning is new in gcc 4.6.

Quoted 8 lines
Quoted 5 lines
---
 target-i386/kvm.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

Thanks, applied to the trivial patches tree:
http://repo.or.cz/w/qemu/stefanha.git/shortlog/refs/heads/trivial-patches

Please skip this one. I'll post a patch fixing the issue that this warning revealed (lacking save/restore of FPU OP, IP and DP).

Jan

#18 lore raw

Re: [Qemu-devel] [PATCH-v3 2/2] kvm: Fix unused-but-set-variable warning

Quoted 12 lines · Jan Kiszka
Quoted 11 lines · Stefan Hajnoczi
Quoted 9 lines · Christophe Fergeau

Based on a patch from Hans de Goede <[email protected]>

This warning is new in gcc 4.6.

---
 target-i386/kvm.c |    3 +--

 1 files changed, 1 insertions(+), 2 deletions(-)
Quoted 5 lines
Quoted 2 lines

Thanks, applied to the trivial patches tree:
http://repo.or.cz/w/qemu/stefanha.git/shortlog/refs/heads/trivial-patches

Please skip this one. I'll post a patch fixing the issue that this warning revealed (lacking save/restore of FPU OP, IP and DP).

Okay, dropped from trivial-patches in favor of Jan's fix.

Stefan

#19 lore raw

Re: [Qemu-devel] [PATCH-v3 2/2] kvm: Fix unused-but-set-variable warning

Quoted 5 lines · Stefan Hajnoczi
Quoted 2 lines · Jan Kiszka

Please skip this one. I'll post a patch fixing the issue that this warning revealed (lacking save/restore of FPU OP, IP and DP).

Okay, dropped from trivial-patches in favor of Jan's fix.

Great, thanks to all!

Christophe

Quoted 2 lines

Stefan