Skip to contentSkip to conversation

Fix unused-but-set-variable warnings

PATCH Applied Christophe Fergeau 6 participants 10 messages Jun 1, 2011 – Jun 10, 2011

lore
Share & tools
lore
#0 lore raw

cover Fix unused-but-set-variable warnings

Hi,

Here are a few more "unused-but-set-variable" warning fixes which I got when rebuilding qemu. I can fold the other 2 patches that were already sent to this list in this series if needed.

The 3rd hunk of the ehci patch needs a review from someone who knows the code, different values are assigned to the "pid" variable which the patch deletes, and further down in the function, ehci->pid is used, so maybe an "ehci->pid = pid;" line is missing in this function, in which case the patch would hide a bug instead of solving it.

Similarly, the variable removed from the linux-user patch is assigned different values depending on some conditions, maybe it's not right to remove it but it should be used for "something".

Christophe

Christophe Fergeau (3):
lsi: Fix unused-but-set-variable warning
ehci: Fix unused-but-set-variable warning
linux-user: Fix unused-but-set-variable warning

 hw/lsi53c895a.c        |    2 --
 hw/usb-ehci.c          |   11 +----------
 linux-user/linuxload.c |    9 +--------
 3 files changed, 2 insertions(+), 20 deletions(-)
Signature · 1 line
1.7.5.2
#1 lore raw

PATCH 1/3 lsi: Fix unused-but-set-variable warning

This warning is new in gcc 4.6.

---
 hw/lsi53c895a.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
hw/lsi53c895a.c +0 -2
index 83084b6..90c6cbc 100644
@@ -889,7 +889,6 @@ static void lsi_do_msgout(LSIState *s)
     uint8_t msg;
     int len;
     uint32_t current_tag;
-    SCSIDevice *current_dev;
     lsi_request *current_req, *p, *p_next;
     int id;
 
@@ -901,7 +900,6 @@ static void lsi_do_msgout(LSIState *s)
         current_req = lsi_find_by_tag(s, current_tag);
     }
     id = (current_tag >> 8) & 0xf;
-    current_dev = s->bus.devs[id];
 
     DPRINTF("MSG out len=%d\n", s->dbc);
     while (s->dbc) {
Signature · 1 line
1.7.5.2
Acked-by on v1 1/3
#2 lore raw

Re: [Qemu-devel] [PATCH 1/3] lsi: Fix unused-but-set-variable warning

Quoted 20 lines · Christophe Fergeau

This warning is new in gcc 4.6.

---
  hw/lsi53c895a.c |    2 --
  1 files changed, 0 insertions(+), 2 deletions(-)
hw/lsi53c895a.c +0 -1
index 83084b6..90c6cbc 100644
@@ -889,7 +889,6 @@ static void lsi_do_msgout(LSIState *s)
      uint8_t msg;
      int len;
      uint32_t current_tag;
-    SCSIDevice *current_dev;
      lsi_request *current_req, *p, *p_next;
      int id;
 

hw/lsi53c895a.c static void lsi_do_msgout(LSIState *s) · line 905

Quoted 7 lines
hw/lsi53c895a.c +0 -1
@@ -901,7 +900,6 @@ static void lsi_do_msgout(LSIState *s)
          current_req = lsi_find_by_tag(s, current_tag);
      }
      id = (current_tag>>  8)&  0xf;
-    current_dev = s->bus.devs[id];
 
      DPRINTF("MSG out len=%d\n", s->dbc);
      while (s->dbc) {
Reviewed-by
#3 lore raw

Re: [Qemu-devel] [PATCH 1/3] lsi: Fix unused-but-set-variable warning

Stefan, if you're picking up gcc warning fixes for the trivial tree, how about this one?

(I think the other gcc warning fixes are either:
* in the most recent usb pull request
* linux-user
* target-alpha
which all have a clear owner/interested person.)

-- PMM

Quoted 31 lines · Paolo Bonzini
Quoted 21 lines · Christophe Fergeau

This warning is new in gcc 4.6.

---
 hw/lsi53c895a.c |    2 --

 1 files changed, 0 insertions(+), 2 deletions(-)
hw/lsi53c895a.c +0 -1
index 83084b6..90c6cbc 100644
@@ -889,7 +889,6 @@ static void lsi_do_msgout(LSIState *s)
      uint8_t msg;
      int len;
      uint32_t current_tag;
-    SCSIDevice *current_dev;
      lsi_request *current_req, *p, *p_next;
      int id;
 

hw/lsi53c895a.c static void lsi_do_msgout(LSIState *s) · line 905

Quoted 7 lines
hw/lsi53c895a.c +0 -1
@@ -901,7 +900,6 @@ static void lsi_do_msgout(LSIState *s)
          current_req = lsi_find_by_tag(s, current_tag);
      }
      id = (current_tag>>  8)&  0xf;
-    current_dev = s->bus.devs[id];
 
      DPRINTF("MSG out len=%d\n", s->dbc);
      while (s->dbc) {
#4 lore raw

Re: [Qemu-devel] [PATCH 1/3] lsi: Fix unused-but-set-variable warning

Quoted 7 lines · Peter Maydell

Stefan, if you're picking up gcc warning fixes for the trivial tree, how about this one?

(I think the other gcc warning fixes are either:
* in the most recent usb pull request
* linux-user
* target-alpha

Speaking of, anyone willing to pull and/or look at my target-alpha patchset? I've been re-posting and/or pinging it for more than 2 months now with no more than one spelling error as feedback...

r~

#6 lore raw

PATCH 2/3 ehci: Fix unused-but-set-variable warning

In reply to Christophe Fergeau

This warning is new in gcc 4.6.

---
 hw/usb-ehci.c |   11 +----------
 1 files changed, 1 insertions(+), 10 deletions(-)
hw/usb-ehci.c +1 -10
index f63519e..8a7b1bb 100644
@@ -523,11 +523,8 @@ static void ehci_detach(USBPort *port)
 static void ehci_reset(void *opaque)
 {
     EHCIState *s = opaque;
-    uint8_t *pci_conf;
     int i;
 
-    pci_conf = s->dev.config;
-
     memset(&s->mmio[OPREGBASE], 0x00, MMIO_SIZE - OPREGBASE);
 
     s->usbcmd = NB_MAXINTRATE << USBCMD_ITC_SH;
@@ -1105,18 +1102,15 @@ static int ehci_process_itd(EHCIState *ehci,
     int ret;
     int i, j;
     int ptr;
-    int pid;
     int pg;
     int len;
     int dir;
     int devadr;
     int endp;
-    int maxpkt;
 
     dir =(itd->bufptr[1] & ITD_BUFPTR_DIRECTION);
     devadr = get_field(itd->bufptr[0], ITD_BUFPTR_DEVADDR);
     endp = get_field(itd->bufptr[0], ITD_BUFPTR_EP);
-    maxpkt = get_field(itd->bufptr[1], ITD_BUFPTR_MAXPKT);
 
     for(i = 0; i < 8; i++) {
         if (itd->transact[i] & ITD_XACT_ACTIVE) {
@@ -1134,11 +1128,8 @@ static int ehci_process_itd(EHCIState *ehci,
 
             DPRINTF("ISOCH: buffer %08X len %d\n", ptr, len);
 
-            if (!dir) {
+            if (!dir)
                 cpu_physical_memory_rw(ptr, &ehci->buffer[0], len, 0);
-                pid = USB_TOKEN_OUT;
-            } else
-                pid = USB_TOKEN_IN;
 
             ret = USB_RET_NODEV;
 
Signature · 1 line
1.7.5.2
#7 lore raw

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

hw/usb-ehci.c static int ehci_process_itd(EHCIState *ehci, · line 1135

Quoted 13 lines · Christophe Fergeau
hw/usb-ehci.c +1 -4
@@ -1134,11 +1128,8 @@ static int ehci_process_itd(EHCIState *ehci,
 
             DPRINTF("ISOCH: buffer %08X len %d\n", ptr, len);
 
-            if (!dir) {
+            if (!dir)
                 cpu_physical_memory_rw(ptr, &ehci->buffer[0], len, 0);
-                pid = USB_TOKEN_OUT;
-            } else
-                pid = USB_TOKEN_IN;
 
             ret = USB_RET_NODEV;
 

I think you want those to be ehci->pid instead of deleting them.

David

#8 lore raw

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

Quoted 1 line · David Ahern

I think you want those to be ehci->pid instead of deleting them.

Yeah, this is exactly what I was wondering while making this patch, but couldn't decide which one was supposed to be given my total lack of knowledge of USB and of this code :)

Thanks,

Christophe

#9 lore raw

PATCH 3/3 linux-user: Fix unused-but-set-variable warning

In reply to Christophe Fergeau

This warning is new in gcc 4.6.

---
 linux-user/linuxload.c |    9 +--------
 1 files changed, 1 insertions(+), 8 deletions(-)
linux-user/linuxload.c +1 -8
index ac8c486..e66a4ea 100644
@@ -57,7 +57,7 @@ static int prepare_binprm(struct linux_binprm *bprm)
 {
     struct stat		st;
     int mode;
-    int retval, id_change;
+    int retval;
 
     if(fstat(bprm->fd, &st) < 0) {
 	return(-errno);
@@ -73,14 +73,10 @@ static int prepare_binprm(struct linux_binprm *bprm)
 
     bprm->e_uid = geteuid();
     bprm->e_gid = getegid();
-    id_change = 0;
 
     /* Set-uid? */
     if(mode & S_ISUID) {
     	bprm->e_uid = st.st_uid;
-	if(bprm->e_uid != geteuid()) {
-	    id_change = 1;
-	}
     }
 
     /* Set-gid? */
@@ -91,9 +87,6 @@ static int prepare_binprm(struct linux_binprm *bprm)
      */
     if ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) {
 	bprm->e_gid = st.st_gid;
-	if (!in_group_p(bprm->e_gid)) {
-		id_change = 1;
-	}
     }
 
     retval = read(bprm->fd, bprm->buf, BPRM_BUF_SIZE);
Signature · 1 line
1.7.5.2