Skip to contentSkip to conversation

redundant code: Fix warnings reported by Clang static code analyzer

PATCH Superseded [email protected] 3 participants 22 messages Feb 25, 2020

Subsystems (2)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

cover redundant code: Fix warnings reported by Clang static code analyzer

From: Chen Qun <[email protected]>

Hi all, our EulerRobot integrates clang static code analyzer tools and found a lot of warnings. They are mainly redundant variable assignments.

This series fixes the warnings.

Chen Qun (13):
block/stream: Remove redundant statement in stream_run() block/iscsi:Remove redundant statement in iscsi_open() block/file-posix: Remove redundant statement in raw_handle_perm_lock() scsi/esp-pci: Remove redundant statement in esp_pci_io_write() scsi/scsi-disk: Remove redundant statement in
scsi_disk_emulate_command()
display/pxa2xx_lcd: Remove redundant statement in
pxa2xx_palette_parse()
display/exynos4210_fimd: Remove redundant statement in

    exynos4210_fimd_update()
  display/blizzard: Remove redundant statement in
    blizzard_draw_line16_32()
  dma/xlnx-zdma: Remove redundant statement in zdma_write_dst()
  migration/vmstate: Remove redundant statement in
    vmstate_save_state_v()
  timer/exynos4210_mct: Remove redundant statement in
    exynos4210_mct_write()

usb/hcd-ehci: Remove redundant statements
monitor/hmp-cmds: Remove redundant statement in
hmp_rocker_of_dpa_groups()

 block/file-posix.c           | 1 -
 block/iscsi.c                | 1 -
 block/stream.c               | 1 -
 hw/display/blizzard.c        | 1 -
 hw/display/exynos4210_fimd.c | 1 -
 hw/display/pxa2xx_lcd.c      | 1 -
 hw/dma/xlnx-zdma.c           | 2 --
 hw/scsi/esp-pci.c            | 1 -
 hw/scsi/scsi-disk.c          | 1 -
 hw/timer/exynos4210_mct.c    | 4 ----
 hw/usb/hcd-ehci.c            | 3 ---
 migration/vmstate.c          | 1 -
 monitor/hmp-cmds.c           | 1 -
 13 files changed, 19 deletions(-)
Signature · 1 line
2.23.0
#1 lore raw

PATCH 1/13 block/stream: Remove redundant statement in stream_run()

From: Chen Qun <[email protected]>

Clang static code analyzer show warning:
block/stream.c:186:9: warning: Value stored to 'ret' is never read

        ret = 0;
        ^     ~

---
Cc: John Snow <[email protected]>
Cc: Kevin Wolf <[email protected]>
Cc: Max Reitz <[email protected]>
Cc: [email protected]

---
 block/stream.c | 1 -
 1 file changed, 1 deletion(-)
block/stream.c +0 -1
index 5562ccbf57..d78074ac80 100644
@@ -183,7 +183,6 @@ static int coroutine_fn stream_run(Job *job, Error **errp)
                 break;
             }
         }
-        ret = 0;
 
         /* Publish progress */
         job_progress_update(&s->common.job, n);
Signature · 1 line
2.23.0
Reviewed-by on v1 1/13
#2 lore raw

Re: [PATCH 01/13] block/stream: Remove redundant statement in stream_run()

Quoted 23 lines · On 2/24/20 9:09 PM, [email protected] wrote:

From: Chen Qun <[email protected]>

Clang static code analyzer show warning:
block/stream.c:186:9: warning: Value stored to 'ret' is never read

        ret = 0;
        ^     ~

---
Cc: John Snow <[email protected]>
Cc: Kevin Wolf <[email protected]>
Cc: Max Reitz <[email protected]>
Cc: [email protected]

---
 block/stream.c | 1 -
 1 file changed, 1 deletion(-)
block/stream.c +0 -0
index 5562ccbf57..d78074ac80 100644

block/stream.c static int coroutine_fn stream_run(Job *job, Error **errp) · line 188

Quoted 7 lines
block/stream.c +0 -1
@@ -183,7 +183,6 @@ static int coroutine_fn stream_run(Job *job, Error **errp)
                 break;
             }
         }
-        ret = 0;
 
         /* Publish progress */
         job_progress_update(&s->common.job, n);
#3 lore raw

PATCH 2/13 block/iscsi:Remove redundant statement in iscsi_open()

In reply to [email protected]

From: Chen Qun <[email protected]>

Clang static code analyzer show warning:
block/iscsi.c:1920:9: warning: Value stored to 'flags' is never read

        flags &= ~BDRV_O_RDWR;
        ^        ~~~~~~~~~~~~

---
Cc: Ronnie Sahlberg <[email protected]>
Cc: Paolo Bonzini <[email protected]>
Cc: Peter Lieven <[email protected]>
Cc: Kevin Wolf <[email protected]>
Cc: Max Reitz <[email protected]>
Cc: [email protected]

---
 block/iscsi.c | 1 -
 1 file changed, 1 deletion(-)
block/iscsi.c +0 -1
index 682abd8e09..ed88479ede 100644
@@ -1917,7 +1917,6 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags,
         if (ret < 0) {
             goto out;
         }
-        flags &= ~BDRV_O_RDWR;
     }
 
     iscsi_readcapacity_sync(iscsilun, &local_err);
Signature · 1 line
2.23.0
#4 lore raw

PATCH 3/13 block/file-posix: Remove redundant statement in raw_handle_perm_lock()

In reply to [email protected]

From: Chen Qun <[email protected]>

Clang static code analyzer show warning:
block/file-posix.c:891:9: warning: Value stored to 'op' is never read

        op = RAW_PL_ABORT;
        ^    ~~~~~~~~~~~~

---
Cc: Kevin Wolf <[email protected]>
Cc: Max Reitz <[email protected]>
Cc: [email protected]

---
 block/file-posix.c | 1 -
 1 file changed, 1 deletion(-)
block/file-posix.c +0 -1
index 6345477112..0f77447a25 100644
@@ -888,7 +888,6 @@ static int raw_handle_perm_lock(BlockDriverState *bs,
                               "Is another process using the image [%s]?\n",
                               bs->filename);
         }
-        op = RAW_PL_ABORT;
         /* fall through to unlock bytes. */
     case RAW_PL_ABORT:
         raw_apply_lock_bytes(s, s->fd, s->perm, ~s->shared_perm,
Signature · 1 line
2.23.0
#5 lore raw

PATCH 4/13 scsi/esp-pci: Remove redundant statement in esp_pci_io_write()

In reply to [email protected]

From: Chen Qun <[email protected]>

Clang static code analyzer show warning:
hw/scsi/esp-pci.c:198:9: warning: Value stored to 'size' is never read

        size = 4;
        ^      ~

---
Cc: Paolo Bonzini <[email protected]>
Cc: Fam Zheng <[email protected]>

---
 hw/scsi/esp-pci.c | 1 -
 1 file changed, 1 deletion(-)
hw/scsi/esp-pci.c +0 -1
index d5a1f9e017..2e6cc07d4e 100644
@@ -195,7 +195,6 @@ static void esp_pci_io_write(void *opaque, hwaddr addr,
         val <<= shift;
         val |= current & ~(mask << shift);
         addr &= ~3;
-        size = 4;
     }
 
     if (addr < 0x40) {
Signature · 1 line
2.23.0
#6 lore raw

PATCH 5/13 scsi/scsi-disk: Remove redundant statement in scsi_disk_emulate_command()

In reply to [email protected]

From: Chen Qun <[email protected]>

Clang static code analyzer show warning:
scsi/scsi-disk.c:1918:5: warning: Value stored to 'buflen' is never read

    buflen = req->cmd.xfer;
    ^        ~~~~~~~~~~~~~

---
Cc: Paolo Bonzini <[email protected]>
Cc: Fam Zheng <[email protected]>

---
 hw/scsi/scsi-disk.c | 1 -
 1 file changed, 1 deletion(-)
hw/scsi/scsi-disk.c +0 -1
index 10d0794d60..1c0cb63a6f 100644
@@ -1915,7 +1915,6 @@ static int32_t scsi_disk_emulate_command(SCSIRequest *req, uint8_t *buf)
         r->iov.iov_base = blk_blockalign(s->qdev.conf.blk, r->buflen);
     }
 
-    buflen = req->cmd.xfer;
     outbuf = r->iov.iov_base;
     memset(outbuf, 0, r->buflen);
     switch (req->cmd.buf[0]) {
Signature · 1 line
2.23.0
#7 lore raw

PATCH 6/13 display/pxa2xx_lcd: Remove redundant statement in pxa2xx_palette_parse()

In reply to [email protected]

From: Chen Qun <[email protected]>

Clang static code analyzer show warning:
hw/display/pxa2xx_lcd.c:596:9: warning: Value stored to 'format' is never read

        format = 0;
        ^        ~

---
Cc: Andrzej Zaborowski <[email protected]>
Cc: Peter Maydell <[email protected]>
Cc: [email protected]

---
 hw/display/pxa2xx_lcd.c | 1 -
 1 file changed, 1 deletion(-)
hw/display/pxa2xx_lcd.c +0 -1
index 05f5f84671..464e93161a 100644
@@ -593,7 +593,6 @@ static void pxa2xx_palette_parse(PXA2xxLCDState *s, int ch, int bpp)
         n = 256;
         break;
     default:
-        format = 0;
         return;
     }
 
Signature · 1 line
2.23.0
#8 lore raw

PATCH 7/13 display/exynos4210_fimd: Remove redundant statement in exynos4210_fimd_update()

In reply to [email protected]

From: Chen Qun <[email protected]>

Clang static code analyzer show warning:
hw/display/exynos4210_fimd.c:1313:17: warning: Value stored to 'is_dirty' is never read

                is_dirty = false;

---
Cc: Igor Mitsyanko <[email protected]>
Cc: Peter Maydell <[email protected]>
Cc: [email protected]

---
 hw/display/exynos4210_fimd.c | 1 -
 1 file changed, 1 deletion(-)
hw/display/exynos4210_fimd.c +0 -1
index c1071ecd46..05d3265b76 100644
@@ -1310,7 +1310,6 @@ static void exynos4210_fimd_update(void *opaque)
                 }
                 host_fb_addr += inc_size;
                 fb_line_addr += inc_size;
-                is_dirty = false;
             }
             g_free(snap);
             blend = true;
Signature · 1 line
2.23.0
#9 lore raw

PATCH 8/13 display/blizzard: Remove redundant statement in blizzard_draw_line16_32()

In reply to [email protected]

From: Chen Qun <[email protected]>

Clang static code analyzer show warning:
hw/display/blizzard.c:940:9: warning: Value stored to 'data' is never read

        data >>= 5;
        ^        ~

---
Cc: Andrzej Zaborowski <[email protected]>
Cc: Peter Maydell <[email protected]>
Cc: [email protected]

---
 hw/display/blizzard.c | 1 -
 1 file changed, 1 deletion(-)
hw/display/blizzard.c +0 -1
index 359e399c2a..62517bdf75 100644
@@ -937,7 +937,6 @@ static void blizzard_draw_line16_32(uint32_t *dest,
         g = (data & 0x3f) << 2;
         data >>= 6;
         r = (data & 0x1f) << 3;
-        data >>= 5;
         *dest++ = rgb_to_pixel32(r, g, b);
     }
 }
Signature · 1 line
2.23.0
#10 lore raw

PATCH 9/13 dma/xlnx-zdma: Remove redundant statement in zdma_write_dst()

In reply to [email protected]

From: Chen Qun <[email protected]>

Clang static code analyzer show warning:
hw/dma/xlnx-zdma.c:399:13: warning: Value stored to 'dst_type' is never read

            dst_type = FIELD_EX32(s->dsc_dst.words[3], ZDMA_CH_DST_DSCR_WORD3,
            ^          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---
Cc: Alistair Francis <[email protected]>
Cc: "Edgar E. Iglesias" <[email protected]>
Cc: Peter Maydell <[email protected]>
Cc: [email protected]

---
 hw/dma/xlnx-zdma.c | 2 --
 1 file changed, 2 deletions(-)
hw/dma/xlnx-zdma.c +0 -2
index 8fb83f5b07..45355c5d59 100644
@@ -396,8 +396,6 @@ static void zdma_write_dst(XlnxZDMA *s, uint8_t *buf, uint32_t len)
             zdma_load_descriptor(s, next, &s->dsc_dst);
             dst_size = FIELD_EX32(s->dsc_dst.words[2], ZDMA_CH_DST_DSCR_WORD2,
                                   SIZE);
-            dst_type = FIELD_EX32(s->dsc_dst.words[3], ZDMA_CH_DST_DSCR_WORD3,
-                                  TYPE);
         }
 
         /* Match what hardware does by ignoring the dst_size and only using
Signature · 1 line
2.23.0
#11 lore raw

Re: [PATCH 09/13] dma/xlnx-zdma: Remove redundant statement in zdma_write_dst()

Quoted 23 lines · On 2/25/20 3:09 AM, [email protected] wrote:

From: Chen Qun <[email protected]>

Clang static code analyzer show warning:
hw/dma/xlnx-zdma.c:399:13: warning: Value stored to 'dst_type' is never read

             dst_type = FIELD_EX32(s->dsc_dst.words[3], ZDMA_CH_DST_DSCR_WORD3,
             ^          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---
Cc: Alistair Francis <[email protected]>
Cc: "Edgar E. Iglesias" <[email protected]>
Cc: Peter Maydell <[email protected]>
Cc: [email protected]

---
  hw/dma/xlnx-zdma.c | 2 --
  1 file changed, 2 deletions(-)
hw/dma/xlnx-zdma.c +0 -0
index 8fb83f5b07..45355c5d59 100644

hw/dma/xlnx-zdma.c static void zdma_write_dst(XlnxZDMA *s, uint8_t *buf, uint32_t len) · line 400

Quoted 5 lines
hw/dma/xlnx-zdma.c +0 -2
@@ -396,8 +396,6 @@ static void zdma_write_dst(XlnxZDMA *s, uint8_t *buf, uint32_t len)
              zdma_load_descriptor(s, next, &s->dsc_dst);
              dst_size = FIELD_EX32(s->dsc_dst.words[2], ZDMA_CH_DST_DSCR_WORD2,
                                    SIZE);
-            dst_type = FIELD_EX32(s->dsc_dst.words[3], ZDMA_CH_DST_DSCR_WORD3,
-                                  TYPE);

Maybe move dst_type to this if() statement now?

Quoted 4 lines
hw/dma/xlnx-zdma.c +0 -0
          }
 
          /* Match what hardware does by ignoring the dst_size and only using
#12 lore raw

RE: [PATCH 09/13] dma/xlnx-zdma: Remove redundant statement in zdma_write_dst()

Quoted 43 lines

-----Original Message-----
From: Philippe Mathieu-Daudé [mailto:[email protected]]
Sent: Tuesday, February 25, 2020 5:36 PM
To: Chenqun (kuhn) <[email protected]>; qemu- [email protected]; [email protected]
Cc: [email protected]; Zhanghailiang <[email protected]>; Alistair Francis <[email protected]>; [email protected]
Subject: Re: [PATCH 09/13] dma/xlnx-zdma: Remove redundant statement in zdma_write_dst()

Quoted 4 lines · On 2/25/20 3:09 AM, [email protected] wrote:

From: Chen Qun <[email protected]>

Clang static code analyzer show warning:
hw/dma/xlnx-zdma.c:399:13: warning: Value stored to 'dst_type' is never

read

Quoted 1 line
             dst_type = FIELD_EX32(s->dsc_dst.words[3],

ZDMA_CH_DST_DSCR_WORD3,

Quoted 1 line
             ^

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

hw/dma/xlnx-zdma.c static void zdma_write_dst(XlnxZDMA *s, uint8_t

Quoted 17 lines

---
Cc: Alistair Francis <[email protected]>
Cc: "Edgar E. Iglesias" <[email protected]>
Cc: Peter Maydell <[email protected]>
Cc: [email protected]

---
  hw/dma/xlnx-zdma.c | 2 --
  1 file changed, 2 deletions(-)
hw/dma/xlnx-zdma.c index renamed from hw/dma/xlnx-zdma.c +0 -0

8fb83f5b07..45355c5d59 100644

hw/dma/xlnx-zdma.c +0 -0
@@ -396,8 +396,6 @@ static void zdma_write_dst(XlnxZDMA *s, uint8_t

*buf, uint32_t len)

hw/dma/xlnx-zdma.c static void zdma_write_dst(XlnxZDMA *s, uint8_t · line 397

Quoted 2 lines
hw/dma/xlnx-zdma.c +0 -0
              zdma_load_descriptor(s, next, &s->dsc_dst);
              dst_size = FIELD_EX32(s->dsc_dst.words[2],
Quoted 8 lines

ZDMA_CH_DST_DSCR_WORD2,

hw/dma/xlnx-zdma.c static void zdma_write_dst(XlnxZDMA *s, uint8_t · line 399

Quoted 2 lines
hw/dma/xlnx-zdma.c +0 -1
                                    SIZE);
-            dst_type = FIELD_EX32(s->dsc_dst.words[3],

ZDMA_CH_DST_DSCR_WORD3,

hw/dma/xlnx-zdma.c static void zdma_write_dst(XlnxZDMA *s, uint8_t *buf, uint32_t len) · line 400

Quoted 1 line
hw/dma/xlnx-zdma.c +0 -1
-                                  TYPE);

Maybe move dst_type to this if() statement now?

Sorry, I don't follow you. I didn't find where I could move dst_type.
Do you mean to move the first dst_type to the if(). Modify it like this:

    while (len) {
        dst_size = FIELD_EX32(s->dsc_dst.words[2], ZDMA_CH_DST_DSCR_WORD2,
                              SIZE);
        if (dst_size == 0 && ptype == PT_MEM) {
            uint64_t next;
            dst_type = FIELD_EX32(s->dsc_dst.words[3], ZDMA_CH_DST_DSCR_WORD3,
                              TYPE);
            next = zdma_update_descr_addr(s, dst_type,
                                          R_ZDMA_CH_DST_CUR_DSCR_LSB);
            zdma_load_descriptor(s, next, &s->dsc_dst);
            dst_size = FIELD_EX32(s->dsc_dst.words[2], ZDMA_CH_DST_DSCR_WORD2,
                                  SIZE);
        }
       ...

}

Thanks.

Quoted 5 lines
Quoted 5 lines
hw/dma/xlnx-zdma.c +0 -0
          }
 
          /* Match what hardware does by ignoring the dst_size and

only using

#13 lore raw

Re: [PATCH 09/13] dma/xlnx-zdma: Remove redundant statement in zdma_write_dst()

Quoted 52 lines · Chenqun (kuhn)
Quoted 41 lines

-----Original Message-----
From: Philippe Mathieu-Daudé [mailto:[email protected]]
Sent: Tuesday, February 25, 2020 5:36 PM
To: Chenqun (kuhn) <[email protected]>; qemu- [email protected]; [email protected]
Cc: [email protected]; Zhanghailiang <[email protected]>; Alistair Francis <[email protected]>; [email protected]
Subject: Re: [PATCH 09/13] dma/xlnx-zdma: Remove redundant statement in zdma_write_dst()

Quoted 4 lines · On 2/25/20 3:09 AM, [email protected] wrote:

From: Chen Qun <[email protected]>

Clang static code analyzer show warning:
hw/dma/xlnx-zdma.c:399:13: warning: Value stored to 'dst_type' is never

read

Quoted 1 line
              dst_type = FIELD_EX32(s->dsc_dst.words[3],

ZDMA_CH_DST_DSCR_WORD3,

Quoted 1 line
              ^

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

hw/dma/xlnx-zdma.c static void zdma_write_dst(XlnxZDMA *s, uint8_t

Quoted 17 lines

---
Cc: Alistair Francis <[email protected]>
Cc: "Edgar E. Iglesias" <[email protected]>
Cc: Peter Maydell <[email protected]>
Cc: [email protected]

---
   hw/dma/xlnx-zdma.c | 2 --
   1 file changed, 2 deletions(-)
hw/dma/xlnx-zdma.c index renamed from hw/dma/xlnx-zdma.c +0 -0

8fb83f5b07..45355c5d59 100644

hw/dma/xlnx-zdma.c +0 -0
@@ -396,8 +396,6 @@ static void zdma_write_dst(XlnxZDMA *s, uint8_t

*buf, uint32_t len)

hw/dma/xlnx-zdma.c static void zdma_write_dst(XlnxZDMA *s, uint8_t · line 397

Quoted 2 lines
hw/dma/xlnx-zdma.c +0 -0
               zdma_load_descriptor(s, next, &s->dsc_dst);
               dst_size = FIELD_EX32(s->dsc_dst.words[2],
Quoted 8 lines

ZDMA_CH_DST_DSCR_WORD2,

hw/dma/xlnx-zdma.c static void zdma_write_dst(XlnxZDMA *s, uint8_t · line 399

Quoted 2 lines
hw/dma/xlnx-zdma.c +0 -1
                                     SIZE);
-            dst_type = FIELD_EX32(s->dsc_dst.words[3],

ZDMA_CH_DST_DSCR_WORD3,

hw/dma/xlnx-zdma.c static void zdma_write_dst(XlnxZDMA *s, uint8_t *buf, uint32_t len) · line 400

Quoted 1 line
hw/dma/xlnx-zdma.c +0 -1
-                                  TYPE);

Maybe move dst_type to this if() statement now?

Sorry, I don't follow you. I didn't find where I could move dst_type.
Do you mean to move the first dst_type to the if(). Modify it like this:

Quoted 15 lines
     while (len) {
         dst_size = FIELD_EX32(s->dsc_dst.words[2], ZDMA_CH_DST_DSCR_WORD2,
                               SIZE);
         if (dst_size == 0 && ptype == PT_MEM) {
             uint64_t next;
             dst_type = FIELD_EX32(s->dsc_dst.words[3], ZDMA_CH_DST_DSCR_WORD3,
                               TYPE);
             next = zdma_update_descr_addr(s, dst_type,
                                           R_ZDMA_CH_DST_CUR_DSCR_LSB);
             zdma_load_descriptor(s, next, &s->dsc_dst);
             dst_size = FIELD_EX32(s->dsc_dst.words[2], ZDMA_CH_DST_DSCR_WORD2,
                                   SIZE);
         }
        ...
    }

No, like this:

-- >8 --
@@ -373,7 +373,7 @@ static uint64_t zdma_update_descr_addr(XlnxZDMA *s, bool type,
static void zdma_write_dst(XlnxZDMA *s, uint8_t *buf, uint32_t len)

 {
     uint32_t dst_size, dlen;
-    bool dst_intr, dst_type;
+    bool dst_intr;
     unsigned int ptype = ARRAY_FIELD_EX32(s->regs, ZDMA_CH_CTRL0, 
POINT_TYPE);
     unsigned int rw_mode = ARRAY_FIELD_EX32(s->regs, ZDMA_CH_CTRL0, MODE);
     unsigned int burst_type = ARRAY_FIELD_EX32(s->regs, ZDMA_CH_DATA_ATTR,
@@ -387,17 +387,17 @@ static void zdma_write_dst(XlnxZDMA *s, uint8_t *buf, uint32_t len)
     while (len) {
         dst_size = FIELD_EX32(s->dsc_dst.words[2], ZDMA_CH_DST_DSCR_WORD2,
                               SIZE);
-        dst_type = FIELD_EX32(s->dsc_dst.words[3], ZDMA_CH_DST_DSCR_WORD3,
-                              TYPE);
         if (dst_size == 0 && ptype == PT_MEM) {
             uint64_t next;
+            bool dst_type;
+
+            dst_type = FIELD_EX32(s->dsc_dst.words[3], ZDMA_CH_DST_DSCR_WORD3,
+                                  TYPE);
             next = zdma_update_descr_addr(s, dst_type,
                                           R_ZDMA_CH_DST_CUR_DSCR_LSB);
             zdma_load_descriptor(s, next, &s->dsc_dst);
             dst_size = FIELD_EX32(s->dsc_dst.words[2], 
ZDMA_CH_DST_DSCR_WORD2,
                                   SIZE);
-            dst_type = FIELD_EX32(s->dsc_dst.words[3], ZDMA_CH_DST_DSCR_WORD3,
-                                  TYPE);
         }

---

#14 lore raw

RE: [PATCH 09/13] dma/xlnx-zdma: Remove redundant statement in zdma_write_dst()

Quoted 118 lines

-----Original Message-----
From: Philippe Mathieu-Daudé [mailto:[email protected]]
Sent: Tuesday, February 25, 2020 6:12 PM
To: Chenqun (kuhn) <[email protected]>; qemu- [email protected]; [email protected]
Cc: [email protected]; Zhanghailiang <[email protected]>; Alistair Francis <[email protected]>; [email protected]
Subject: Re: [PATCH 09/13] dma/xlnx-zdma: Remove redundant statement in zdma_write_dst()

Quoted 4 lines · Chenqun (kuhn)
Quoted 4 lines

-----Original Message-----
From: Philippe Mathieu-Daudé [mailto:[email protected]]
Sent: Tuesday, February 25, 2020 5:36 PM
To: Chenqun (kuhn) <[email protected]>; qemu-

[email protected];

Quoted 45 lines
Quoted 45 lines

[email protected]
Cc: [email protected]; Zhanghailiang <[email protected]>; Alistair Francis <[email protected]>; [email protected]
Subject: Re: [PATCH 09/13] dma/xlnx-zdma: Remove redundant statement in
zdma_write_dst()

Quoted 5 lines · On 2/25/20 3:09 AM, [email protected] wrote:

From: Chen Qun <[email protected]>

Clang static code analyzer show warning:
hw/dma/xlnx-zdma.c:399:13: warning: Value stored to 'dst_type' is never

read

Quoted 1 line
              dst_type = FIELD_EX32(s->dsc_dst.words[3],

ZDMA_CH_DST_DSCR_WORD3,

Quoted 1 line
              ^

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

hw/dma/xlnx-zdma.c static void zdma_write_dst(XlnxZDMA *s, uint8_t

Quoted 17 lines

---
Cc: Alistair Francis <[email protected]>
Cc: "Edgar E. Iglesias" <[email protected]>
Cc: Peter Maydell <[email protected]>
Cc: [email protected]

---
   hw/dma/xlnx-zdma.c | 2 --
   1 file changed, 2 deletions(-)
hw/dma/xlnx-zdma.c index renamed from hw/dma/xlnx-zdma.c +0 -0

8fb83f5b07..45355c5d59 100644

hw/dma/xlnx-zdma.c +0 -0
@@ -396,8 +396,6 @@ static void zdma_write_dst(XlnxZDMA *s, uint8_t

*buf, uint32_t len)

hw/dma/xlnx-zdma.c static void zdma_write_dst(XlnxZDMA *s, uint8_t · line 397

Quoted 2 lines
hw/dma/xlnx-zdma.c +0 -0
               zdma_load_descriptor(s, next, &s->dsc_dst);
               dst_size = FIELD_EX32(s->dsc_dst.words[2],

ZDMA_CH_DST_DSCR_WORD2,

hw/dma/xlnx-zdma.c static void zdma_write_dst(XlnxZDMA *s, uint8_t · line 399

Quoted 2 lines
hw/dma/xlnx-zdma.c +0 -1
                                     SIZE);
-            dst_type = FIELD_EX32(s->dsc_dst.words[3],

ZDMA_CH_DST_DSCR_WORD3,

Quoted 1 line
hw/dma/xlnx-zdma.c +0 -1
-                                  TYPE);
Quoted 7 lines
Quoted 2 lines

Maybe move dst_type to this if() statement now?

Sorry, I don't follow you. I didn't find where I could move dst_type.
Do you mean to move the first dst_type to the if(). Modify it like this:

     while (len) {
         dst_size = FIELD_EX32(s->dsc_dst.words[2],

ZDMA_CH_DST_DSCR_WORD2,

Quoted 4 lines
                               SIZE);
         if (dst_size == 0 && ptype == PT_MEM) {
             uint64_t next;
             dst_type = FIELD_EX32(s->dsc_dst.words[3],

ZDMA_CH_DST_DSCR_WORD3,

Quoted 5 lines
                               TYPE);
             next = zdma_update_descr_addr(s, dst_type,
                                           R_ZDMA_CH_DST_CUR_DSCR_LSB);
             zdma_load_descriptor(s, next, &s->dsc_dst);
             dst_size = FIELD_EX32(s->dsc_dst.words[2],

ZDMA_CH_DST_DSCR_WORD2,

Quoted 4 lines
                                   SIZE);
         }
        ...
    }

No, like this:

-- >8 --

(quoted diff) +1 -1
@@ -373,7 +373,7 @@ static uint64_t zdma_update_descr_addr(XlnxZDMA
 *s, bool type,
 static void zdma_write_dst(XlnxZDMA *s, uint8_t *buf, uint32_t len)
 {
     uint32_t dst_size, dlen;
-    bool dst_intr, dst_type;
+    bool dst_intr;
     unsigned int ptype = ARRAY_FIELD_EX32(s->regs, ZDMA_CH_CTRL0,
 POINT_TYPE);
     unsigned int rw_mode = ARRAY_FIELD_EX32(s->regs, ZDMA_CH_CTRL0,
MODE);
     unsigned int burst_type = ARRAY_FIELD_EX32(s->regs,
ZDMA_CH_DATA_ATTR, @@ -387,17 +387,17 @@ static void
zdma_write_dst(XlnxZDMA *s, uint8_t *buf, uint32_t len)
     while (len) {
         dst_size = FIELD_EX32(s->dsc_dst.words[2],
ZDMA_CH_DST_DSCR_WORD2,
                               SIZE);

- dst_type = FIELD_EX32(s->dsc_dst.words[3],
ZDMA_CH_DST_DSCR_WORD3,

(quoted diff) +3 -1
-                              TYPE);
         if (dst_size == 0 && ptype == PT_MEM) {
             uint64_t next;
+            bool dst_type;
+
+            dst_type = FIELD_EX32(s->dsc_dst.words[3],

ZDMA_CH_DST_DSCR_WORD3,

Quoted 11 lines
+                                  TYPE);
             next = zdma_update_descr_addr(s, dst_type,
                                           R_ZDMA_CH_DST_CUR_DSCR_LSB);
             zdma_load_descriptor(s, next, &s->dsc_dst);
             dst_size = FIELD_EX32(s->dsc_dst.words[2],
ZDMA_CH_DST_DSCR_WORD2,
                                   SIZE);
-            dst_type = FIELD_EX32(s->dsc_dst.words[3],
ZDMA_CH_DST_DSCR_WORD3,
-                                  TYPE);
         }

Hmm, this is better.
I will modify it later in V2.

Thanks.

Quoted 1 line

---

#15 lore raw

PATCH 10/13 migration/vmstate: Remove redundant statement in vmstate_save_state_v()

In reply to [email protected]

From: Chen Qun <[email protected]>

The "ret" has been assigned in all branches. It didn't need to be
assigned separately.

Clang static code analyzer show warning:
migration/vmstate.c:365:17: warning: Value stored to 'ret' is never read

                ret = 0;
                ^     ~

---
Cc: Juan Quintela <[email protected]>
Cc: "Dr. David Alan Gilbert" <[email protected]>

---
 migration/vmstate.c | 1 -
 1 file changed, 1 deletion(-)
migration/vmstate.c +0 -1
index 7dd8ef66c6..bafa890384 100644
@@ -362,7 +362,6 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vmsd,
             }
             for (i = 0; i < n_elems; i++) {
                 void *curr_elem = first_elem + size * i;
-                ret = 0;
 
                 vmsd_desc_field_start(vmsd, vmdesc_loop, field, i, n_elems);
                 old_offset = qemu_ftell_fast(f);
Signature · 1 line
2.23.0
#16 lore raw

PATCH 11/13 timer/exynos4210_mct: Remove redundant statement in exynos4210_mct_write()

In reply to [email protected]

From: Chen Qun <[email protected]>

Clang static code analyzer show warning:
hw/timer/exynos4210_mct.c:1370:9: warning: Value stored to 'index' is never read

        index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i);
        ^       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hw/timer/exynos4210_mct.c:1399:9: warning: Value stored to 'index' is never read
        index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i);
        ^       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hw/timer/exynos4210_mct.c:1441:9: warning: Value stored to 'index' is never read
        index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i);
        ^       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---
Cc: Igor Mitsyanko <[email protected]>
Cc: Peter Maydell <[email protected]>
Cc: [email protected]

---
 hw/timer/exynos4210_mct.c | 4 ----
 1 file changed, 4 deletions(-)
hw/timer/exynos4210_mct.c +0 -4
index 944120aea5..570cf7075b 100644
@@ -1367,7 +1367,6 @@ static void exynos4210_mct_write(void *opaque, hwaddr offset,
 
     case L0_TCNTB: case L1_TCNTB:
         lt_i = GET_L_TIMER_IDX(offset);
-        index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i);
 
         /*
          * TCNTB is updated to internal register only after CNT expired.
@@ -1396,7 +1395,6 @@ static void exynos4210_mct_write(void *opaque, hwaddr offset,
 
     case L0_ICNTB: case L1_ICNTB:
         lt_i = GET_L_TIMER_IDX(offset);
-        index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i);
 
         s->l_timer[lt_i].reg.wstat |= L_WSTAT_ICNTB_WRITE;
         s->l_timer[lt_i].reg.cnt[L_REG_CNT_ICNTB] = value &
@@ -1438,8 +1436,6 @@ static void exynos4210_mct_write(void *opaque, hwaddr offset,
 
     case L0_FRCNTB: case L1_FRCNTB:
         lt_i = GET_L_TIMER_IDX(offset);
-        index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i);
-
         DPRINTF("local timer[%d] FRCNTB write %llx\n", lt_i, value);
 
         s->l_timer[lt_i].reg.wstat |= L_WSTAT_FRCCNTB_WRITE;
Signature · 1 line
2.23.0
#17 lore raw

PATCH 12/13 usb/hcd-ehci: Remove redundant statements

In reply to [email protected]

From: Chen Qun <[email protected]>

The "again" assignment is meaningless before g_assert_not_reached. In addition, the break statements no longer needs to be after g_assert_not_reached.

Clang static code analyzer show warning:
hw/usb/hcd-ehci.c:2108:13: warning: Value stored to 'again' is never read

            again = -1;
            ^       ~~

---
Cc: Gerd Hoffmann <[email protected]>

---
 hw/usb/hcd-ehci.c | 3 ---
 1 file changed, 3 deletions(-)
hw/usb/hcd-ehci.c +0 -3
index 56ab2f457f..29d49c2d7e 100644
@@ -1301,7 +1301,6 @@ static void ehci_execute_complete(EHCIQueue *q)
         /* should not be triggerable */
         fprintf(stderr, "USB invalid response %d\n", p->packet.status);
         g_assert_not_reached();
-        break;
     }
 
     /* TODO check 4.12 for splits */
@@ -2105,9 +2104,7 @@ static void ehci_advance_state(EHCIState *ehci, int async)
 
         default:
             fprintf(stderr, "Bad state!\n");
-            again = -1;
             g_assert_not_reached();
-            break;
         }
 
         if (again < 0 || itd_count > 16) {
Signature · 1 line
2.23.0
Reviewed-by on v1 12/13
#18 lore raw

Re: [PATCH 12/13] usb/hcd-ehci: Remove redundant statements

Quoted 33 lines · On 2/25/20 3:09 AM, [email protected] wrote:

From: Chen Qun <[email protected]>

The "again" assignment is meaningless before g_assert_not_reached. In addition, the break statements no longer needs to be after g_assert_not_reached.

Clang static code analyzer show warning:
hw/usb/hcd-ehci.c:2108:13: warning: Value stored to 'again' is never read

             again = -1;
             ^       ~~

---
Cc: Gerd Hoffmann <[email protected]>

---
  hw/usb/hcd-ehci.c | 3 ---
  1 file changed, 3 deletions(-)
hw/usb/hcd-ehci.c +0 -1
index 56ab2f457f..29d49c2d7e 100644
@@ -1301,7 +1301,6 @@ static void ehci_execute_complete(EHCIQueue *q)
          /* should not be triggerable */
          fprintf(stderr, "USB invalid response %d\n", p->packet.status);
          g_assert_not_reached();
-        break;
      }
 
      /* TODO check 4.12 for splits */

hw/usb/hcd-ehci.c static void ehci_advance_state(EHCIState *ehci, int async) · line 2110

Quoted 9 lines
hw/usb/hcd-ehci.c +0 -2
@@ -2105,9 +2104,7 @@ static void ehci_advance_state(EHCIState *ehci, int async)
 
          default:
              fprintf(stderr, "Bad state!\n");
-            again = -1;
              g_assert_not_reached();
-            break;
          }
 
          if (again < 0 || itd_count > 16) {
#19 lore raw

PATCH 13/13 monitor/hmp-cmds: Remove redundant statement in hmp_rocker_of_dpa_groups()

In reply to [email protected]

From: Chen Qun <[email protected]>

Clang static code analyzer show warning:
monitor/hmp-cmds.c:2867:17: warning: Value stored to 'set' is never read

                set = true;
                ^     ~~~~

---
Cc: "Dr. David Alan Gilbert" <[email protected]>

---
 monitor/hmp-cmds.c | 1 -
 1 file changed, 1 deletion(-)
monitor/hmp-cmds.c +0 -1
index 53bc3f76c4..84f94647cd 100644
@@ -2864,7 +2864,6 @@ void hmp_rocker_of_dpa_groups(Monitor *mon, const QDict *qdict)
 
         if (group->has_set_eth_dst) {
             if (!set) {
-                set = true;
                 monitor_printf(mon, " set");
             }
             monitor_printf(mon, " dst %s", group->set_eth_dst);
Signature · 1 line
2.23.0
#20 lore raw

Re: [PATCH 13/13] monitor/hmp-cmds: Remove redundant statement in hmp_rocker_of_dpa_groups()

Quoted 21 lines · On 2/25/20 3:09 AM, [email protected] wrote:

From: Chen Qun <[email protected]>

Clang static code analyzer show warning:
monitor/hmp-cmds.c:2867:17: warning: Value stored to 'set' is never read

                 set = true;
                 ^     ~~~~

---
Cc: "Dr. David Alan Gilbert" <[email protected]>

---
  monitor/hmp-cmds.c | 1 -
  1 file changed, 1 deletion(-)
monitor/hmp-cmds.c +0 -0
index 53bc3f76c4..84f94647cd 100644

monitor/hmp-cmds.c void hmp_rocker_of_dpa_groups(Monitor *mon, const QDict *qdict) · line 2869

Quoted 7 lines
monitor/hmp-cmds.c +0 -1
@@ -2864,7 +2864,6 @@ void hmp_rocker_of_dpa_groups(Monitor *mon, const QDict *qdict)
 
          if (group->has_set_eth_dst) {
              if (!set) {
-                set = true;
                  monitor_printf(mon, " set");
              }
              monitor_printf(mon, " dst %s", group->set_eth_dst);

Can you move the 'set' declaration to the for() statement and also remove the last "set = false;"?

#21 lore raw

RE: [PATCH 13/13] monitor/hmp-cmds: Remove redundant statement in hmp_rocker_of_dpa_groups()

Quoted 34 lines

-----Original Message-----
From: Philippe Mathieu-Daudé [mailto:[email protected]]
Sent: Tuesday, February 25, 2020 5:45 PM
To: Chenqun (kuhn) <[email protected]>; qemu- [email protected]; [email protected]
Cc: [email protected]; Zhanghailiang <[email protected]>; Dr. David Alan Gilbert <[email protected]>
Subject: Re: [PATCH 13/13] monitor/hmp-cmds: Remove redundant statement in hmp_rocker_of_dpa_groups()

Quoted 22 lines · On 2/25/20 3:09 AM, [email protected] wrote:

From: Chen Qun <[email protected]>

Clang static code analyzer show warning:
monitor/hmp-cmds.c:2867:17: warning: Value stored to 'set' is never read

                 set = true;
                 ^     ~~~~

---
Cc: "Dr. David Alan Gilbert" <[email protected]>

---
  monitor/hmp-cmds.c | 1 -
  1 file changed, 1 deletion(-)
monitor/hmp-cmds.c index renamed from monitor/hmp-cmds.c +0 -0

53bc3f76c4..84f94647cd 100644

monitor/hmp-cmds.c +0 -0
@@ -2864,7 +2864,6 @@ void hmp_rocker_of_dpa_groups(Monitor *mon,
 const QDict *qdict)
 
Quoted 10 lines
Quoted 7 lines
monitor/hmp-cmds.c +0 -1
          if (group->has_set_eth_dst) {
              if (!set) {
-                set = true;
                  monitor_printf(mon, " set");
              }
              monitor_printf(mon, " dst %s", group->set_eth_dst);

Can you move the 'set' declaration to the for() statement and also remove the last "set = false;"?

Yes, you are right! It will be better! I will modify it later in V2.

Thanks.