All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] Removal of several unused variables causing
@ 2022-11-09 15:57 mrezanin
  2022-11-09 15:57 ` [PATCH 1/4] rtl8139: Remove unused variable mrezanin
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: mrezanin @ 2022-11-09 15:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: Miroslav Rezanina

From: Miroslav Rezanina <mrezanin@redhat.com>

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(-)

-- 
2.31.1



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/4] rtl8139: Remove unused variable
  2022-11-09 15:57 [PATCH 0/4] Removal of several unused variables causing mrezanin
@ 2022-11-09 15:57 ` mrezanin
  2022-11-10  8:40   ` Thomas Huth
  2022-11-09 15:57 ` [PATCH 2/4] tulip: " mrezanin
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: mrezanin @ 2022-11-09 15:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: Miroslav Rezanina

From: Miroslav Rezanina <mrezanin@redhat.com>

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.

Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
---
 hw/net/rtl8139.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
index 6b65823b4b..e6643e3c9d 100644
--- a/hw/net/rtl8139.c
+++ b/hw/net/rtl8139.c
@@ -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 */
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/4] tulip: Remove unused variable
  2022-11-09 15:57 [PATCH 0/4] Removal of several unused variables causing mrezanin
  2022-11-09 15:57 ` [PATCH 1/4] rtl8139: Remove unused variable mrezanin
@ 2022-11-09 15:57 ` mrezanin
  2022-11-10  8:41   ` Thomas Huth
  2022-11-09 15:57 ` [PATCH 3/4] qemu-img: remove " mrezanin
  2022-11-09 15:57 ` [PATCH 4/4] host-libusb: Remove " mrezanin
  3 siblings, 1 reply; 9+ messages in thread
From: mrezanin @ 2022-11-09 15:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: Miroslav Rezanina

From: Miroslav Rezanina <mrezanin@redhat.com>

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.

Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
---
 hw/net/tulip.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/hw/net/tulip.c b/hw/net/tulip.c
index b9e42c322a..c2b3b1bdfa 100644
--- a/hw/net/tulip.c
+++ b/hw/net/tulip.c
@@ -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) {
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/4] qemu-img: remove unused variable
  2022-11-09 15:57 [PATCH 0/4] Removal of several unused variables causing mrezanin
  2022-11-09 15:57 ` [PATCH 1/4] rtl8139: Remove unused variable mrezanin
  2022-11-09 15:57 ` [PATCH 2/4] tulip: " mrezanin
@ 2022-11-09 15:57 ` mrezanin
  2022-11-10  8:43   ` Thomas Huth
  2022-11-09 15:57 ` [PATCH 4/4] host-libusb: Remove " mrezanin
  3 siblings, 1 reply; 9+ messages in thread
From: mrezanin @ 2022-11-09 15:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: Miroslav Rezanina

From: Miroslav Rezanina <mrezanin@redhat.com>

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.

Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
---
 qemu-img.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/qemu-img.c b/qemu-img.c
index a3b64c88af..a9b3a8103c 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -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);
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 4/4] host-libusb: Remove unused variable
  2022-11-09 15:57 [PATCH 0/4] Removal of several unused variables causing mrezanin
                   ` (2 preceding siblings ...)
  2022-11-09 15:57 ` [PATCH 3/4] qemu-img: remove " mrezanin
@ 2022-11-09 15:57 ` mrezanin
  2022-11-10  8:44   ` Thomas Huth
  3 siblings, 1 reply; 9+ messages in thread
From: mrezanin @ 2022-11-09 15:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: Miroslav Rezanina

From: Miroslav Rezanina <mrezanin@redhat.com>

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.

Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
---
 hw/usb/host-libusb.c | 15 ---------------
 1 file changed, 15 deletions(-)

diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
index 28f8af8941..176868d345 100644
--- a/hw/usb/host-libusb.c
+++ b/hw/usb/host-libusb.c
@@ -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) {
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/4] rtl8139: Remove unused variable
  2022-11-09 15:57 ` [PATCH 1/4] rtl8139: Remove unused variable mrezanin
@ 2022-11-10  8:40   ` Thomas Huth
  0 siblings, 0 replies; 9+ messages in thread
From: Thomas Huth @ 2022-11-10  8:40 UTC (permalink / raw)
  To: mrezanin, qemu-devel; +Cc: QEMU Trivial, Jason Wang

On 09/11/2022 16.57, mrezanin@redhat.com wrote:
> From: Miroslav Rezanina <mrezanin@redhat.com>
> 
> 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.
> 
> Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
> ---
>   hw/net/rtl8139.c | 2 --
>   1 file changed, 2 deletions(-)
> 
> diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
> index 6b65823b4b..e6643e3c9d 100644
> --- a/hw/net/rtl8139.c
> +++ b/hw/net/rtl8139.c
> @@ -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 */

Reviewed-by: Thomas Huth <thuth@redhat.com>



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/4] tulip: Remove unused variable
  2022-11-09 15:57 ` [PATCH 2/4] tulip: " mrezanin
@ 2022-11-10  8:41   ` Thomas Huth
  0 siblings, 0 replies; 9+ messages in thread
From: Thomas Huth @ 2022-11-10  8:41 UTC (permalink / raw)
  To: mrezanin, qemu-devel; +Cc: QEMU Trivial, Jason Wang

On 09/11/2022 16.57, mrezanin@redhat.com wrote:
> From: Miroslav Rezanina <mrezanin@redhat.com>
> 
> 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.
> 
> Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
> ---
>   hw/net/tulip.c | 4 +---
>   1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/hw/net/tulip.c b/hw/net/tulip.c
> index b9e42c322a..c2b3b1bdfa 100644
> --- a/hw/net/tulip.c
> +++ b/hw/net/tulip.c
> @@ -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) {

Reviewed-by: Thomas Huth <thuth@redhat.com>



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 3/4] qemu-img: remove unused variable
  2022-11-09 15:57 ` [PATCH 3/4] qemu-img: remove " mrezanin
@ 2022-11-10  8:43   ` Thomas Huth
  0 siblings, 0 replies; 9+ messages in thread
From: Thomas Huth @ 2022-11-10  8:43 UTC (permalink / raw)
  To: mrezanin, qemu-devel, Kevin Wolf, Hanna Reitz; +Cc: Qemu-block

On 09/11/2022 16.57, mrezanin@redhat.com wrote:
> From: Miroslav Rezanina <mrezanin@redhat.com>
> 
> 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.
> 
> Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
> ---
>   qemu-img.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/qemu-img.c b/qemu-img.c
> index a3b64c88af..a9b3a8103c 100644
> --- a/qemu-img.c
> +++ b/qemu-img.c
> @@ -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);

Reviewed-by: Thomas Huth <thuth@redhat.com>



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 4/4] host-libusb: Remove unused variable
  2022-11-09 15:57 ` [PATCH 4/4] host-libusb: Remove " mrezanin
@ 2022-11-10  8:44   ` Thomas Huth
  0 siblings, 0 replies; 9+ messages in thread
From: Thomas Huth @ 2022-11-10  8:44 UTC (permalink / raw)
  To: mrezanin, qemu-devel; +Cc: QEMU Trivial, Gerd Hoffmann

On 09/11/2022 16.57, mrezanin@redhat.com wrote:
> From: Miroslav Rezanina <mrezanin@redhat.com>
> 
> 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.
> 
> Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
> ---
>   hw/usb/host-libusb.c | 15 ---------------
>   1 file changed, 15 deletions(-)
> 
> diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
> index 28f8af8941..176868d345 100644
> --- a/hw/usb/host-libusb.c
> +++ b/hw/usb/host-libusb.c
> @@ -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) {

Reviewed-by: Thomas Huth <thuth@redhat.com>



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-11-10  8:45 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-09 15:57 [PATCH 0/4] Removal of several unused variables causing mrezanin
2022-11-09 15:57 ` [PATCH 1/4] rtl8139: Remove unused variable mrezanin
2022-11-10  8:40   ` Thomas Huth
2022-11-09 15:57 ` [PATCH 2/4] tulip: " mrezanin
2022-11-10  8:41   ` Thomas Huth
2022-11-09 15:57 ` [PATCH 3/4] qemu-img: remove " mrezanin
2022-11-10  8:43   ` Thomas Huth
2022-11-09 15:57 ` [PATCH 4/4] host-libusb: Remove " mrezanin
2022-11-10  8:44   ` Thomas Huth

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.