Skip to contentSkip to conversation

Removal of several unused variables causing

PATCH In review [email protected] 2 participants 9 messages Nov 9, 2022 – Nov 10, 2022

lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

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
index 6b65823b4b..e6643e3c9d 100644
@@ -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
Reviewed-by on v1 1/4
#2 lore raw

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_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 -1
index 6b65823b4b..e6643e3c9d 100644
@@ -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 */
#3 lore raw

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
index b9e42c322a..c2b3b1bdfa 100644
@@ -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
Reviewed-by on v1 2/4
#4 lore raw

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_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 -2
index b9e42c322a..c2b3b1bdfa 100644
@@ -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) {
#5 lore raw

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
index a3b64c88af..a9b3a8103c 100644
@@ -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
Reviewed-by on v1 3/4
#6 lore raw

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_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 +1 -1
index a3b64c88af..a9b3a8103c 100644
@@ -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);
#7 lore raw

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
index 28f8af8941..176868d345 100644
@@ -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
Reviewed-by on v1 4/4
#8 lore raw

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_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 -8
index 28f8af8941..176868d345 100644
@@ -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) {