[PATCH v2 13/13] monitor/hmp-cmds: Remove redundant statement in hmp_rocker_of_dpa_groups()
From: Chen Qun Clang static code analyzer show warning: monitor/hmp-cmds.c:2867:17: warning: Value stored to 'set' is never read set = true; ^ Reported-by: Euler Robot Signed-off-by: Chen Qun --- Cc: "Dr. David Alan Gilbert" Cc: Philippe Mathieu-Daudé v1->v2: move the 'set' declaration to the for() statement(Base on Philippe's suggestion). --- monitor/hmp-cmds.c | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 53bc3f76c4..c6b0495822 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -2808,7 +2808,6 @@ void hmp_rocker_of_dpa_groups(Monitor *mon, const QDict *qdict) const char *name = qdict_get_str(qdict, "name"); uint8_t type = qdict_get_try_int(qdict, "type", 9); Error *err = NULL; -bool set = false; list = qmp_query_rocker_of_dpa_groups(name, type != 9, type, &err); if (err != NULL) { @@ -2820,6 +2819,7 @@ void hmp_rocker_of_dpa_groups(Monitor *mon, const QDict *qdict) for (g = list; g; g = g->next) { RockerOfDpaGroup *group = g->value; +bool set = false; monitor_printf(mon, "0x%08x", group->id); @@ -2864,14 +2864,11 @@ 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); } -set = false; - if (group->has_ttl_check && group->ttl_check) { monitor_printf(mon, " check TTL"); } -- 2.23.0
[PATCH v2 12/13] usb/hcd-ehci: Remove redundant statements
From: Chen Qun 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; ^ ~~ Reported-by: Euler Robot Signed-off-by: Chen Qun Reviewed-by: Philippe Mathieu-Daudé --- Cc: Gerd Hoffmann Cc: Philippe Mathieu-Daudé --- hw/usb/hcd-ehci.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c index 56ab2f457f..29d49c2d7e 100644 --- a/hw/usb/hcd-ehci.c +++ b/hw/usb/hcd-ehci.c @@ -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) { -- 2.23.0
[PATCH v2 11/13] timer/exynos4210_mct: Remove redundant statement in exynos4210_mct_write()
From: Chen Qun 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); ^ ~ Reported-by: Euler Robot Signed-off-by: Chen Qun --- Cc: Igor Mitsyanko Cc: Peter Maydell --- hw/timer/exynos4210_mct.c | 4 1 file changed, 4 deletions(-) diff --git a/hw/timer/exynos4210_mct.c b/hw/timer/exynos4210_mct.c index 944120aea5..570cf7075b 100644 --- a/hw/timer/exynos4210_mct.c +++ b/hw/timer/exynos4210_mct.c @@ -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; -- 2.23.0
[PATCH v2 04/13] scsi/esp-pci: Remove redundant statement in esp_pci_io_write()
From: Chen Qun Clang static code analyzer show warning: hw/scsi/esp-pci.c:198:9: warning: Value stored to 'size' is never read size = 4; ^ ~ Reported-by: Euler Robot Signed-off-by: Chen Qun --- Cc: Paolo Bonzini Cc:Fam Zheng --- hw/scsi/esp-pci.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/scsi/esp-pci.c b/hw/scsi/esp-pci.c index d5a1f9e017..2e6cc07d4e 100644 --- a/hw/scsi/esp-pci.c +++ b/hw/scsi/esp-pci.c @@ -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) { -- 2.23.0
[PATCH v2 05/13] scsi/scsi-disk: Remove redundant statement in scsi_disk_emulate_command()
From: Chen Qun Clang static code analyzer show warning: scsi/scsi-disk.c:1918:5: warning: Value stored to 'buflen' is never read buflen = req->cmd.xfer; ^~ Reported-by: Euler Robot Signed-off-by: Chen Qun --- Cc: Paolo Bonzini Cc: Fam Zheng --- hw/scsi/scsi-disk.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index 10d0794d60..1c0cb63a6f 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -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]) { -- 2.23.0
[PATCH v2 09/13] dma/xlnx-zdma: Remove redundant statement in zdma_write_dst()
From: Chen Qun 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, ^ ~~~ Reported-by: Euler Robot Signed-off-by: Chen Qun --- Cc: Alistair Francis Cc: "Edgar E. Iglesias" Cc: Peter Maydell Cc: Philippe Mathieu-Daudé v1->v2: move the 'dst_type' declaration.(Base on Philippe's suggestion). --- hw/dma/xlnx-zdma.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/dma/xlnx-zdma.c b/hw/dma/xlnx-zdma.c index 8fb83f5b07..eeacad59ce 100644 --- a/hw/dma/xlnx-zdma.c +++ b/hw/dma/xlnx-zdma.c @@ -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 = 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); } /* Match what hardware does by ignoring the dst_size and only using -- 2.23.0
[PATCH v2 06/13] display/pxa2xx_lcd: Remove redundant statement in pxa2xx_palette_parse()
From: Chen Qun Clang static code analyzer show warning: hw/display/pxa2xx_lcd.c:596:9: warning: Value stored to 'format' is never read format = 0; ^~ Reported-by: Euler Robot Signed-off-by: Chen Qun --- Cc: Andrzej Zaborowski Cc: Peter Maydell --- hw/display/pxa2xx_lcd.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/display/pxa2xx_lcd.c b/hw/display/pxa2xx_lcd.c index 05f5f84671..464e93161a 100644 --- a/hw/display/pxa2xx_lcd.c +++ b/hw/display/pxa2xx_lcd.c @@ -593,7 +593,6 @@ static void pxa2xx_palette_parse(PXA2xxLCDState *s, int ch, int bpp) n = 256; break; default: -format = 0; return; } -- 2.23.0
[PATCH v2 10/13] migration/vmstate: Remove redundant statement in vmstate_save_state_v()
From: Chen Qun 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; ^ ~ Reported-by: Euler Robot Signed-off-by: Chen Qun --- Cc: Juan Quintela Cc: "Dr. David Alan Gilbert" --- migration/vmstate.c | 1 - 1 file changed, 1 deletion(-) diff --git a/migration/vmstate.c b/migration/vmstate.c index 7dd8ef66c6..bafa890384 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -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); -- 2.23.0
[PATCH v2 08/13] display/blizzard: Remove redundant statement in blizzard_draw_line16_32()
From: Chen Qun Clang static code analyzer show warning: hw/display/blizzard.c:940:9: warning: Value stored to 'data' is never read data >>= 5; ^~ Reported-by: Euler Robot Signed-off-by: Chen Qun --- Cc: Andrzej Zaborowski Cc: Peter Maydell --- hw/display/blizzard.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/display/blizzard.c b/hw/display/blizzard.c index 359e399c2a..62517bdf75 100644 --- a/hw/display/blizzard.c +++ b/hw/display/blizzard.c @@ -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); } } -- 2.23.0
[PATCH v2 03/13] block/file-posix: Remove redundant statement in raw_handle_perm_lock()
From: Chen Qun Clang static code analyzer show warning: block/file-posix.c:891:9: warning: Value stored to 'op' is never read op = RAW_PL_ABORT; ^ Reported-by: Euler Robot Signed-off-by: Chen Qun --- Cc: Kevin Wolf Cc: Max Reitz --- block/file-posix.c | 1 - 1 file changed, 1 deletion(-) diff --git a/block/file-posix.c b/block/file-posix.c index 6345477112..0f77447a25 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -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, -- 2.23.0
[PATCH v2 00/13] redundant code: Fix warnings reported by Clang static code analyzer
From: Chen Qun Since v1: - Patch1: Addressed John Snow review comment. - Patch12:Addressed Philippe Mathieu-Daudé review comment. - Patch9: Move the 'dst_type' declaration to while() statement. - Patch13: Move the 'set' declaration to the for() statement. 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 | 10 +- 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 | 5 + 13 files changed, 6 insertions(+), 25 deletions(-) -- 2.23.0
[PATCH v2 07/13] display/exynos4210_fimd: Remove redundant statement in exynos4210_fimd_update()
From: Chen Qun 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; Reported-by: Euler Robot Signed-off-by: Chen Qun --- Cc: Igor Mitsyanko Cc: Peter Maydell --- hw/display/exynos4210_fimd.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/display/exynos4210_fimd.c b/hw/display/exynos4210_fimd.c index c1071ecd46..05d3265b76 100644 --- a/hw/display/exynos4210_fimd.c +++ b/hw/display/exynos4210_fimd.c @@ -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; -- 2.23.0
[PATCH v2 01/13] block/stream: Remove redundant statement in stream_run()
From: Chen Qun Clang static code analyzer show warning: block/stream.c:186:9: warning: Value stored to 'ret' is never read ret = 0; ^ ~ Reported-by: Euler Robot Signed-off-by: Chen Qun Reviewed-by: John Snow --- Cc: John Snow Cc: Kevin Wolf Cc: Max Reitz --- block/stream.c | 1 - 1 file changed, 1 deletion(-) diff --git a/block/stream.c b/block/stream.c index 5562ccbf57..d78074ac80 100644 --- a/block/stream.c +++ b/block/stream.c @@ -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); -- 2.23.0
[PATCH v2 02/13] block/iscsi:Remove redundant statement in iscsi_open()
From: Chen Qun Clang static code analyzer show warning: block/iscsi.c:1920:9: warning: Value stored to 'flags' is never read flags &= ~BDRV_O_RDWR; ^ Reported-by: Euler Robot Signed-off-by: Chen Qun --- Cc: Ronnie Sahlberg Cc: Paolo Bonzini Cc: Peter Lieven Cc: Kevin Wolf Cc: Max Reitz --- block/iscsi.c | 1 - 1 file changed, 1 deletion(-) diff --git a/block/iscsi.c b/block/iscsi.c index 682abd8e09..ed88479ede 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -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); -- 2.23.0
[PATCH 11/13] timer/exynos4210_mct: Remove redundant statement in exynos4210_mct_write()
From: Chen Qun 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); ^ ~ Reported-by: Euler Robot Signed-off-by: Chen Qun --- Cc: Igor Mitsyanko Cc: Peter Maydell Cc: qemu-...@nongnu.org --- hw/timer/exynos4210_mct.c | 4 1 file changed, 4 deletions(-) diff --git a/hw/timer/exynos4210_mct.c b/hw/timer/exynos4210_mct.c index 944120aea5..570cf7075b 100644 --- a/hw/timer/exynos4210_mct.c +++ b/hw/timer/exynos4210_mct.c @@ -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; -- 2.23.0
[PATCH 02/13] block/iscsi:Remove redundant statement in iscsi_open()
From: Chen Qun Clang static code analyzer show warning: block/iscsi.c:1920:9: warning: Value stored to 'flags' is never read flags &= ~BDRV_O_RDWR; ^ Reported-by: Euler Robot Signed-off-by: Chen Qun --- Cc: Ronnie Sahlberg Cc: Paolo Bonzini Cc: Peter Lieven Cc: Kevin Wolf Cc: Max Reitz Cc: qemu-bl...@nongnu.org --- block/iscsi.c | 1 - 1 file changed, 1 deletion(-) diff --git a/block/iscsi.c b/block/iscsi.c index 682abd8e09..ed88479ede 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -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); -- 2.23.0
[PATCH 05/13] scsi/scsi-disk: Remove redundant statement in scsi_disk_emulate_command()
From: Chen Qun Clang static code analyzer show warning: scsi/scsi-disk.c:1918:5: warning: Value stored to 'buflen' is never read buflen = req->cmd.xfer; ^~ Reported-by: Euler Robot Signed-off-by: Chen Qun --- Cc: Paolo Bonzini Cc: Fam Zheng --- hw/scsi/scsi-disk.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index 10d0794d60..1c0cb63a6f 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -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]) { -- 2.23.0
[PATCH 01/13] block/stream: Remove redundant statement in stream_run()
From: Chen Qun Clang static code analyzer show warning: block/stream.c:186:9: warning: Value stored to 'ret' is never read ret = 0; ^ ~ Reported-by: Euler Robot Signed-off-by: Chen Qun --- Cc: John Snow Cc: Kevin Wolf Cc: Max Reitz Cc: qemu-bl...@nongnu.org --- block/stream.c | 1 - 1 file changed, 1 deletion(-) diff --git a/block/stream.c b/block/stream.c index 5562ccbf57..d78074ac80 100644 --- a/block/stream.c +++ b/block/stream.c @@ -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); -- 2.23.0
[PATCH 09/13] dma/xlnx-zdma: Remove redundant statement in zdma_write_dst()
From: Chen Qun 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, ^ ~~~ Reported-by: Euler Robot Signed-off-by: Chen Qun --- Cc: Alistair Francis Cc: "Edgar E. Iglesias" Cc: Peter Maydell Cc: qemu-...@nongnu.org --- hw/dma/xlnx-zdma.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/hw/dma/xlnx-zdma.c b/hw/dma/xlnx-zdma.c index 8fb83f5b07..45355c5d59 100644 --- a/hw/dma/xlnx-zdma.c +++ b/hw/dma/xlnx-zdma.c @@ -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 -- 2.23.0
[PATCH 08/13] display/blizzard: Remove redundant statement in blizzard_draw_line16_32()
From: Chen Qun Clang static code analyzer show warning: hw/display/blizzard.c:940:9: warning: Value stored to 'data' is never read data >>= 5; ^~ Reported-by: Euler Robot Signed-off-by: Chen Qun --- Cc: Andrzej Zaborowski Cc: Peter Maydell Cc: qemu-...@nongnu.org --- hw/display/blizzard.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/display/blizzard.c b/hw/display/blizzard.c index 359e399c2a..62517bdf75 100644 --- a/hw/display/blizzard.c +++ b/hw/display/blizzard.c @@ -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); } } -- 2.23.0
[PATCH 13/13] monitor/hmp-cmds: Remove redundant statement in hmp_rocker_of_dpa_groups()
From: Chen Qun Clang static code analyzer show warning: monitor/hmp-cmds.c:2867:17: warning: Value stored to 'set' is never read set = true; ^ Reported-by: Euler Robot Signed-off-by: Chen Qun --- Cc: "Dr. David Alan Gilbert" --- monitor/hmp-cmds.c | 1 - 1 file changed, 1 deletion(-) diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 53bc3f76c4..84f94647cd 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -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); -- 2.23.0
[PATCH 06/13] display/pxa2xx_lcd: Remove redundant statement in pxa2xx_palette_parse()
From: Chen Qun Clang static code analyzer show warning: hw/display/pxa2xx_lcd.c:596:9: warning: Value stored to 'format' is never read format = 0; ^~ Reported-by: Euler Robot Signed-off-by: Chen Qun --- Cc: Andrzej Zaborowski Cc: Peter Maydell Cc: qemu-...@nongnu.org --- hw/display/pxa2xx_lcd.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/display/pxa2xx_lcd.c b/hw/display/pxa2xx_lcd.c index 05f5f84671..464e93161a 100644 --- a/hw/display/pxa2xx_lcd.c +++ b/hw/display/pxa2xx_lcd.c @@ -593,7 +593,6 @@ static void pxa2xx_palette_parse(PXA2xxLCDState *s, int ch, int bpp) n = 256; break; default: -format = 0; return; } -- 2.23.0
[PATCH 12/13] usb/hcd-ehci: Remove redundant statements
From: Chen Qun 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; ^ ~~ Reported-by: Euler Robot Signed-off-by: Chen Qun --- Cc: Gerd Hoffmann --- hw/usb/hcd-ehci.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c index 56ab2f457f..29d49c2d7e 100644 --- a/hw/usb/hcd-ehci.c +++ b/hw/usb/hcd-ehci.c @@ -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) { -- 2.23.0
[PATCH 07/13] display/exynos4210_fimd: Remove redundant statement in exynos4210_fimd_update()
From: Chen Qun 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; Reported-by: Euler Robot Signed-off-by: Chen Qun --- Cc: Igor Mitsyanko Cc: Peter Maydell Cc: qemu-...@nongnu.org --- hw/display/exynos4210_fimd.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/display/exynos4210_fimd.c b/hw/display/exynos4210_fimd.c index c1071ecd46..05d3265b76 100644 --- a/hw/display/exynos4210_fimd.c +++ b/hw/display/exynos4210_fimd.c @@ -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; -- 2.23.0
[PATCH 10/13] migration/vmstate: Remove redundant statement in vmstate_save_state_v()
From: Chen Qun 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; ^ ~ Reported-by: Euler Robot Signed-off-by: Chen Qun --- Cc: Juan Quintela Cc: "Dr. David Alan Gilbert" --- migration/vmstate.c | 1 - 1 file changed, 1 deletion(-) diff --git a/migration/vmstate.c b/migration/vmstate.c index 7dd8ef66c6..bafa890384 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -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); -- 2.23.0
[PATCH 03/13] block/file-posix: Remove redundant statement in raw_handle_perm_lock()
From: Chen Qun Clang static code analyzer show warning: block/file-posix.c:891:9: warning: Value stored to 'op' is never read op = RAW_PL_ABORT; ^ Reported-by: Euler Robot Signed-off-by: Chen Qun --- Cc: Kevin Wolf Cc: Max Reitz Cc: qemu-bl...@nongnu.org --- block/file-posix.c | 1 - 1 file changed, 1 deletion(-) diff --git a/block/file-posix.c b/block/file-posix.c index 6345477112..0f77447a25 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -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, -- 2.23.0
[PATCH 04/13] scsi/esp-pci: Remove redundant statement in esp_pci_io_write()
From: Chen Qun Clang static code analyzer show warning: hw/scsi/esp-pci.c:198:9: warning: Value stored to 'size' is never read size = 4; ^ ~ Reported-by: Euler Robot Signed-off-by: Chen Qun --- Cc: Paolo Bonzini Cc: Fam Zheng --- hw/scsi/esp-pci.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/scsi/esp-pci.c b/hw/scsi/esp-pci.c index d5a1f9e017..2e6cc07d4e 100644 --- a/hw/scsi/esp-pci.c +++ b/hw/scsi/esp-pci.c @@ -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) { -- 2.23.0
[PATCH 00/13]redundant code: Fix warnings reported by Clang static code analyzer
From: Chen Qun 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(-) -- 2.23.0
[PATCH v2] test-vmstate: Fix memleaks in test_load_qlist
From: Chen Qun There is memleak in test_load_qlist().It's not a big deal, but test-vmstate will fail if sanitizers is enabled. In addition, "ret" is written twice with the same value in test_gtree_load_iommu(). Reported-by: Euler Robot Signed-off-by: Chen Qun --- tests/test-vmstate.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c index cea363dd69..f7b3868881 100644 --- a/tests/test-vmstate.c +++ b/tests/test-vmstate.c @@ -1241,7 +1241,6 @@ static void test_gtree_load_iommu(void) TestGTreeIOMMU *orig_iommu = create_iommu(); QEMUFile *fsave, *fload; char eof; -int ret; fsave = open_test_file(true); qemu_put_buffer(fsave, iommu_dump, sizeof(iommu_dump)); @@ -1250,10 +1249,8 @@ static void test_gtree_load_iommu(void) fload = open_test_file(false); vmstate_load_state(fload, &vmstate_iommu, dest_iommu, 1); -ret = qemu_file_get_error(fload); eof = qemu_get_byte(fload); -ret = qemu_file_get_error(fload); -g_assert(!ret); +g_assert(!qemu_file_get_error(fload)); g_assert_cmpint(orig_iommu->id, ==, dest_iommu->id); g_assert_cmpint(eof, ==, QEMU_VM_EOF); @@ -1395,6 +1392,7 @@ static void test_load_qlist(void) compare_containers(orig_container, dest_container); free_container(orig_container); free_container(dest_container); +qemu_fclose(fload); } typedef struct TmpTestStruct { -- 2.23.0
[PATCH 3/3] hw/xtensa/xtfpga:fix leak of fdevice tree blob
From: Chen Qun The device tree blob returned by load_device_tree is malloced. We should free it after cpu_physical_memory_write(). Reported-by: Euler Robot Signed-off-by: Chen Qun --- hw/xtensa/xtfpga.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c index 8e2dd1327a..60ccc74f5f 100644 --- a/hw/xtensa/xtfpga.c +++ b/hw/xtensa/xtfpga.c @@ -380,6 +380,7 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine) cur_tagptr = put_tag(cur_tagptr, BP_TAG_FDT, sizeof(dtb_addr), &dtb_addr); cur_lowmem = QEMU_ALIGN_UP(cur_lowmem + fdt_size, 4 * KiB); +g_free(fdt); } #else if (dtb_filename) { -- 2.23.0
[PATCH 1/3] hw/nios2:fix leak of fdevice tree blob
From: Chen Qun The device tree blob returned by load_device_tree is malloced. We should free it after cpu_physical_memory_write(). Reported-by: Euler Robot Signed-off-by: Chen Qun --- hw/nios2/boot.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/nios2/boot.c b/hw/nios2/boot.c index 46b8349876..88224aa84c 100644 --- a/hw/nios2/boot.c +++ b/hw/nios2/boot.c @@ -109,6 +109,7 @@ static int nios2_load_dtb(struct nios2_boot_info bi, const uint32_t ramsize, } cpu_physical_memory_write(bi.fdt, fdt, fdt_size); +g_free(fdt); return fdt_size; } -- 2.23.0
[PATCH 2/3] hw/ppc/virtex_ml507:fix leak of fdevice tree blob
From: Chen Qun The device tree blob returned by load_device_tree is malloced. We should free it after cpu_physical_memory_write(). Reported-by: Euler Robot Signed-off-by: Chen Qun --- hw/ppc/virtex_ml507.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c index 91dd00ee91..4eef70069f 100644 --- a/hw/ppc/virtex_ml507.c +++ b/hw/ppc/virtex_ml507.c @@ -188,6 +188,7 @@ static int xilinx_load_device_tree(hwaddr addr, if (r < 0) fprintf(stderr, "couldn't set /chosen/bootargs\n"); cpu_physical_memory_write(addr, fdt, fdt_size); +g_free(fdt); return fdt_size; } -- 2.23.0
[PATCH 0/3]hw: Fixs memleak of fdevice tree blob
From: Chen Qun The device tree blob returned by load_device_tree is malloced. We should free it after cpu_physical_memory_write().Otherwise, if we repeatedly call 'system_reset',it will repeatedly load fdt, so there are many memleaks. Paolo Bonzini : https://lists.gnu.org/archive/html/qemu-devel/2019-10/msg00129.html Pan Nengyuan: https://lists.gnu.org/archive/html/qemu-devel/2020-02/msg03594.html After searching the device code, I found three similar issues. This series fixes the last three. Chen Qun (3): hw/nios2:fix leak of fdevice tree blob hw/ppc/virtex_ml507:fix leak of fdevice tree blob hw/xtensa/xtfpga:fix leak of fdevice tree blob hw/nios2/boot.c | 1 + hw/ppc/virtex_ml507.c | 1 + hw/xtensa/xtfpga.c| 1 + 3 files changed, 3 insertions(+) -- 2.23.0
[PATCH] test-vmstate: Fix memleaks in test_load_qlist
From: Chen Qun We may forget to free fload. ASAN spotted it. Reported-by: Euler Robot Signed-off-by: Chen Qun --- tests/test-vmstate.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c index cea363dd69..5b2743121b 100644 --- a/tests/test-vmstate.c +++ b/tests/test-vmstate.c @@ -1395,6 +1395,7 @@ static void test_load_qlist(void) compare_containers(orig_container, dest_container); free_container(orig_container); free_container(dest_container); +qemu_fclose(fload); } typedef struct TmpTestStruct { -- 2.23.0
[PATCH v2] hw/char/exynos4210_uart: Fix memleaks in exynos4210_uart_init
From: Chen Qun It's easy to reproduce as follow: virsh qemu-monitor-command vm1 --pretty '{"execute": "device-list-properties", "arguments":{"typename":"exynos4210.uart"}}' ASAN shows memory leak stack: #1 0xfffd896d71cb in g_malloc0 (/lib64/libglib-2.0.so.0+0x571cb) #2 0xaaad270beee3 in timer_new_full /qemu/include/qemu/timer.h:530 #3 0xaaad270beee3 in timer_new /qemu/include/qemu/timer.h:551 #4 0xaaad270beee3 in timer_new_ns /qemu/include/qemu/timer.h:569 #5 0xaaad270beee3 in exynos4210_uart_init /qemu/hw/char/exynos4210_uart.c:677 #6 0xaaad275c8f4f in object_initialize_with_type /qemu/qom/object.c:516 #7 0xaaad275c91bb in object_new_with_type /qemu/qom/object.c:684 #8 0xaaad2755df2f in qmp_device_list_properties /qemu/qom/qom-qmp-cmds.c:152 Reported-by: Euler Robot Signed-off-by: Chen Qun --- Changes V2 to V1: -Keep s->wordtime in exynos4210_uart_init (Base on Eduardo and Philippe's comments). --- hw/char/exynos4210_uart.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/char/exynos4210_uart.c b/hw/char/exynos4210_uart.c index 25d6588e41..96d5180e3e 100644 --- a/hw/char/exynos4210_uart.c +++ b/hw/char/exynos4210_uart.c @@ -674,8 +674,6 @@ static void exynos4210_uart_init(Object *obj) SysBusDevice *dev = SYS_BUS_DEVICE(obj); Exynos4210UartState *s = EXYNOS4210_UART(dev); -s->fifo_timeout_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, - exynos4210_uart_timeout_int, s); s->wordtime = NANOSECONDS_PER_SECOND * 10 / 9600; /* memory mapping */ @@ -691,6 +689,9 @@ static void exynos4210_uart_realize(DeviceState *dev, Error **errp) { Exynos4210UartState *s = EXYNOS4210_UART(dev); +s->fifo_timeout_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, + exynos4210_uart_timeout_int, s); + qemu_chr_fe_set_handlers(&s->chr, exynos4210_uart_can_receive, exynos4210_uart_receive, exynos4210_uart_event, NULL, s, NULL, true); -- 2.23.0
[PATCH] hw/char/exynos4210_uart: Fix memleaks in exynos4210_uart_init
From: Chen Qun It's easy to reproduce as follow: virsh qemu-monitor-command vm1 --pretty '{"execute": "device-list-properties", "arguments":{"typename":"exynos4210.uart"}}' ASAN shows memory leak stack: #1 0xfffd896d71cb in g_malloc0 (/lib64/libglib-2.0.so.0+0x571cb) #2 0xaaad270beee3 in timer_new_full /qemu/include/qemu/timer.h:530 #3 0xaaad270beee3 in timer_new /qemu/include/qemu/timer.h:551 #4 0xaaad270beee3 in timer_new_ns /qemu/include/qemu/timer.h:569 #5 0xaaad270beee3 in exynos4210_uart_init /qemu/hw/char/exynos4210_uart.c:677 #6 0xaaad275c8f4f in object_initialize_with_type /qemu/qom/object.c:516 #7 0xaaad275c91bb in object_new_with_type /qemu/qom/object.c:684 #8 0xaaad2755df2f in qmp_device_list_properties /qemu/qom/qom-qmp-cmds.c:152 Reported-by: Euler Robot Signed-off-by: Chen Qun --- hw/char/exynos4210_uart.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/char/exynos4210_uart.c b/hw/char/exynos4210_uart.c index 25d6588e41..5048db5410 100644 --- a/hw/char/exynos4210_uart.c +++ b/hw/char/exynos4210_uart.c @@ -674,10 +674,6 @@ static void exynos4210_uart_init(Object *obj) SysBusDevice *dev = SYS_BUS_DEVICE(obj); Exynos4210UartState *s = EXYNOS4210_UART(dev); -s->fifo_timeout_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, - exynos4210_uart_timeout_int, s); -s->wordtime = NANOSECONDS_PER_SECOND * 10 / 9600; - /* memory mapping */ memory_region_init_io(&s->iomem, obj, &exynos4210_uart_ops, s, "exynos4210.uart", EXYNOS4210_UART_REGS_MEM_SIZE); @@ -691,6 +687,10 @@ static void exynos4210_uart_realize(DeviceState *dev, Error **errp) { Exynos4210UartState *s = EXYNOS4210_UART(dev); +s->fifo_timeout_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, + exynos4210_uart_timeout_int, s); +s->wordtime = NANOSECONDS_PER_SECOND * 10 / 9600; + qemu_chr_fe_set_handlers(&s->chr, exynos4210_uart_can_receive, exynos4210_uart_receive, exynos4210_uart_event, NULL, s, NULL, true); -- 2.23.0
[PATCH] contrib/elf2dmp: prevent uninitialized warning
From: Chen Qun Fix compilation warnings: contrib/elf2dmp/main.c:66:17: warning: ‘KdpDataBlockEncoded’ may be used uninitialized in this function [-Wmaybe-uninitialized] block = __builtin_bswap64(block ^ kdbe) ^ kwa; ^~~ contrib/elf2dmp/main.c:78:24: note: ‘KdpDataBlockEncoded’ was declared here uint64_t kwn, kwa, KdpDataBlockEncoded; ^~~ Reported-by: Euler Robot Signed-off-by: Chen Qun --- contrib/elf2dmp/main.c | 25 - 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/contrib/elf2dmp/main.c b/contrib/elf2dmp/main.c index 9a2dbc2902..203b9e6d04 100644 --- a/contrib/elf2dmp/main.c +++ b/contrib/elf2dmp/main.c @@ -76,6 +76,7 @@ static KDDEBUGGER_DATA64 *get_kdbg(uint64_t KernBase, struct pdb_reader *pdb, DBGKD_DEBUG_DATA_HEADER64 kdbg_hdr; bool decode = false; uint64_t kwn, kwa, KdpDataBlockEncoded; +uint64_t KiWaitNever, KiWaitAlways; if (va_space_rw(vs, KdDebuggerDataBlock + offsetof(KDDEBUGGER_DATA64, Header), @@ -84,21 +85,19 @@ static KDDEBUGGER_DATA64 *get_kdbg(uint64_t KernBase, struct pdb_reader *pdb, return NULL; } -if (memcmp(&kdbg_hdr.OwnerTag, OwnerTag, sizeof(OwnerTag))) { -uint64_t KiWaitNever, KiWaitAlways; - -decode = true; +if (!SYM_RESOLVE(KernBase, pdb, KiWaitNever) || +!SYM_RESOLVE(KernBase, pdb, KiWaitAlways) || +!SYM_RESOLVE(KernBase, pdb, KdpDataBlockEncoded)) { +return NULL; +} -if (!SYM_RESOLVE(KernBase, pdb, KiWaitNever) || -!SYM_RESOLVE(KernBase, pdb, KiWaitAlways) || -!SYM_RESOLVE(KernBase, pdb, KdpDataBlockEncoded)) { -return NULL; -} +if (va_space_rw(vs, KiWaitNever, &kwn, sizeof(kwn), 0) || +va_space_rw(vs, KiWaitAlways, &kwa, sizeof(kwa), 0)) { +return NULL; +} -if (va_space_rw(vs, KiWaitNever, &kwn, sizeof(kwn), 0) || -va_space_rw(vs, KiWaitAlways, &kwa, sizeof(kwa), 0)) { -return NULL; -} +if (memcmp(&kdbg_hdr.OwnerTag, OwnerTag, sizeof(OwnerTag))) { +decode = true; printf("[KiWaitNever] = 0x%016"PRIx64"\n", kwn); printf("[KiWaitAlways] = 0x%016"PRIx64"\n", kwa); -- 2.23.0
[PATCH] tests/plugin: prevent uninitialized warning
From: Chen Qun According to the glibc function requirements, we need initialise the variable. Otherwise there will be compilation warnings: glib-autocleanups.h:28:3: warning: ‘out’ may be used uninitialized in this function [-Wmaybe-uninitialized] g_free (*pp); ^~~~ Reported-by: Euler Robot Signed-off-by: Chen Qun --- tests/plugin/bb.c | 2 +- tests/plugin/insn.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/plugin/bb.c b/tests/plugin/bb.c index f30bea08dc..8b9da23a04 100644 --- a/tests/plugin/bb.c +++ b/tests/plugin/bb.c @@ -22,7 +22,7 @@ static bool do_inline; static void plugin_exit(qemu_plugin_id_t id, void *p) { -g_autofree gchar *out; +g_autofree gchar *out = NULL; out = g_strdup_printf("bb's: %" PRIu64", insns: %" PRIu64 "\n", bb_count, insn_count); qemu_plugin_outs(out); diff --git a/tests/plugin/insn.c b/tests/plugin/insn.c index 0a8f5a..c83b1c0157 100644 --- a/tests/plugin/insn.c +++ b/tests/plugin/insn.c @@ -44,7 +44,7 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) static void plugin_exit(qemu_plugin_id_t id, void *p) { -g_autofree gchar *out; +g_autofree gchar *out = NULL; out = g_strdup_printf("insns: %" PRIu64 "\n", insn_count); qemu_plugin_outs(out); } -- 2.23.0
[PATCH] aspeed/i2c:fix uninitialized variable warning
From: Chen Qun Fix warning: hw/i2c/aspeed_i2c.c: In function ‘aspeed_i2c_bus_write’: glib/glib-autocleanups.h:28:3: warning: ‘cmd_flags’ may be used uninitialized in this function [-Wmaybe-uninitialized] g_free (*pp); ^~~~ hw/i2c/aspeed_i2c.c:403:22: note: ‘cmd_flags’ was declared here g_autofree char *cmd_flags; ^ Reported-by: Euler Robot Signed-off-by: Chen Qun --- hw/i2c/aspeed_i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/i2c/aspeed_i2c.c b/hw/i2c/aspeed_i2c.c index 9cda968501..fb973a983d 100644 --- a/hw/i2c/aspeed_i2c.c +++ b/hw/i2c/aspeed_i2c.c @@ -400,7 +400,7 @@ static bool aspeed_i2c_check_sram(AspeedI2CBus *bus) static void aspeed_i2c_bus_cmd_dump(AspeedI2CBus *bus) { -g_autofree char *cmd_flags; +g_autofree char *cmd_flags = NULL; uint32_t count; if (bus->cmd & (I2CD_RX_BUFF_ENABLE | I2CD_RX_BUFF_ENABLE)) { -- 2.23.0
[PATCH] monitor: fix memory leak in monitor_fdset_dup_fd_find_remove
From: Chen Qun When remove dup_fd in monitor_fdset_dup_fd_find_remove function, we need to free mon_fdset_fd_dup. ASAN shows memory leak stack: Direct leak of 96 byte(s) in 3 object(s) allocated from: #0 0xfffd37b033b3 in __interceptor_calloc (/lib64/libasan.so.4+0xd33b3) #1 0xfffd375c71cb in g_malloc0 (/lib64/libglib-2.0.so.0+0x571cb) #2 0xaaae25bf1c17 in monitor_fdset_dup_fd_add /qemu/monitor/misc.c:1724 #3 0xaaae265cfd8f in qemu_open /qemu/util/osdep.c:315 #4 0xaaae264e2b2b in qmp_chardev_open_file_source /qemu/chardev/char-fd.c:122 #5 0xaaae264e47cf in qmp_chardev_open_file /qemu/chardev/char-file.c:81 #6 0xaaae264e118b in qemu_char_open /qemu/chardev/char.c:237 #7 0xaaae264e118b in qemu_chardev_new /qemu/chardev/char.c:964 #8 0xaaae264e1543 in qemu_chr_new_from_opts /qemu/chardev/char.c:680 #9 0xaaae25e12e0f in chardev_init_func /qemu/vl.c:2083 #10 0xaaae26603823 in qemu_opts_foreach /qemu/util/qemu-option.c:1170 #11 0xaaae258c9787 in main /qemu/vl.c:4089 #12 0xfffd35b80b9f in __libc_start_main (/lib64/libc.so.6+0x20b9f) #13 0xaaae258d7b63 (/qemu/build/aarch64-softmmu/qemu-system-aarch64+0x8b7b63) Reported-by: Euler Robot Signed-off-by: Chen Qun --- monitor/misc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/monitor/misc.c b/monitor/misc.c index a04d7edde0..cf79d36100 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -1744,6 +1744,7 @@ static int64_t monitor_fdset_dup_fd_find_remove(int dup_fd, bool remove) if (mon_fdset_fd_dup->fd == dup_fd) { if (remove) { QLIST_REMOVE(mon_fdset_fd_dup, next); +g_free(mon_fdset_fd_dup); if (QLIST_EMPTY(&mon_fdset->dup_fds)) { monitor_fdset_cleanup(mon_fdset); } -- 2.23.0
[PATCH] xhci: Fix memory leak in xhci_kick_epctx when poweroff GuestOS
From: Chen Qun start vm with libvirt, when GuestOS running, enter poweroff command using the xhci keyboard, then ASAN shows memory leak stack: Direct leak of 80 byte(s) in 5 object(s) allocated from: #0 0xfffd1e6431cb in __interceptor_malloc (/lib64/libasan.so.4+0xd31cb) #1 0xfffd1e107163 in g_malloc (/lib64/libglib-2.0.so.0+0x57163) #2 0xaaad39051367 in qemu_sglist_init /qemu/dma-helpers.c:43 #3 0xaaad3947c407 in pci_dma_sglist_init /qemu/include/hw/pci/pci.h:842 #4 0xaaad3947c407 in xhci_xfer_create_sgl /qemu/hw/usb/hcd-xhci.c:1446 #5 0xaaad3947c407 in xhci_setup_packet /qemu/hw/usb/hcd-xhci.c:1618 #6 0xaaad3948625f in xhci_submit /qemu/hw/usb/hcd-xhci.c:1827 #7 0xaaad3948625f in xhci_fire_transfer /qemu/hw/usb/hcd-xhci.c:1839 #8 0xaaad3948625f in xhci_kick_epctx /qemu/hw/usb/hcd-xhci.c:1991 #9 0xaaad3948f537 in xhci_doorbell_write /qemu/hw/usb/hcd-xhci.c:3158 #10 0xaaad38bcbfc7 in memory_region_write_accessor /qemu/memory.c:483 #11 0xaaad38bc654f in access_with_adjusted_size /qemu/memory.c:544 #12 0xaaad38bd1877 in memory_region_dispatch_write /qemu/memory.c:1482 #13 0xaaad38b1c77f in flatview_write_continue /qemu/exec.c:3167 #14 0xaaad38b1ca83 in flatview_write /qemu/exec.c:3207 #15 0xaaad38b268db in address_space_write /qemu/exec.c:3297 #16 0xaaad38bf909b in kvm_cpu_exec /qemu/accel/kvm/kvm-all.c:2383 #17 0xaaad38bb063f in qemu_kvm_cpu_thread_fn /qemu/cpus.c:1246 #18 0xaaad39821c93 in qemu_thread_start /qemu/util/qemu-thread-posix.c:519 #19 0xfffd1c8378bb (/lib64/libpthread.so.0+0x78bb) #20 0xfffd1c77616b (/lib64/libc.so.6+0xd616b) Reported-by: Euler Robot Signed-off-by: Chen Qun --- hw/usb/hcd-xhci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index 80988bb305..0d3d96d05a 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -2000,6 +2000,7 @@ static void xhci_kick_epctx(XHCIEPContext *epctx, unsigned int streamid) if (xfer != NULL && xfer->running_retry) { DPRINTF("xhci: xfer nacked, stopping schedule\n"); epctx->retry = xfer; +xhci_xfer_unmap(xfer); break; } if (count++ > TRANSFER_LIMIT) { -- 2.23.0
[PATCH] vl: fix memory leak in configure_accelerators
From: Chen Qun The accel_list forgot to free, the asan output: Direct leak of 16 byte(s) in 1 object(s) allocated from: #0 0x919331cb in __interceptor_malloc (/lib64/libasan.so.4+0xd31cb) #1 0x913f7163 in g_malloc (/lib64/libglib-2.0.so.0+0x57163) #2 0x91413d9b in g_strsplit (/lib64/libglib-2.0.so.0+0x73d9b) #3 0xaaab42fb58e7 in configure_accelerators /qemu/vl.c:2777 #4 0xaaab42fb58e7 in main /qemu/vl.c:4121 #5 0x8f9b0b9f in __libc_start_main (/lib64/libc.so.6+0x20b9f) #6 0xaaab42fc1dab (/qemu/build/aarch64-softmmu/qemu-system-aarch64+0x8b1dab) Indirect leak of 4 byte(s) in 1 object(s) allocated from: #0 0x919331cb in __interceptor_malloc (/lib64/libasan.so.4+0xd31cb) #1 0x913f7163 in g_malloc (/lib64/libglib-2.0.so.0+0x57163) #2 0x9141243b in g_strdup (/lib64/libglib-2.0.so.0+0x7243b) #3 0x91413e6f in g_strsplit (/lib64/libglib-2.0.so.0+0x73e6f) #4 0xaaab42fb58e7 in configure_accelerators /qemu/vl.c:2777 #5 0xaaab42fb58e7 in main /qemu/vl.c:4121 #6 0x8f9b0b9f in __libc_start_main (/lib64/libc.so.6+0x20b9f) #7 0xaaab42fc1dab (/qemu/build/aarch64-softmmu/qemu-system-aarch64+0x8b1dab) Reported-by: Euler Robot Signed-off-by: Chen Qun --- vl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/vl.c b/vl.c index 86474a55c9..035a24e52b 100644 --- a/vl.c +++ b/vl.c @@ -2788,6 +2788,7 @@ static void configure_accelerators(const char *progname) error_report("invalid accelerator %s", *tmp); } } +g_strfreev(accel_list); } else { if (accel != NULL) { error_report("The -accel and \"-machine accel=\" options are incompatible"); -- 2.23.0