Fix unused-but-set-variable warnings
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
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
@@ -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
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.
Signed-off-by Christophe Fergeau<[email protected]>--- hw/lsi53c895a.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-)hw/lsi53c895a.c +0
-1@@ -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) {
Peter Maydell
Reviewed-byRe: [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.
Signed-off-by Christophe Fergeau<[email protected]>---
hw/lsi53c895a.c | 2 --1 files changed, 0 insertions(+), 2 deletions(-)hw/lsi53c895a.c +0
-1@@ -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) {Acked-by Paolo Bonzini <[email protected]>
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~
Stefan Hajnoczi
AppliedRe: [Qemu-devel] [PATCH 1/3] lsi: Fix unused-but-set-variable warning
In reply to Christophe FergeauQuoted 6 lines · Christophe Fergeau
This warning is new in gcc 4.6.
Signed-off-by Christophe Fergeau <[email protected]>--- hw/lsi53c895a.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-)
Thanks, applied to the trivial patches tree:
http://repo.or.cz/w/qemu/stefanha.git/shortlog/refs/heads/trivial-patches
Stefan
PATCH 2/3 ehci: Fix unused-but-set-variable warning
In reply to Christophe FergeauThis 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
@@ -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
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
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->pidinstead 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
PATCH 3/3 linux-user: Fix unused-but-set-variable warning
In reply to Christophe FergeauThis 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
@@ -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