From d58f8860ddba8a316bdcdc1010ca4d2ed0b41941 Mon Sep 17 00:00:00 2001 From: Chen Qun Date: Wed, 25 Mar 2020 10:59:17 +0800 Subject: [PATCH 01/19] scsi/esp-pci: add g_assert() for fix clang analyzer warning in esp_pci_io_write() 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 Reviewed-by: Laurent Vivier Message-Id: <20200325025919.21316-2-kuhn.chenqun@huawei.com> Signed-off-by: Laurent Vivier --- hw/scsi/esp-pci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/scsi/esp-pci.c b/hw/scsi/esp-pci.c index d5a1f9e017..497a8d5901 100644 --- a/hw/scsi/esp-pci.c +++ b/hw/scsi/esp-pci.c @@ -197,6 +197,7 @@ static void esp_pci_io_write(void *opaque, hwaddr addr, addr &= ~3; size = 4; } + g_assert(size >= 4); if (addr < 0x40) { /* SCSI core reg */ From fd1c220395eab1712e67238d876c72bf3292c153 Mon Sep 17 00:00:00 2001 From: Chen Qun Date: Wed, 25 Mar 2020 10:59:18 +0800 Subject: [PATCH 02/19] display/blizzard: use extract16() for fix clang analyzer warning in blizzard_draw_line16_32() 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 Reviewed-by: Laurent Vivier Message-Id: <20200325025919.21316-3-kuhn.chenqun@huawei.com> Signed-off-by: Laurent Vivier --- hw/display/blizzard.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/hw/display/blizzard.c b/hw/display/blizzard.c index 359e399c2a..105241577d 100644 --- a/hw/display/blizzard.c +++ b/hw/display/blizzard.c @@ -19,6 +19,7 @@ */ #include "qemu/osdep.h" +#include "qemu/bitops.h" #include "ui/console.h" #include "hw/display/blizzard.h" #include "ui/pixel_ops.h" @@ -932,12 +933,9 @@ static void blizzard_draw_line16_32(uint32_t *dest, const uint16_t *end = (const void *) src + width; while (src < end) { data = *src ++; - b = (data & 0x1f) << 3; - data >>= 5; - g = (data & 0x3f) << 2; - data >>= 6; - r = (data & 0x1f) << 3; - data >>= 5; + b = extract16(data, 0, 5) << 3; + g = extract16(data, 5, 6) << 2; + r = extract16(data, 11, 5) << 3; *dest++ = rgb_to_pixel32(r, g, b); } } From 237d8f09635e01ff2c4e4c8ca28d14b92dfcd8bf Mon Sep 17 00:00:00 2001 From: Chen Qun Date: Wed, 25 Mar 2020 10:59:19 +0800 Subject: [PATCH 03/19] timer/exynos4210_mct: Remove redundant statement in exynos4210_mct_write() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Laurent Vivier Reviewed-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20200325025919.21316-4-kuhn.chenqun@huawei.com> Signed-off-by: Laurent Vivier --- 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; From 4b4d96c776f552e4a7ffe2b686ef1dfc9ad3f98f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Mon, 16 Mar 2020 15:28:27 +0100 Subject: [PATCH 04/19] MAINTAINERS: Mark the LatticeMico32 target as orphan MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Michael Walle expressed his desire to orphan the lm32 target [*]: I guess it is time to pull the plug. Mainly, because I have no time for this anymore. I've always worked on this on my spare time and life changed. And secondly, I guess RISC-V is taking over ;) It has a far better ecosystem. Also, to my knowledge the only (public) user of LM32 is milkymist and this project is dead for years now.. So time to say goodbye. It was fun and I've learned a lot - technically and also how a huge open source project works. Thank you everyone for that :) Basically everything still works and there are even TCG test cases which covers all instructions the processor has. Many thanks to Michael for his substantial contributions to QEMU, and for maintaining the LM32 target for various years! [*] https://www.mail-archive.com/qemu-devel@nongnu.org/msg605024.html Acked-by: Michael Walle Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-Id: <20200316142827.20867-1-philmd@redhat.com> Signed-off-by: Laurent Vivier --- MAINTAINERS | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 8aa8efaf1d..d6886be131 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -184,8 +184,8 @@ F: hw/net/*i82596* F: include/hw/net/lasi_82596.h LM32 TCG CPUs -M: Michael Walle -S: Maintained +R: Michael Walle +S: Orphan F: target/lm32/ F: disas/lm32.c F: hw/lm32/ @@ -977,13 +977,13 @@ F: pc-bios/hppa-firmware.img LM32 Machines ------------- EVR32 and uclinux BSP -M: Michael Walle -S: Maintained +R: Michael Walle +S: Orphan F: hw/lm32/lm32_boards.c milkymist -M: Michael Walle -S: Maintained +R: Michael Walle +S: Orphan F: hw/lm32/milkymist.c M68K Machines From f4eaf69e45c74b33d092ab53903a8458d197e240 Mon Sep 17 00:00:00 2001 From: Wainer dos Santos Moschetta Date: Tue, 10 Mar 2020 15:05:09 -0300 Subject: [PATCH 05/19] hw/mem/pc-dimm: Print slot number on error at pc_dimm_pre_plug() The error report in pc_dimm_pre_plug() now has the slot number printed. Signed-off-by: Wainer dos Santos Moschetta Message-Id: <20200310180510.19489-2-wainersm@redhat.com> Signed-off-by: Laurent Vivier --- hw/mem/pc-dimm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index 8f50b8afea..36edfcf467 100644 --- a/hw/mem/pc-dimm.c +++ b/hw/mem/pc-dimm.c @@ -44,8 +44,8 @@ void pc_dimm_pre_plug(PCDIMMDevice *dimm, MachineState *machine, &error_abort); if ((slot < 0 || slot >= machine->ram_slots) && slot != PC_DIMM_UNASSIGNED_SLOT) { - error_setg(&local_err, "invalid slot number, valid range is [0-%" - PRIu64 "]", machine->ram_slots - 1); + error_setg(&local_err, "invalid slot number %d, valid range is [0-%" + PRIu64 "]", slot, machine->ram_slots - 1); goto out; } From 12d814e901a21fbecc7d34765c02813f187aecef Mon Sep 17 00:00:00 2001 From: Wainer dos Santos Moschetta Date: Tue, 10 Mar 2020 15:05:10 -0300 Subject: [PATCH 06/19] hw/mem/pc-dimm: Fix line over 80 characters warning Signed-off-by: Wainer dos Santos Moschetta Message-Id: <20200310180510.19489-3-wainersm@redhat.com> Signed-off-by: Laurent Vivier --- hw/mem/pc-dimm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index 36edfcf467..6d62588fea 100644 --- a/hw/mem/pc-dimm.c +++ b/hw/mem/pc-dimm.c @@ -218,7 +218,8 @@ static MemoryRegion *pc_dimm_get_memory_region(PCDIMMDevice *dimm, Error **errp) static uint64_t pc_dimm_md_get_addr(const MemoryDeviceState *md) { - return object_property_get_uint(OBJECT(md), PC_DIMM_ADDR_PROP, &error_abort); + return object_property_get_uint(OBJECT(md), PC_DIMM_ADDR_PROP, + &error_abort); } static void pc_dimm_md_set_addr(MemoryDeviceState *md, uint64_t addr, From a1ecb4381829d7eb302bc2d9cb69842c2585601d Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Thu, 23 Apr 2020 21:20:11 +0100 Subject: [PATCH 07/19] elf_ops: Don't try to g_mapped_file_unref(NULL) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Calling g_mapped_file_unref() on a NULL pointer is not valid, and glib will assert if you try it. $ qemu-system-arm -M virt -display none -device loader,file=/tmp/bad.elf qemu-system-arm: -device loader,file=/tmp/bad.elf: GLib: g_mapped_file_unref: assertion 'file != NULL' failed (One way to produce an ELF file that fails like this is to copy just the first 16 bytes of a valid ELF file; this is sufficient to fool the code in load_elf_ram_sym() into thinking it's an ELF file and calling load_elf32() or load_elf64().) The failure-exit path in load_elf can be reached from various points in execution, and for some of those we haven't yet called g_mapped_file_new_from_fd(). Add a condition to the unref call so we only call it if we successfully created the GMappedFile to start with. This will fix the assertion; for the specific case of the generic loader it will then fall back from "guess this is an ELF file" to "maybe it's a uImage or a hex file" and eventually to "just load as a raw data file". Reported-by: Randy Yates Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Stefano Garzarella Message-Id: <20200423202011.32686-1-peter.maydell@linaro.org> Signed-off-by: Laurent Vivier --- include/hw/elf_ops.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/hw/elf_ops.h b/include/hw/elf_ops.h index e0bb47bb67..398a4a2c85 100644 --- a/include/hw/elf_ops.h +++ b/include/hw/elf_ops.h @@ -606,7 +606,9 @@ static int glue(load_elf, SZ)(const char *name, int fd, *highaddr = (uint64_t)(elf_sword)high; ret = total_size; fail: - g_mapped_file_unref(mapped_file); + if (mapped_file) { + g_mapped_file_unref(mapped_file); + } g_free(phdr); return ret; } From 8261cc171f98e89714a0578412e7880396a4f4a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Tue, 21 Apr 2020 14:22:36 +0200 Subject: [PATCH 08/19] MAINTAINERS: Update Keith Busch's email address MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit keith.busch@intel.com address is being rejected. Replace by the email address Keith is actively using. Signed-off-by: Philippe Mathieu-Daudé Acked-by: Keith Busch Message-Id: <20200421122236.24867-1-f4bug@amsat.org> Signed-off-by: Laurent Vivier --- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index d6886be131..1f84e3ae2c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1735,7 +1735,7 @@ F: hw/virtio/virtio-crypto-pci.c F: include/hw/virtio/virtio-crypto.h nvme -M: Keith Busch +M: Keith Busch L: qemu-block@nongnu.org S: Supported F: hw/block/nvme* From 949da1eb9db9df0d998ad2f3086979e4e23a44a1 Mon Sep 17 00:00:00 2001 From: Mikhail Gusarov Date: Sun, 26 Apr 2020 23:09:58 +0200 Subject: [PATCH 09/19] chardev: Add macOS to list of OSes that support -chardev serial MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit macOS API for dealing with serial ports/ttys is identical to BSDs. Signed-off-by: Mikhail Gusarov Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Message-Id: <20200426210956.17324-1-dottedmag@dottedmag.net> Signed-off-by: Laurent Vivier --- chardev/char-serial.c | 2 +- include/qemu/osdep.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/chardev/char-serial.c b/chardev/char-serial.c index 5b833ea077..7c3d84ae24 100644 --- a/chardev/char-serial.c +++ b/chardev/char-serial.c @@ -53,7 +53,7 @@ static void qmp_chardev_open_serial(Chardev *chr, #elif defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \ || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) \ - || defined(__GLIBC__) + || defined(__GLIBC__) || defined(__APPLE__) static void tty_serial_init(int fd, int speed, int parity, int data_bits, int stop_bits) diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 20f5c5f197..ff7c17b857 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -379,7 +379,7 @@ void qemu_anon_ram_free(void *ptr, size_t size); #define HAVE_CHARDEV_SERIAL 1 #elif defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \ || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) \ - || defined(__GLIBC__) + || defined(__GLIBC__) || defined(__APPLE__) #define HAVE_CHARDEV_SERIAL 1 #endif From b3ac2b94cdc939a90d5a22338ae507689e2cfab0 Mon Sep 17 00:00:00 2001 From: Simran Singhal Date: Wed, 1 Apr 2020 22:23:14 +0530 Subject: [PATCH 10/19] Compress lines for immediate return Compress two lines into a single line if immediate return statement is found. It also remove variables progress, val, data, ret and sock as they are no longer needed. Remove space between function "mixer_load" and '(' to fix the checkpatch.pl error:- ERROR: space prohibited between function name and open parenthesis '(' Done using following coccinelle script: @@ local idexpression ret; expression e; @@ -ret = +return e; -return ret; Signed-off-by: Simran Singhal Reviewed-by: Stefan Hajnoczi Message-Id: <20200401165314.GA3213@simran-Inspiron-5558> [lv: in handle_aiocb_write_zeroes_unmap() move "int ret" inside the #ifdef] Signed-off-by: Laurent Vivier --- block/file-posix.c | 8 +++----- block/nfs.c | 3 +-- block/nvme.c | 4 +--- block/vhdx.c | 3 +-- hw/audio/ac97.c | 4 +--- hw/audio/adlib.c | 5 +---- hw/display/cirrus_vga.c | 4 +--- migration/ram.c | 4 +--- ui/gtk.c | 3 +-- util/qemu-sockets.c | 5 +---- 10 files changed, 12 insertions(+), 31 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index bf09ad8bc0..05e094be29 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -1617,13 +1617,12 @@ static int handle_aiocb_write_zeroes_unmap(void *opaque) { RawPosixAIOData *aiocb = opaque; BDRVRawState *s G_GNUC_UNUSED = aiocb->bs->opaque; - int ret; /* First try to write zeros and unmap at the same time */ #ifdef CONFIG_FALLOCATE_PUNCH_HOLE - ret = do_fallocate(s->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, - aiocb->aio_offset, aiocb->aio_nbytes); + int ret = do_fallocate(s->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, + aiocb->aio_offset, aiocb->aio_nbytes); if (ret != -ENOTSUP) { return ret; } @@ -1631,8 +1630,7 @@ static int handle_aiocb_write_zeroes_unmap(void *opaque) /* If we couldn't manage to unmap while guaranteed that the area reads as * all-zero afterwards, just write zeroes without unmapping */ - ret = handle_aiocb_write_zeroes(aiocb); - return ret; + return handle_aiocb_write_zeroes(aiocb); } #ifndef HAVE_COPY_FILE_RANGE diff --git a/block/nfs.c b/block/nfs.c index 2393fbfe6b..18c0a73694 100644 --- a/block/nfs.c +++ b/block/nfs.c @@ -623,8 +623,7 @@ static int nfs_file_open(BlockDriverState *bs, QDict *options, int flags, } bs->total_sectors = ret; - ret = 0; - return ret; + return 0; } static QemuOptsList nfs_create_opts = { diff --git a/block/nvme.c b/block/nvme.c index 7b7c0cc5d6..eb2f54dd9d 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -575,11 +575,9 @@ static bool nvme_poll_cb(void *opaque) { EventNotifier *e = opaque; BDRVNVMeState *s = container_of(e, BDRVNVMeState, irq_notifier); - bool progress = false; trace_nvme_poll_cb(s); - progress = nvme_poll_queues(s); - return progress; + return nvme_poll_queues(s); } static int nvme_init(BlockDriverState *bs, const char *device, int namespace, diff --git a/block/vhdx.c b/block/vhdx.c index 45be0a4321..aedd782604 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -411,8 +411,7 @@ int vhdx_update_headers(BlockDriverState *bs, BDRVVHDXState *s, if (ret < 0) { return ret; } - ret = vhdx_update_header(bs, s, generate_data_write_guid, log_guid); - return ret; + return vhdx_update_header(bs, s, generate_data_write_guid, log_guid); } /* opens the specified header block from the VHDX file header section */ diff --git a/hw/audio/ac97.c b/hw/audio/ac97.c index 1ec87feec0..8a9b9924c4 100644 --- a/hw/audio/ac97.c +++ b/hw/audio/ac97.c @@ -573,11 +573,9 @@ static uint32_t nam_readb (void *opaque, uint32_t addr) static uint32_t nam_readw (void *opaque, uint32_t addr) { AC97LinkState *s = opaque; - uint32_t val = ~0U; uint32_t index = addr; s->cas = 0; - val = mixer_load (s, index); - return val; + return mixer_load(s, index); } static uint32_t nam_readl (void *opaque, uint32_t addr) diff --git a/hw/audio/adlib.c b/hw/audio/adlib.c index d6c1fb0586..7c3b67dcfb 100644 --- a/hw/audio/adlib.c +++ b/hw/audio/adlib.c @@ -120,13 +120,10 @@ static void adlib_write(void *opaque, uint32_t nport, uint32_t val) static uint32_t adlib_read(void *opaque, uint32_t nport) { AdlibState *s = opaque; - uint8_t data; int a = nport & 3; adlib_kill_timers (s); - data = OPLRead (s->opl, a); - - return data; + return OPLRead (s->opl, a); } static void timer_handler (void *opaque, int c, double interval_Sec) diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c index 0d391e1300..1f29731ffe 100644 --- a/hw/display/cirrus_vga.c +++ b/hw/display/cirrus_vga.c @@ -2411,12 +2411,10 @@ static uint64_t cirrus_linear_bitblt_read(void *opaque, unsigned size) { CirrusVGAState *s = opaque; - uint32_t ret; /* XXX handle bitblt */ (void)s; - ret = 0xff; - return ret; + return 0xff; } static void cirrus_linear_bitblt_write(void *opaque, diff --git a/migration/ram.c b/migration/ram.c index 04f13feb2e..06cba88632 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2135,9 +2135,7 @@ int ram_postcopy_send_discard_bitmap(MigrationState *ms) } trace_ram_postcopy_send_discard_bitmap(); - ret = postcopy_each_ram_send_discard(ms); - - return ret; + return postcopy_each_ram_send_discard(ms); } /** diff --git a/ui/gtk.c b/ui/gtk.c index 030b251c61..83f2f5d49b 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -1650,8 +1650,7 @@ static GSList *gd_vc_menu_init(GtkDisplayState *s, VirtualConsole *vc, G_CALLBACK(gd_menu_switch_vc), s); gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), vc->menu_item); - group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(vc->menu_item)); - return group; + return gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(vc->menu_item)); } #if defined(CONFIG_VTE) diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index bcc06d0e01..86c48b9fa5 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -765,15 +765,12 @@ static int vsock_connect_addr(const struct sockaddr_vm *svm, Error **errp) static int vsock_connect_saddr(VsockSocketAddress *vaddr, Error **errp) { struct sockaddr_vm svm; - int sock = -1; if (!vsock_parse_vaddr_to_sockaddr(vaddr, &svm, errp)) { return -1; } - sock = vsock_connect_addr(&svm, errp); - - return sock; + return vsock_connect_addr(&svm, errp); } static int vsock_listen_saddr(VsockSocketAddress *vaddr, From dfde483ea38ce221e8e634823620308550b8f7f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Wed, 22 Apr 2020 15:31:44 +0200 Subject: [PATCH 11/19] block: Avoid dead assignment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix warning reported by Clang static code analyzer: block.c:3167:5: warning: Value stored to 'ret' is never read ret = bdrv_fill_options(&options, filename, &flags, &local_err); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Fixes: 462f5bcf6 Reported-by: Clang Static Analyzer Suggested-by: Markus Armbruster Reviewed-by: Alistair Francis Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Max Reitz Message-Id: <20200422133152.16770-2-philmd@redhat.com> Signed-off-by: Laurent Vivier --- block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block.c b/block.c index 301ec588bd..cf5c19b1db 100644 --- a/block.c +++ b/block.c @@ -3165,7 +3165,7 @@ static BlockDriverState *bdrv_open_inherit(const char *filename, } ret = bdrv_fill_options(&options, filename, &flags, &local_err); - if (local_err) { + if (ret < 0) { goto fail; } From 1fe5a8c2cd5dc0da03a4246474abf37f0e8cc8c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Wed, 22 Apr 2020 15:31:45 +0200 Subject: [PATCH 12/19] blockdev: Remove dead assignment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix warning reported by Clang static code analyzer: CC blockdev.o blockdev.c:2744:5: warning: Value stored to 'ret' is never read ret = blk_truncate(blk, size, false, PREALLOC_MODE_OFF, errp); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Reported-by: Clang Static Analyzer Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Max Reitz Message-Id: <20200422133152.16770-3-philmd@redhat.com> [lv: fix conflict because of "Add flags to blk_truncate()"] Signed-off-by: Laurent Vivier --- blockdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blockdev.c b/blockdev.c index dc1a0c7c2f..708d0c323f 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2741,7 +2741,7 @@ void qmp_block_resize(bool has_device, const char *device, } bdrv_drained_begin(bs); - ret = blk_truncate(blk, size, false, PREALLOC_MODE_OFF, 0, errp); + blk_truncate(blk, size, false, PREALLOC_MODE_OFF, 0, errp); bdrv_drained_end(bs); out: From 00d1d29b768d920342c5e33cc56a9e0be596b2b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Wed, 22 Apr 2020 15:31:46 +0200 Subject: [PATCH 13/19] hw/i2c/pm_smbus: Remove dead assignment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix warning reported by Clang static code analyzer: CC hw/i2c/pm_smbus.o hw/i2c/pm_smbus.c:187:17: warning: Value stored to 'ret' is never read ret = 0; ^ ~ Reported-by: Clang Static Analyzer Reviewed-by: Alistair Francis Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20200422133152.16770-4-philmd@redhat.com> Signed-off-by: Laurent Vivier --- hw/i2c/pm_smbus.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/i2c/pm_smbus.c b/hw/i2c/pm_smbus.c index 36994ff585..4728540c37 100644 --- a/hw/i2c/pm_smbus.c +++ b/hw/i2c/pm_smbus.c @@ -184,7 +184,6 @@ static void smb_transaction(PMSMBus *s) s->smb_stat |= STS_HOST_BUSY | STS_BYTE_DONE; s->smb_data[0] = s->smb_blkdata; s->smb_index = 0; - ret = 0; } goto out; } From 1cf5ae5129a8e78b9eb2d6545bcc56a8b136eb79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Wed, 22 Apr 2020 15:31:47 +0200 Subject: [PATCH 14/19] hw/input/adb-kbd: Remove dead assignment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since commit 5a1f49718 the 'olen' variable is not really used. Remove it to fix a warning reported by Clang static code analyzer: CC hw/input/adb-kbd.o hw/input/adb-kbd.c:200:5: warning: Value stored to 'olen' is never read olen = 0; ^ ~ Fixes: 5a1f49718 (adb: add support for QKeyCode) Reported-by: Clang Static Analyzer Suggested-by: BALATON Zoltan Acked-by: David Gibson Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20200422133152.16770-5-philmd@redhat.com> Signed-off-by: Laurent Vivier --- hw/input/adb-kbd.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/hw/input/adb-kbd.c b/hw/input/adb-kbd.c index 0ba8207589..a6d5c9b7c9 100644 --- a/hw/input/adb-kbd.c +++ b/hw/input/adb-kbd.c @@ -195,9 +195,7 @@ static int adb_kbd_poll(ADBDevice *d, uint8_t *obuf) { KBDState *s = ADB_KEYBOARD(d); int keycode; - int olen; - olen = 0; if (s->count == 0) { return 0; } @@ -216,7 +214,6 @@ static int adb_kbd_poll(ADBDevice *d, uint8_t *obuf) if (keycode == 0x7f) { obuf[0] = 0x7f; obuf[1] = 0x7f; - olen = 2; } else { obuf[0] = keycode; /* NOTE: the power key key-up is the two byte sequence 0xff 0xff; @@ -224,10 +221,9 @@ static int adb_kbd_poll(ADBDevice *d, uint8_t *obuf) * byte, but choose not to bother. */ obuf[1] = 0xff; - olen = 2; } - return olen; + return 2; } static int adb_kbd_request(ADBDevice *d, uint8_t *obuf, From 22c9336d3a82d1469796b7421cb5bd5f9bfd9748 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Wed, 22 Apr 2020 15:31:48 +0200 Subject: [PATCH 15/19] hw/ide/sii3112: Remove dead assignment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix warning reported by Clang static code analyzer: CC hw/ide/sii3112.o hw/ide/sii3112.c:204:9: warning: Value stored to 'val' is never read val = 0; ^ ~ Fixes: a9dd6604 Reported-by: Clang Static Analyzer Reviewed-by: BALATON Zoltan Acked-by: John Snow Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20200422133152.16770-6-philmd@redhat.com> Signed-off-by: Laurent Vivier --- hw/ide/sii3112.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/ide/sii3112.c b/hw/ide/sii3112.c index d69079c3d9..94d2b57f95 100644 --- a/hw/ide/sii3112.c +++ b/hw/ide/sii3112.c @@ -42,7 +42,7 @@ static uint64_t sii3112_reg_read(void *opaque, hwaddr addr, unsigned int size) { SiI3112PCIState *d = opaque; - uint64_t val = 0; + uint64_t val; switch (addr) { case 0x00: @@ -126,6 +126,7 @@ static uint64_t sii3112_reg_read(void *opaque, hwaddr addr, break; default: val = 0; + break; } trace_sii3112_read(size, addr, val); return val; @@ -201,7 +202,7 @@ static void sii3112_reg_write(void *opaque, hwaddr addr, d->regs[1].sien = (val >> 16) & 0x3eed; break; default: - val = 0; + break; } } From 2c8ed55f0f615ea825cb30e80e74a07d6945bcf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Wed, 22 Apr 2020 15:31:49 +0200 Subject: [PATCH 16/19] hw/isa/i82378: Remove dead assignment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rename the unique variable assigned as 'pit' which better represents what it holds, to fix a warning reported by the Clang static code analyzer: CC hw/isa/i82378.o hw/isa/i82378.c:108:5: warning: Value stored to 'isa' is never read isa = isa_create_simple(isabus, "i82374"); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Reported-by: Clang Static Analyzer Reviewed-by: Alistair Francis Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20200422133152.16770-7-philmd@redhat.com> Signed-off-by: Laurent Vivier --- hw/isa/i82378.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/isa/i82378.c b/hw/isa/i82378.c index dcb6b479ea..d9e6c7fa00 100644 --- a/hw/isa/i82378.c +++ b/hw/isa/i82378.c @@ -67,7 +67,7 @@ static void i82378_realize(PCIDevice *pci, Error **errp) I82378State *s = I82378(dev); uint8_t *pci_conf; ISABus *isabus; - ISADevice *isa; + ISADevice *pit; pci_conf = pci->config; pci_set_word(pci_conf + PCI_COMMAND, @@ -99,13 +99,13 @@ static void i82378_realize(PCIDevice *pci, Error **errp) isa_bus_irqs(isabus, s->i8259); /* 1 82C54 (pit) */ - isa = i8254_pit_init(isabus, 0x40, 0, NULL); + pit = i8254_pit_init(isabus, 0x40, 0, NULL); /* speaker */ - pcspk_init(isabus, isa); + pcspk_init(isabus, pit); /* 2 82C37 (dma) */ - isa = isa_create_simple(isabus, "i82374"); + isa_create_simple(isabus, "i82374"); } static void i82378_init(Object *obj) From 6ae1a5a37711c80166b92019174877fc6f73030a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Wed, 22 Apr 2020 15:31:50 +0200 Subject: [PATCH 17/19] hw/gpio/aspeed_gpio: Remove dead assignment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix warning reported by Clang static code analyzer: hw/gpio/aspeed_gpio.c:717:18: warning: Value stored to 'g_idx' during its initialization is never read int set_idx, g_idx = *group_idx; ^~~~~ ~~~~~~~~~~ Reported-by: Clang Static Analyzer Reviewed-by: Cédric Le Goater Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20200422133152.16770-8-philmd@redhat.com> Signed-off-by: Laurent Vivier --- hw/gpio/aspeed_gpio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/gpio/aspeed_gpio.c b/hw/gpio/aspeed_gpio.c index e52fcfd9a0..4c75b5c80c 100644 --- a/hw/gpio/aspeed_gpio.c +++ b/hw/gpio/aspeed_gpio.c @@ -712,7 +712,7 @@ static void aspeed_gpio_write(void *opaque, hwaddr offset, uint64_t data, static int get_set_idx(AspeedGPIOState *s, const char *group, int *group_idx) { AspeedGPIOClass *agc = ASPEED_GPIO_GET_CLASS(s); - int set_idx, g_idx = *group_idx; + int set_idx, g_idx; for (set_idx = 0; set_idx < agc->nr_gpio_sets; set_idx++) { const GPIOSetProperties *set_props = &agc->props[set_idx]; From dd1545a3f03f6e821a4ef588acbd99fb4328bcc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Wed, 22 Apr 2020 15:31:51 +0200 Subject: [PATCH 18/19] hw/timer/stm32f2xx_timer: Remove dead assignment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix warning reported by Clang static code analyzer: CC hw/timer/stm32f2xx_timer.o hw/timer/stm32f2xx_timer.c:225:9: warning: Value stored to 'value' is never read value = timer_val; ^ ~~~~~~~~~ Reported-by: Clang Static Analyzer Reviewed-by: Alistair Francis Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20200422133152.16770-9-philmd@redhat.com> Signed-off-by: Laurent Vivier --- hw/timer/stm32f2xx_timer.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/timer/stm32f2xx_timer.c b/hw/timer/stm32f2xx_timer.c index 06ec8a02c2..ba8694dcd3 100644 --- a/hw/timer/stm32f2xx_timer.c +++ b/hw/timer/stm32f2xx_timer.c @@ -222,7 +222,6 @@ static void stm32f2xx_timer_write(void *opaque, hwaddr offset, case TIM_PSC: timer_val = stm32f2xx_ns_to_ticks(s, now) - s->tick_offset; s->tim_psc = value & 0xFFFF; - value = timer_val; break; case TIM_CNT: timer_val = value; From e702fba83108519618046a2a09235a62e3a81595 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Wed, 22 Apr 2020 15:31:52 +0200 Subject: [PATCH 19/19] hw/timer/pxa2xx_timer: Add assertion to silent static analyzer warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit pxa2xx_timer_tick4() takes an opaque pointer, then calls pxa2xx_timer_update4(), so the static analyzer can not verify that the 'n < 8': 425 static void pxa2xx_timer_tick4(void *opaque) 426 { 427 PXA2xxTimer4 *t = (PXA2xxTimer4 *) opaque; 428 PXA2xxTimerInfo *i = (PXA2xxTimerInfo *) t->tm.info; 429 430 pxa2xx_timer_tick(&t->tm); 433 if (t->control & (1 << 6)) 434 pxa2xx_timer_update4(i, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL), t->tm.num - 4); 135 static void pxa2xx_timer_update4(void *opaque, uint64_t now_qemu, int n) 136 { 137 PXA2xxTimerInfo *s = (PXA2xxTimerInfo *) opaque; 140 static const int counters[8] = { 0, 0, 0, 0, 4, 4, 6, 6 }; 142 143 if (s->tm4[n].control & (1 << 7)) 144 counter = n; 145 else 146 counter = counters[n]; Add an assert() to give the static analyzer a hint, this fixes a warning reported by Clang static code analyzer: CC hw/timer/pxa2xx_timer.o hw/timer/pxa2xx_timer.c:146:17: warning: Assigned value is garbage or undefined counter = counters[n]; ^ ~~~~~~~~~~~ Reported-by: Clang Static Analyzer Reviewed-by: Alistair Francis Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20200422133152.16770-10-philmd@redhat.com> Signed-off-by: Laurent Vivier --- hw/timer/pxa2xx_timer.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/timer/pxa2xx_timer.c b/hw/timer/pxa2xx_timer.c index cd172cc1e9..944c165889 100644 --- a/hw/timer/pxa2xx_timer.c +++ b/hw/timer/pxa2xx_timer.c @@ -140,6 +140,7 @@ static void pxa2xx_timer_update4(void *opaque, uint64_t now_qemu, int n) static const int counters[8] = { 0, 0, 0, 0, 4, 4, 6, 6 }; int counter; + assert(n < ARRAY_SIZE(counters)); if (s->tm4[n].control & (1 << 7)) counter = n; else