Removal of several unused variables causing
cover Removal of several unused variables causing
From: Miroslav Rezanina <[email protected]>
When trying to run qemu build using clang 15.0.1 compiler with --enable-werror option, several 'Unused but set variable' warnings was breaking the build.
These variables show similar pattern - they are only incremented but final value of the variable is never used.
Removing this variables to enable using --enable-werror option with Clang 15.0.1.
Miroslav Rezanina (4):
rtl8139: Remove unused variable
tulip: Remove unused variable
qemu-img: remove unused variable
host-libusb: Remove unused variable
hw/net/rtl8139.c | 2 -- hw/net/tulip.c | 4 +--- hw/usb/host-libusb.c | 15 --------------- qemu-img.c | 4 ++-- 4 files changed, 3 insertions(+), 22 deletions(-)
Signature · 1 line
2.31.1
PATCH 1/4 rtl8139: Remove unused variable
From: Miroslav Rezanina <[email protected]>
Variable send_count used in rtl8139_cplus_transmit_one function is only incremented but never read. This causes 'Unused but set variable' warning on Clang 15.0.1 compiler.
Removing the variable to prevent the warning.
--- hw/net/rtl8139.c | 2 -- 1 file changed, 2 deletions(-)
hw/net/rtl8139.c +0 -2
@@ -2156,7 +2156,6 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s) ip_data_len, saved_size - ETH_HLEN, large_send_mss);int tcp_send_offset =0 ; -int send_count =0 ;/* maximum IP header length is 60 bytes */ uint8_t saved_ip_header[60 ];
@@ -2261,7 +2260,6 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s)/* add transferred count to TCP sequence number */ stl_be_p (&p_tcp_hdr->th_seq, chunk_size +ldl_be_p (&p_tcp_hdr->th_seq)); - ++send_count; }/* Stop sending this frame */
Signature · 1 line
2.31.1
Re: [PATCH 1/4] rtl8139: Remove unused variable
Quoted 26 lines · On 09/11/2022 16.57, [email protected] wrote:
From: Miroslav Rezanina <[email protected]>
Variable
send_countused inrtl8139_cplus_transmit_onefunction is only incremented but never read. This causes 'Unused but set variable' warning on Clang 15.0.1 compiler.Removing the variable to prevent the warning.
Signed-off-by Miroslav Rezanina <[email protected]>--- hw/net/rtl8139.c | 2 -- 1 file changed, 2 deletions(-)hw/net/rtl8139.c +0
-1@@ -2156,7 +2156,6 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s) ip_data_len, saved_size - ETH_HLEN, large_send_mss);int tcp_send_offset =0 ; -int send_count =0 ;/* maximum IP header length is 60 bytes */ uint8_t saved_ip_header[60 ];
hw/net/rtl8139.c static int rtl8139_cplus_transmit_one(RTL8139State *s) · line 2265
Quoted 7 lines
hw/net/rtl8139.c +0
-1@@ -2261,7 +2260,6 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s)/* add transferred count to TCP sequence number */ stl_be_p (&p_tcp_hdr->th_seq, chunk_size +ldl_be_p (&p_tcp_hdr->th_seq)); - ++send_count; }/* Stop sending this frame */
PATCH 2/4 tulip: Remove unused variable
In reply to [email protected]From: Miroslav Rezanina <[email protected]>
Variable n used in tulip_idblock_crc function is only incremented but never read. This causes 'Unused but set variable' warning on Clang 15.0.1 compiler.
Removing the variable to prevent the warning.
--- hw/net/tulip.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
hw/net/tulip.c +1 -3
@@ -870,11 +870,10 @@ static const MemoryRegionOps tulip_ops = {static void tulip_idblock_crc (TULIPState *s,uint16_t *srom) { -int word, n; +int word;int bit;unsigned char bitval, crc;const int len =9 ; - n =0 ; crc =-1 ;for (word =0 ; word < len; word++) {
@@ -887,7 +886,6 @@ static void tulip_idblock_crc(TULIPState *s, uint16_t *srom) srom[len -1 ] = (srom[len -1 ] &0xff00 ) | (unsigned short )crc;break ; } - n++; bitval = ((srom[word] >> bit) &1 ) ^ ((crc >>7 ) &1 ); crc = crc <<1 ;if (bitval ==1 ) {
Signature · 1 line
2.31.1
Re: [PATCH 2/4] tulip: Remove unused variable
Quoted 30 lines · On 09/11/2022 16.57, [email protected] wrote:
From: Miroslav Rezanina <[email protected]>
Variable n used in
tulip_idblock_crcfunction is only incremented but never read. This causes 'Unused but set variable' warning on Clang 15.0.1 compiler.Removing the variable to prevent the warning.
Signed-off-by Miroslav Rezanina <[email protected]>--- hw/net/tulip.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)hw/net/tulip.c +1
-2@@ -870,11 +870,10 @@ static const MemoryRegionOps tulip_ops = {static void tulip_idblock_crc (TULIPState *s,uint16_t *srom) { -int word, n; +int word;int bit;unsigned char bitval, crc;const int len =9 ; - n =0 ; crc =-1 ;for (word =0 ; word < len; word++) {
hw/net/tulip.c static void tulip_idblock_crc(TULIPState *s, uint16_t *srom) · line 891
Quoted 7 lines
hw/net/tulip.c +0
-1@@ -887,7 +886,6 @@ static void tulip_idblock_crc(TULIPState *s, uint16_t *srom) srom[len -1 ] = (srom[len -1 ] &0xff00 ) | (unsigned short )crc;break ; } - n++; bitval = ((srom[word] >> bit) &1 ) ^ ((crc >>7 ) &1 ); crc = crc <<1 ;if (bitval ==1 ) {
PATCH 3/4 qemu-img: remove unused variable
In reply to [email protected]From: Miroslav Rezanina <[email protected]>
Variable block_count used in img_dd function is only incremented but never read. This causes 'Unused but set variable' warning on Clang 15.0.1 compiler.
Removing the variable to prevent the warning.
--- qemu-img.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
qemu-img.c +2 -2
@@ -4922,7 +4922,7 @@ static int img_dd(int argc, char **argv)const char *out_fmt ="raw" ;const char *fmt =NULL ;int64_t size =0 ; -int64_t block_count =0 , out_pos, in_pos; +int64_t out_pos, in_pos;bool force_share = false;struct DdInfo dd = { .flags =0 ,
@@ -5122,7 +5122,7 @@ static int img_dd(int argc, char **argv) in.buf =g_new (uint8_t, in.bsz); -for (out_pos =0 ; in_pos < size; block_count++) { +for (out_pos =0 ; in_pos < size; ) {int bytes = (in_pos + in.bsz > size) ? size - in_pos : in.bsz; ret =blk_pread (blk1, in_pos, bytes, in.buf,0 );
Signature · 1 line
2.31.1
Re: [PATCH 3/4] qemu-img: remove unused variable
Quoted 26 lines · On 09/11/2022 16.57, [email protected] wrote:
From: Miroslav Rezanina <[email protected]>
Variable
block_countused inimg_ddfunction is only incremented but never read. This causes 'Unused but set variable' warning on Clang 15.0.1 compiler.Removing the variable to prevent the warning.
Signed-off-by Miroslav Rezanina <[email protected]>--- qemu-img.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)qemu-img.c +1
-1@@ -4922,7 +4922,7 @@ static int img_dd(int argc, char **argv)const char *out_fmt ="raw" ;const char *fmt =NULL ;int64_t size =0 ; -int64_t block_count =0 , out_pos, in_pos; +int64_t out_pos, in_pos;bool force_share = false;struct DdInfo dd = { .flags =0 ,
qemu-img.c static int img_dd(int argc, char **argv) · line 5128
Quoted 8 lines
qemu-img.c +1
-1@@ -5122,7 +5122,7 @@ static int img_dd(int argc, char **argv) in.buf =g_new (uint8_t, in.bsz); -for (out_pos =0 ; in_pos < size; block_count++) { +for (out_pos =0 ; in_pos < size; ) {int bytes = (in_pos + in.bsz > size) ? size - in_pos : in.bsz; ret =blk_pread (blk1, in_pos, bytes, in.buf,0 );
PATCH 4/4 host-libusb: Remove unused variable
In reply to [email protected]From: Miroslav Rezanina <[email protected]>
Variable unconnected used in usb_host_auto_check function is only incremented but never read as line where it is read was disabled since introducing the code. This causes 'Unused but set variable' warning on Clang 15.0.1 compiler.
Removing the variable and disabled code to prevent the warning.
--- hw/usb/host-libusb.c | 15 --------------- 1 file changed, 15 deletions(-)
hw/usb/host-libusb.c +0 -15
@@ -1837,7 +1837,6 @@ static void usb_host_auto_check(void *unused)struct USBAutoFilter *f;libusb_device **devs =NULL ;struct libusb_device_descriptor ddesc; -int unconnected =0 ;int i, n;if (usb_host_init () !=0 ) {
@@ -1897,9 +1896,6 @@ static void usb_host_auto_check(void *unused)libusb_free_device_list (devs,1 ); QTAILQ_FOREACH(s, &hostdevs, next) { -if (s->dh ==NULL ) { - unconnected++; - }if (s->seen ==0 ) {if (s->dh) {usb_host_close (s);
@@ -1908,17 +1904,6 @@ static void usb_host_auto_check(void *unused) } s->seen =0 ; } - -#if 0 -if (unconnected ==0 ) { -/* nothing to watch */ -if (usb_auto_timer) { -timer_del (usb_auto_timer); -trace_usb_host_auto_scan_disabled (); - } -return ; - } -#endif }if (!usb_vmstate) {
Signature · 1 line
2.31.1
Re: [PATCH 4/4] host-libusb: Remove unused variable
Quoted 43 lines · On 09/11/2022 16.57, [email protected] wrote:
From: Miroslav Rezanina <[email protected]>
Variable unconnected used in
usb_host_auto_checkfunction is only incremented but never read as line where it is read was disabled since introducing the code. This causes 'Unused but set variable' warning on Clang 15.0.1 compiler.Removing the variable and disabled code to prevent the warning.
Signed-off-by Miroslav Rezanina <[email protected]>--- hw/usb/host-libusb.c | 15 --------------- 1 file changed, 15 deletions(-)hw/usb/host-libusb.c +0
-8@@ -1837,7 +1837,6 @@ static void usb_host_auto_check(void *unused)struct USBAutoFilter *f;libusb_device **devs =NULL ;struct libusb_device_descriptor ddesc; -int unconnected =0 ;int i, n;if (usb_host_init () !=0 ) {@@ -1897,9 +1896,6 @@ static void usb_host_auto_check(void *unused)libusb_free_device_list (devs,1 ); QTAILQ_FOREACH(s, &hostdevs, next) { -if (s->dh ==NULL ) { - unconnected++; - }if (s->seen ==0 ) {if (s->dh) {usb_host_close (s);@@ -1908,17 +1904,6 @@ static void usb_host_auto_check(void *unused) } s->seen =0 ; } - -#if 0 -if (unconnected ==0 ) { -/* nothing to watch */
hw/usb/host-libusb.c static void usb_host_auto_check(void *unused) · line 1909
Quoted 10 lines
hw/usb/host-libusb.c +0
-7-if (usb_auto_timer) { -timer_del (usb_auto_timer); -trace_usb_host_auto_scan_disabled (); - } - return; - } -#endif }if (!usb_vmstate) {