From 830b92509459180eaab986bb37173fd07ba6db53 Mon Sep 17 00:00:00 2001 From: Liao Pingfang Date: Mon, 13 Jul 2020 17:05:26 +0800 Subject: hw: Remove superfluous breaks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove superfluous breaks, as there is a "return" before them. Signed-off-by: Liao Pingfang Signed-off-by: Yi Wang Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Thomas Huth Message-Id: <1594631126-36631-1-git-send-email-wang.yi59@zte.com.cn> Signed-off-by: Laurent Vivier --- hw/block/pflash_cfi01.c | 1 - hw/display/cirrus_vga.c | 1 - hw/display/qxl-logger.c | 2 -- hw/gpio/max7310.c | 3 --- hw/i386/intel_iommu.c | 1 - hw/input/pxa2xx_keypad.c | 10 ---------- hw/intc/armv7m_nvic.c | 1 - hw/net/lan9118.c | 2 -- hw/usb/ccid-card-emulated.c | 1 - 9 files changed, 22 deletions(-) (limited to 'hw') diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index 8ab1d66..f0fcd63 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -213,7 +213,6 @@ static uint32_t pflash_devid_query(PFlashCFI01 *pfl, hwaddr offset) default: trace_pflash_device_info(offset); return 0; - break; } /* Replicate responses for each device in bank. */ if (pfl->device_width < pfl->bank_width) { diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c index 212d6f5..02d9ed0 100644 --- a/hw/display/cirrus_vga.c +++ b/hw/display/cirrus_vga.c @@ -1637,7 +1637,6 @@ static int cirrus_vga_read_cr(CirrusVGAState * s, unsigned reg_index) return s->vga.cr[s->vga.cr_index]; case 0x26: // Attribute Controller Index Readback (R) return s->vga.ar_index & 0x3f; - break; default: qemu_log_mask(LOG_GUEST_ERROR, "cirrus: inport cr_index 0x%02x\n", reg_index); diff --git a/hw/display/qxl-logger.c b/hw/display/qxl-logger.c index 2ec6d8f..c15175b 100644 --- a/hw/display/qxl-logger.c +++ b/hw/display/qxl-logger.c @@ -161,7 +161,6 @@ static int qxl_log_cmd_draw(PCIQXLDevice *qxl, QXLDrawable *draw, int group_id) switch (draw->type) { case QXL_DRAW_COPY: return qxl_log_cmd_draw_copy(qxl, &draw->u.copy, group_id); - break; } return 0; } @@ -180,7 +179,6 @@ static int qxl_log_cmd_draw_compat(PCIQXLDevice *qxl, QXLCompatDrawable *draw, switch (draw->type) { case QXL_DRAW_COPY: return qxl_log_cmd_draw_copy(qxl, &draw->u.copy, group_id); - break; } return 0; } diff --git a/hw/gpio/max7310.c b/hw/gpio/max7310.c index bebb403..4f78774 100644 --- a/hw/gpio/max7310.c +++ b/hw/gpio/max7310.c @@ -51,11 +51,9 @@ static uint8_t max7310_rx(I2CSlave *i2c) switch (s->command) { case 0x00: /* Input port */ return s->level ^ s->polarity; - break; case 0x01: /* Output port */ return s->level & ~s->direction; - break; case 0x02: /* Polarity inversion */ return s->polarity; @@ -65,7 +63,6 @@ static uint8_t max7310_rx(I2CSlave *i2c) case 0x04: /* Timeout */ return s->status; - break; case 0xff: /* Reserved */ return 0xff; diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 5284bb6..0d7c430 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -3168,7 +3168,6 @@ static int vtd_irte_get(IntelIOMMUState *iommu, uint16_t index, index, entry->irte.sid_vtype); /* Take this as verification failure. */ return -VTD_FR_IR_SID_ERR; - break; } } diff --git a/hw/input/pxa2xx_keypad.c b/hw/input/pxa2xx_keypad.c index 62aa6f6..7f2f739 100644 --- a/hw/input/pxa2xx_keypad.c +++ b/hw/input/pxa2xx_keypad.c @@ -192,10 +192,8 @@ static uint64_t pxa2xx_keypad_read(void *opaque, hwaddr offset, s->kpc &= ~(KPC_DI); qemu_irq_lower(s->irq); return tmp; - break; case KPDK: return s->kpdk; - break; case KPREC: tmp = s->kprec; if(tmp & KPREC_OF1) @@ -207,31 +205,23 @@ static uint64_t pxa2xx_keypad_read(void *opaque, hwaddr offset, if(tmp & KPREC_UF0) s->kprec &= ~(KPREC_UF0); return tmp; - break; case KPMK: tmp = s->kpmk; if(tmp & KPMK_MKP) s->kpmk &= ~(KPMK_MKP); return tmp; - break; case KPAS: return s->kpas; - break; case KPASMKP0: return s->kpasmkp[0]; - break; case KPASMKP1: return s->kpasmkp[1]; - break; case KPASMKP2: return s->kpasmkp[2]; - break; case KPASMKP3: return s->kpasmkp[3]; - break; case KPKDI: return s->kpkdi; - break; default: qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad read offset 0x%"HWADDR_PRIx"\n", diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c index 277a98b8..7876c1b 100644 --- a/hw/intc/armv7m_nvic.c +++ b/hw/intc/armv7m_nvic.c @@ -1290,7 +1290,6 @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) case 0xd90: /* MPU_TYPE */ /* Unified MPU; if the MPU is not present this value is zero */ return cpu->pmsav7_dregion << 8; - break; case 0xd94: /* MPU_CTRL */ return cpu->env.v7m.mpu_ctrl[attrs.secure]; case 0xd98: /* MPU_RNR */ diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c index 8e2a432..e35f00f 100644 --- a/hw/net/lan9118.c +++ b/hw/net/lan9118.c @@ -931,10 +931,8 @@ static uint32_t do_mac_read(lan9118_state *s, int reg) | (s->conf.macaddr.a[2] << 16) | (s->conf.macaddr.a[3] << 24); case MAC_HASHH: return s->mac_hashh; - break; case MAC_HASHL: return s->mac_hashl; - break; case MAC_MII_ACC: return s->mac_mii_acc; case MAC_MII_DATA: diff --git a/hw/usb/ccid-card-emulated.c b/hw/usb/ccid-card-emulated.c index 7d6105e..0f1afd6 100644 --- a/hw/usb/ccid-card-emulated.c +++ b/hw/usb/ccid-card-emulated.c @@ -350,7 +350,6 @@ static void *event_thread(void *arg) case VEVENT_LAST: /* quit */ vevent_delete(event); return NULL; - break; default: break; } -- cgit v1.1 From bd7b4e1fe67561fb8b67c0617b7ea4febd1297a0 Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Tue, 30 Jun 2020 09:55:20 +0200 Subject: hw/net/can: Add missing fallthrough statements Add fallthrough annotations to be able to compile the code without warnings when using -Wimplicit-fallthrough in our CFLAGS. Looking at the code, it seems like the fallthrough is indeed intended here, so the comments should be appropriate. Signed-off-by: Thomas Huth Reviewed-by: Laurent Vivier Reviewed-by: Pavel Pisa Message-Id: <20200630075520.29825-1-thuth@redhat.com> Signed-off-by: Laurent Vivier --- hw/net/can/can_sja1000.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'hw') diff --git a/hw/net/can/can_sja1000.c b/hw/net/can/can_sja1000.c index ea915a0..2999329 100644 --- a/hw/net/can/can_sja1000.c +++ b/hw/net/can/can_sja1000.c @@ -523,6 +523,7 @@ void can_sja_mem_write(CanSJA1000State *s, hwaddr addr, uint64_t val, break; case 16: /* RX frame information addr16-28. */ s->status_pel |= (1 << 5); /* Set transmit status. */ + /* fallthrough */ case 17 ... 28: if (s->mode & 0x01) { /* Reset mode */ if (addr < 24) { @@ -620,6 +621,7 @@ void can_sja_mem_write(CanSJA1000State *s, hwaddr addr, uint64_t val, break; case 10: s->status_bas |= (1 << 5); /* Set transmit status. */ + /* fallthrough */ case 11 ... 19: if ((s->control & 0x01) == 0) { /* Operation mode */ s->tx_buff[addr - 10] = val; /* Store to TX buffer directly. */ -- cgit v1.1 From b22c2a68c7d5a57175f13c5920a20e8297955e9b Mon Sep 17 00:00:00 2001 From: Kenta Ishiguro Date: Fri, 17 Jul 2020 21:35:14 +0900 Subject: hw/i386/kvm/ioapic.c: fix typo in error message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix a typo in an error message for KVM_SET_IRQCHIP ioctl: "KVM_GET_IRQCHIP" should be "KVM_SET_IRQCHIP". Fixes: a39c1d47ac ("kvm: x86: Add user space part for in-kernel IOAPIC") Signed-off-by: Kenta Ishiguro Reviewed-by: Stefano Garzarella Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Li Qiang Message-Id: <20200717123514.15406-1-kentaishiguro@slowstart.org> Signed-off-by: Laurent Vivier --- hw/i386/kvm/ioapic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'hw') diff --git a/hw/i386/kvm/ioapic.c b/hw/i386/kvm/ioapic.c index 4ba8e47..c5528df 100644 --- a/hw/i386/kvm/ioapic.c +++ b/hw/i386/kvm/ioapic.c @@ -97,7 +97,7 @@ static void kvm_ioapic_put(IOAPICCommonState *s) ret = kvm_vm_ioctl(kvm_state, KVM_SET_IRQCHIP, &chip); if (ret < 0) { - fprintf(stderr, "KVM_GET_IRQCHIP failed: %s\n", strerror(ret)); + fprintf(stderr, "KVM_SET_IRQCHIP failed: %s\n", strerror(ret)); abort(); } } -- cgit v1.1 From 28b18db754da45d978b0a65f9aa4afbc82edb925 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Tue, 21 Jul 2020 14:45:16 +0200 Subject: hw/isa/isa-superio: Fix IDE controller realization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When realizing a Super I/O with IDE controller [*], we get: qom/object.c:1684: object_property_try_add_child: Assertion `!child->parent' failed. Aborted (core dumped) This is because the device is already realized when we try to add the QOM property to the parent. Fix by realizing *after* adding the QOM relationship. [*] Set ISASuperIOClass::ide.count = N with N not zero (no such thing currently exists; the bug is latent) Fixes: e508430619 ("hw/isa/superio: Make the components QOM children") Reviewed-by: Markus Armbruster Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Paolo Bonzini Message-Id: <20200721124516.9602-1-f4bug@amsat.org> Signed-off-by: Laurent Vivier --- hw/isa/isa-superio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'hw') diff --git a/hw/isa/isa-superio.c b/hw/isa/isa-superio.c index e2e47d8..179c185 100644 --- a/hw/isa/isa-superio.c +++ b/hw/isa/isa-superio.c @@ -158,8 +158,8 @@ static void isa_superio_realize(DeviceState *dev, Error **errp) if (k->ide.get_irq) { qdev_prop_set_uint32(d, "irq", k->ide.get_irq(sio, 0)); } - isa_realize_and_unref(isa, bus, &error_fatal); object_property_add_child(OBJECT(sio), "isa-ide", OBJECT(isa)); + isa_realize_and_unref(isa, bus, &error_fatal); sio->ide = isa; trace_superio_create_ide(0, k->ide.get_iobase ? -- cgit v1.1 From cc6498ec6e9e11c0b2d055efbf2f2bc518c73b3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Thu, 6 Aug 2020 15:09:44 +0200 Subject: hw/core/sysbus: Fix a typo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-Id: <20200806130945.21629-2-f4bug@amsat.org> Signed-off-by: Laurent Vivier --- hw/core/sysbus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'hw') diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c index 70239b7..77ab351 100644 --- a/hw/core/sysbus.c +++ b/hw/core/sysbus.c @@ -64,7 +64,7 @@ void foreach_dynamic_sysbus_device(FindSysbusDeviceFunc *func, void *opaque) .opaque = opaque, }; - /* Loop through all sysbus devices that were spawened outside the machine */ + /* Loop through all sysbus devices that were spawned outside the machine */ container = container_get(qdev_get_machine(), "/peripheral"); find_sysbus_device(container, &find); container = container_get(qdev_get_machine(), "/peripheral-anon"); -- cgit v1.1 From f234501c67234d54dc75f34eb76988c929778070 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Thu, 6 Aug 2020 15:09:45 +0200 Subject: hw/core/sysbus: Assert memory region index is in range MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Devices incorrectly modelled might use invalid index while calling sysbus_mmio_get_region(), leading to OOB access. Help developers by asserting the index is in range. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-Id: <20200806130945.21629-3-f4bug@amsat.org> Signed-off-by: Laurent Vivier --- hw/core/sysbus.c | 1 + 1 file changed, 1 insertion(+) (limited to 'hw') diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c index 77ab351..294f90b 100644 --- a/hw/core/sysbus.c +++ b/hw/core/sysbus.c @@ -199,6 +199,7 @@ void sysbus_init_mmio(SysBusDevice *dev, MemoryRegion *memory) MemoryRegion *sysbus_mmio_get_region(SysBusDevice *dev, int n) { + assert(n >= 0 && n < QDEV_MAX_MMIO); return dev->mmio[n].memory; } -- cgit v1.1 From 68b57b0dd63983041b4678cc5cb5772351ee79f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Fri, 14 Aug 2020 10:28:36 +0200 Subject: hw/ide/core: Trivial typo fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Kevin Wolf Reviewed-by: Li Qiang Reviewed-by: Richard Henderson Reviewed-by: Stefano Garzarella Message-Id: <20200814082841.27000-3-f4bug@amsat.org> Signed-off-by: Laurent Vivier --- hw/ide/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'hw') diff --git a/hw/ide/core.c b/hw/ide/core.c index d997a78..f76f7e5 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -709,7 +709,7 @@ void ide_cancel_dma_sync(IDEState *s) /* * We can't cancel Scatter Gather DMA in the middle of the * operation or a partial (not full) DMA transfer would reach - * the storage so we wait for completion instead (we beahve + * the storage so we wait for completion instead (we behave * like if the DMA was completed by the time the guest trying * to cancel dma with bmdma_cmd_writeb with BM_CMD_START not * set). -- cgit v1.1 From 075f32d386aa93afa6e038e1e35fe4a29ffc8e80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Fri, 14 Aug 2020 10:28:38 +0200 Subject: hw/ide/ahci: Replace magic '512' value by BDRV_SECTOR_SIZE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use self-explicit definitions instead of magic '512' value. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Li Qiang Reviewed-by: Richard Henderson Reviewed-by: Stefano Garzarella Message-Id: <20200814082841.27000-5-f4bug@amsat.org> Signed-off-by: Laurent Vivier --- hw/ide/ahci.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'hw') diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 009120f..b696c62 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -1151,7 +1151,7 @@ static void process_ncq_command(AHCIState *s, int port, uint8_t *cmd_fis, if (!ncq_tfs->sector_count) { ncq_tfs->sector_count = 0x10000; } - size = ncq_tfs->sector_count * 512; + size = ncq_tfs->sector_count * BDRV_SECTOR_SIZE; ahci_populate_sglist(ad, &ncq_tfs->sglist, ncq_tfs->cmdh, size, 0); if (ncq_tfs->sglist.size < size) { @@ -1703,7 +1703,8 @@ static int ahci_state_post_load(void *opaque, int version_id) return -1; } ahci_populate_sglist(ncq_tfs->drive, &ncq_tfs->sglist, - ncq_tfs->cmdh, ncq_tfs->sector_count * 512, + ncq_tfs->cmdh, + ncq_tfs->sector_count * BDRV_SECTOR_SIZE, 0); if (ncq_tfs->sector_count != ncq_tfs->sglist.size >> 9) { return -1; -- cgit v1.1 From a71f2d22628cae4fcb3df6fcc44e63e213d6ee18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Fri, 14 Aug 2020 10:28:39 +0200 Subject: hw/ide/atapi: Replace magic '512' value by BDRV_SECTOR_SIZE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use self-explicit definitions instead of magic '512' value. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Li Qiang Reviewed-by: Richard Henderson Reviewed-by: Stefano Garzarella Message-Id: <20200814082841.27000-6-f4bug@amsat.org> Signed-off-by: Laurent Vivier --- hw/ide/atapi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'hw') diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c index 17a9d63..14a2b0b 100644 --- a/hw/ide/atapi.c +++ b/hw/ide/atapi.c @@ -824,9 +824,9 @@ static void cmd_get_configuration(IDEState *s, uint8_t *buf) * * Only a problem if the feature/profiles grow. */ - if (max_len > 512) { + if (max_len > BDRV_SECTOR_SIZE) { /* XXX: assume 1 sector */ - max_len = 512; + max_len = BDRV_SECTOR_SIZE; } memset(buf, 0, max_len); @@ -1186,8 +1186,8 @@ static void cmd_read_dvd_structure(IDEState *s, uint8_t* buf) } } - memset(buf, 0, max_len > IDE_DMA_BUF_SECTORS * 512 + 4 ? - IDE_DMA_BUF_SECTORS * 512 + 4 : max_len); + memset(buf, 0, max_len > IDE_DMA_BUF_SECTORS * BDRV_SECTOR_SIZE + 4 ? + IDE_DMA_BUF_SECTORS * BDRV_SECTOR_SIZE + 4 : max_len); switch (format) { case 0x00 ... 0x7f: -- cgit v1.1 From 4a13980b10c3858a92a974d9158b5bec36990e33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Fri, 14 Aug 2020 10:28:40 +0200 Subject: hw/ide/pci: Replace magic '512' value by BDRV_SECTOR_SIZE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use self-explicit definitions instead of magic '512' value. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Li Qiang Reviewed-by: Richard Henderson Reviewed-by: Stefano Garzarella Message-Id: <20200814082841.27000-7-f4bug@amsat.org> Signed-off-by: Laurent Vivier --- hw/ide/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'hw') diff --git a/hw/ide/pci.c b/hw/ide/pci.c index 5e85c4ad..b50091b 100644 --- a/hw/ide/pci.c +++ b/hw/ide/pci.c @@ -138,7 +138,7 @@ static int32_t bmdma_prepare_buf(const IDEDMA *dma, int32_t limit) int l, len; pci_dma_sglist_init(&s->sg, pci_dev, - s->nsector / (BMDMA_PAGE_SIZE / 512) + 1); + s->nsector / (BMDMA_PAGE_SIZE / BDRV_SECTOR_SIZE) + 1); s->io_buffer_size = 0; for(;;) { if (bm->cur_prd_len == 0) { -- cgit v1.1 From 3dc516bf929ef1a5cc72a9f5f584f375bddc103a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Fri, 14 Aug 2020 10:28:41 +0200 Subject: hw/scsi/scsi-disk: Replace magic '512' value by BDRV_SECTOR_SIZE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use self-explicit definitions instead of magic '512' value. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Kevin Wolf Reviewed-by: Li Qiang Reviewed-by: Richard Henderson Reviewed-by: Stefano Garzarella Message-Id: <20200814082841.27000-8-f4bug@amsat.org> Signed-off-by: Laurent Vivier --- hw/scsi/scsi-disk.c | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) (limited to 'hw') diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index 8ce68a9..7612035 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -71,7 +71,7 @@ typedef struct SCSIDiskClass { typedef struct SCSIDiskReq { SCSIRequest req; - /* Both sector and sector_count are in terms of qemu 512 byte blocks. */ + /* Both sector and sector_count are in terms of BDRV_SECTOR_SIZE bytes. */ uint64_t sector; uint32_t sector_count; uint32_t buflen; @@ -141,7 +141,7 @@ static void scsi_init_iovec(SCSIDiskReq *r, size_t size) r->buflen = size; r->iov.iov_base = blk_blockalign(s->qdev.conf.blk, r->buflen); } - r->iov.iov_len = MIN(r->sector_count * 512, r->buflen); + r->iov.iov_len = MIN(r->sector_count * BDRV_SECTOR_SIZE, r->buflen); qemu_iovec_init_external(&r->qiov, &r->iov, 1); } @@ -311,7 +311,7 @@ static void scsi_read_complete_noio(SCSIDiskReq *r, int ret) goto done; } - n = r->qiov.size / 512; + n = r->qiov.size / BDRV_SECTOR_SIZE; r->sector += n; r->sector_count -= n; scsi_req_data(&r->req, r->qiov.size); @@ -505,7 +505,7 @@ static void scsi_write_complete_noio(SCSIDiskReq *r, int ret) goto done; } - n = r->qiov.size / 512; + n = r->qiov.size / BDRV_SECTOR_SIZE; r->sector += n; r->sector_count -= n; if (r->sector_count == 0) { @@ -1284,7 +1284,7 @@ static int scsi_disk_emulate_mode_sense(SCSIDiskReq *r, uint8_t *outbuf) } else { /* MODE_SENSE_10 */ outbuf[7] = 8; /* Block descriptor length */ } - nb_sectors /= (s->qdev.blocksize / 512); + nb_sectors /= (s->qdev.blocksize / BDRV_SECTOR_SIZE); if (nb_sectors > 0xffffff) { nb_sectors = 0; } @@ -1342,7 +1342,7 @@ static int scsi_disk_emulate_read_toc(SCSIRequest *req, uint8_t *outbuf) start_track = req->cmd.buf[6]; blk_get_geometry(s->qdev.conf.blk, &nb_sectors); trace_scsi_disk_emulate_read_toc(start_track, format, msf >> 1); - nb_sectors /= s->qdev.blocksize / 512; + nb_sectors /= s->qdev.blocksize / BDRV_SECTOR_SIZE; switch (format) { case 0: toclen = cdrom_read_toc(nb_sectors, outbuf, msf, start_track); @@ -1738,9 +1738,10 @@ static void scsi_write_same_complete(void *opaque, int ret) block_acct_done(blk_get_stats(s->qdev.conf.blk), &r->acct); - data->nb_sectors -= data->iov.iov_len / 512; - data->sector += data->iov.iov_len / 512; - data->iov.iov_len = MIN(data->nb_sectors * 512, data->iov.iov_len); + data->nb_sectors -= data->iov.iov_len / BDRV_SECTOR_SIZE; + data->sector += data->iov.iov_len / BDRV_SECTOR_SIZE; + data->iov.iov_len = MIN(data->nb_sectors * BDRV_SECTOR_SIZE, + data->iov.iov_len); if (data->iov.iov_len) { block_acct_start(blk_get_stats(s->qdev.conf.blk), &r->acct, data->iov.iov_len, BLOCK_ACCT_WRITE); @@ -1805,9 +1806,10 @@ static void scsi_disk_emulate_write_same(SCSIDiskReq *r, uint8_t *inbuf) data = g_new0(WriteSameCBData, 1); data->r = r; - data->sector = r->req.cmd.lba * (s->qdev.blocksize / 512); - data->nb_sectors = nb_sectors * (s->qdev.blocksize / 512); - data->iov.iov_len = MIN(data->nb_sectors * 512, SCSI_WRITE_SAME_MAX); + data->sector = r->req.cmd.lba * (s->qdev.blocksize / BDRV_SECTOR_SIZE); + data->nb_sectors = nb_sectors * (s->qdev.blocksize / BDRV_SECTOR_SIZE); + data->iov.iov_len = MIN(data->nb_sectors * BDRV_SECTOR_SIZE, + SCSI_WRITE_SAME_MAX); data->iov.iov_base = buf = blk_blockalign(s->qdev.conf.blk, data->iov.iov_len); qemu_iovec_init_external(&data->qiov, &data->iov, 1); @@ -1980,7 +1982,7 @@ static int32_t scsi_disk_emulate_command(SCSIRequest *req, uint8_t *buf) if ((req->cmd.buf[8] & 1) == 0 && req->cmd.lba) { goto illegal_request; } - nb_sectors /= s->qdev.blocksize / 512; + nb_sectors /= s->qdev.blocksize / BDRV_SECTOR_SIZE; /* Returned value is the address of the last sector. */ nb_sectors--; /* Remember the new size for read/write sanity checking. */ @@ -2049,7 +2051,7 @@ static int32_t scsi_disk_emulate_command(SCSIRequest *req, uint8_t *buf) if ((req->cmd.buf[14] & 1) == 0 && req->cmd.lba) { goto illegal_request; } - nb_sectors /= s->qdev.blocksize / 512; + nb_sectors /= s->qdev.blocksize / BDRV_SECTOR_SIZE; /* Returned value is the address of the last sector. */ nb_sectors--; /* Remember the new size for read/write sanity checking. */ @@ -2180,8 +2182,8 @@ static int32_t scsi_disk_dma_command(SCSIRequest *req, uint8_t *buf) if (!check_lba_range(s, r->req.cmd.lba, len)) { goto illegal_lba; } - r->sector = r->req.cmd.lba * (s->qdev.blocksize / 512); - r->sector_count = len * (s->qdev.blocksize / 512); + r->sector = r->req.cmd.lba * (s->qdev.blocksize / BDRV_SECTOR_SIZE); + r->sector_count = len * (s->qdev.blocksize / BDRV_SECTOR_SIZE); break; case WRITE_6: case WRITE_10: @@ -2211,8 +2213,8 @@ static int32_t scsi_disk_dma_command(SCSIRequest *req, uint8_t *buf) if (!check_lba_range(s, r->req.cmd.lba, len)) { goto illegal_lba; } - r->sector = r->req.cmd.lba * (s->qdev.blocksize / 512); - r->sector_count = len * (s->qdev.blocksize / 512); + r->sector = r->req.cmd.lba * (s->qdev.blocksize / BDRV_SECTOR_SIZE); + r->sector_count = len * (s->qdev.blocksize / BDRV_SECTOR_SIZE); break; default: abort(); @@ -2229,9 +2231,9 @@ static int32_t scsi_disk_dma_command(SCSIRequest *req, uint8_t *buf) } assert(r->iov.iov_len == 0); if (r->req.cmd.mode == SCSI_XFER_TO_DEV) { - return -r->sector_count * 512; + return -r->sector_count * BDRV_SECTOR_SIZE; } else { - return r->sector_count * 512; + return r->sector_count * BDRV_SECTOR_SIZE; } } @@ -2243,7 +2245,7 @@ static void scsi_disk_reset(DeviceState *dev) scsi_device_purge_requests(&s->qdev, SENSE_CODE(RESET)); blk_get_geometry(s->qdev.conf.blk, &nb_sectors); - nb_sectors /= s->qdev.blocksize / 512; + nb_sectors /= s->qdev.blocksize / BDRV_SECTOR_SIZE; if (nb_sectors) { nb_sectors--; } -- cgit v1.1 From 0445fab522b2c7ca158719c3d1a7b12e02e184a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Fri, 14 Aug 2020 15:30:07 +0200 Subject: hw/net/xilinx_axienet: Remove unused code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Most of the MDIOBus fields are unused. The ADVERTISE_10HALF definition is unused. Remove unused code. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Alistair Francis Reviewed-by: Edgar E. Iglesias Message-Id: <20200814133007.16850-1-f4bug@amsat.org> Signed-off-by: Laurent Vivier --- hw/net/xilinx_axienet.c | 23 ----------------------- 1 file changed, 23 deletions(-) (limited to 'hw') diff --git a/hw/net/xilinx_axienet.c b/hw/net/xilinx_axienet.c index 1e48eb7..2e89f23 100644 --- a/hw/net/xilinx_axienet.c +++ b/hw/net/xilinx_axienet.c @@ -54,7 +54,6 @@ TYPE_XILINX_AXI_ENET_CONTROL_STREAM) /* Advertisement control register. */ -#define ADVERTISE_10HALF 0x0020 /* Try for 10mbps half-duplex */ #define ADVERTISE_10FULL 0x0040 /* Try for 10mbps full-duplex */ #define ADVERTISE_100HALF 0x0080 /* Try for 100mbps half-duplex */ #define ADVERTISE_100FULL 0x0100 /* Try for 100mbps full-duplex */ @@ -169,28 +168,6 @@ tdk_init(struct PHY *phy) } struct MDIOBus { - /* bus. */ - int mdc; - int mdio; - - /* decoder. */ - enum { - PREAMBLE, - SOF, - OPC, - ADDR, - REQ, - TURNAROUND, - DATA - } state; - unsigned int drive; - - unsigned int cnt; - unsigned int addr; - unsigned int opc; - unsigned int req; - unsigned int data; - struct PHY *devs[32]; }; -- cgit v1.1 From b3b0e8145892520d0ae315950379b947a9c7afa6 Mon Sep 17 00:00:00 2001 From: Chen Qun Date: Thu, 27 Aug 2020 19:03:02 +0800 Subject: hw/arm/virt-acpi-build:Remove dead assignment in build_madt() Clang static code analyzer show warning: hw/arm/virt-acpi-build.c:641:5: warning: Value stored to 'madt' is never read madt = acpi_data_push(table_data, sizeof *madt); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Reported-by: Euler Robot Signed-off-by: Chen Qun Reviewed-by: Igor Mammedov Reviewed-by: Li Qiang Reviewed-by: Michael S. Tsirkin Message-Id: <20200827110311.164316-2-kuhn.chenqun@huawei.com> Signed-off-by: Laurent Vivier --- hw/arm/virt-acpi-build.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'hw') diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 0a482ff..9efd7a3 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -633,12 +633,11 @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) int madt_start = table_data->len; const MemMapEntry *memmap = vms->memmap; const int *irqmap = vms->irqmap; - AcpiMultipleApicTable *madt; AcpiMadtGenericDistributor *gicd; AcpiMadtGenericMsiFrame *gic_msi; int i; - madt = acpi_data_push(table_data, sizeof *madt); + acpi_data_push(table_data, sizeof(AcpiMultipleApicTable)); gicd = acpi_data_push(table_data, sizeof *gicd); gicd->type = ACPI_APIC_GENERIC_DISTRIBUTOR; -- cgit v1.1 From aa139a7cd0c572250cf19acd3621228b5d423ba3 Mon Sep 17 00:00:00 2001 From: Chen Qun Date: Thu, 27 Aug 2020 19:03:03 +0800 Subject: hw/arm/omap1:Remove redundant statement in omap_clkdsp_read() Clang static code analyzer show warning: hw/arm/omap1.c:1760:15: warning: Value stored to 'cpu' during its initialization is never read CPUState *cpu = CPU(s->cpu); ^~~ ~~~~~~~~~~~ Reported-by: Euler Robot Signed-off-by: Chen Qun Reviewed-by: Peter Maydell Reviewed-by: Li Qiang Message-Id: <20200827110311.164316-3-kuhn.chenqun@huawei.com> Signed-off-by: Laurent Vivier --- hw/arm/omap1.c | 1 - 1 file changed, 1 deletion(-) (limited to 'hw') diff --git a/hw/arm/omap1.c b/hw/arm/omap1.c index 6ba0df6..02c0f66 100644 --- a/hw/arm/omap1.c +++ b/hw/arm/omap1.c @@ -1774,7 +1774,6 @@ static uint64_t omap_clkdsp_read(void *opaque, hwaddr addr, return s->clkm.dsp_rstct2; case 0x18: /* DSP_SYSST */ - cpu = CPU(s->cpu); return (s->clkm.clocking_scheme << 11) | s->clkm.cold_start | (cpu->halted << 6); /* Quite useless... */ } -- cgit v1.1 From 8b616beebcbb70444c2dbc07b210bd3798cf8462 Mon Sep 17 00:00:00 2001 From: Chen Qun Date: Thu, 27 Aug 2020 19:03:06 +0800 Subject: hw/virtio/vhost-user:Remove dead assignment in scrub_shadow_regions() Clang static code analyzer show warning: hw/virtio/vhost-user.c:606:9: warning: Value stored to 'mr' is never read mr = vhost_user_get_mr_data(reg->userspace_addr, &offset, &fd); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Reported-by: Euler Robot Signed-off-by: Chen Qun Reviewed-by: Raphael Norwitz Reviewed-by: Michael S. Tsirkin Message-Id: <20200827110311.164316-6-kuhn.chenqun@huawei.com> Signed-off-by: Laurent Vivier --- hw/virtio/vhost-user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'hw') diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index d7e2423..9c5b4f7 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -603,7 +603,7 @@ static void scrub_shadow_regions(struct vhost_dev *dev, */ for (i = 0; i < dev->mem->nregions; i++) { reg = &dev->mem->regions[i]; - mr = vhost_user_get_mr_data(reg->userspace_addr, &offset, &fd); + vhost_user_get_mr_data(reg->userspace_addr, &offset, &fd); if (fd > 0) { ++fd_num; } -- cgit v1.1 From b7ea580d0baad1227a341f2e1752e464319eb101 Mon Sep 17 00:00:00 2001 From: Chen Qun Date: Thu, 27 Aug 2020 19:03:07 +0800 Subject: hw/net/virtio-net:Remove redundant statement in virtio_net_rsc_tcp_ctrl_check() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Clang static code analyzer show warning: hw/net/virtio-net.c:2077:5: warning: Value stored to 'tcp_flag' is never read tcp_flag &= VIRTIO_NET_TCP_FLAG; ^ ~~~~~~~~~~~~~~~~~~~ The 'VIRTIO_NET_TCP_FLAG' is '0x3F'. The last ‘tcp_flag’ assignment statement is the same as that of the first two statements. Reported-by: Euler Robot Signed-off-by: Chen Qun Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Li Qiang Reviewed-by: Michael S. Tsirkin Message-Id: <20200827110311.164316-7-kuhn.chenqun@huawei.com> Signed-off-by: Laurent Vivier --- hw/net/virtio-net.c | 1 - 1 file changed, 1 deletion(-) (limited to 'hw') diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index a1fe9e9..cb0d270 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -2075,7 +2075,6 @@ static int virtio_net_rsc_tcp_ctrl_check(VirtioNetRscChain *chain, tcp_flag = htons(tcp->th_offset_flags); tcp_hdr = (tcp_flag & VIRTIO_NET_TCP_HDR_LENGTH) >> 10; tcp_flag &= VIRTIO_NET_TCP_FLAG; - tcp_flag = htons(tcp->th_offset_flags) & 0x3F; if (tcp_flag & TH_SYN) { chain->stat.tcp_syn++; return RSC_BYPASS; -- cgit v1.1 From 9b83b0043f3d517ae588c344288ff615bd2b0713 Mon Sep 17 00:00:00 2001 From: Chen Qun Date: Thu, 27 Aug 2020 19:03:08 +0800 Subject: vfio/platform: Remove dead assignment in vfio_intp_interrupt() Clang static code analyzer show warning: hw/vfio/platform.c:239:9: warning: Value stored to 'ret' is never read ret = event_notifier_test_and_clear(intp->interrupt); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Reported-by: Euler Robot Signed-off-by: Chen Qun Reviewed-by: Eric Auger Reviewed-by: Stefan Hajnoczi Reviewed-by: Li Qiang Message-Id: <20200827110311.164316-8-kuhn.chenqun@huawei.com> Signed-off-by: Laurent Vivier --- hw/vfio/platform.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'hw') diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c index ac2cefc..869ed2c 100644 --- a/hw/vfio/platform.c +++ b/hw/vfio/platform.c @@ -236,7 +236,7 @@ static void vfio_intp_interrupt(VFIOINTp *intp) trace_vfio_intp_interrupt_set_pending(intp->pin); QSIMPLEQ_INSERT_TAIL(&vdev->pending_intp_queue, intp, pqnext); - ret = event_notifier_test_and_clear(intp->interrupt); + event_notifier_test_and_clear(intp->interrupt); return; } -- cgit v1.1 From 4b602b6003140afc981d70c9cd721fc96425dd90 Mon Sep 17 00:00:00 2001 From: Chen Qun Date: Thu, 27 Aug 2020 19:03:09 +0800 Subject: usb/bus: Remove dead assignment in usb_get_fw_dev_path() Clang static code analyzer show warning: qemu/hw/usb/bus.c:615:13: warning: Value stored to 'pos' is never read pos += snprintf(fw_path + pos, fw_len - pos, "%s@%lx", Reported-by: Euler Robot Signed-off-by: Chen Qun Reviewed-by: Markus Armbruster Reviewed-by: Gerd Hoffmann Message-Id: <20200827110311.164316-9-kuhn.chenqun@huawei.com> Signed-off-by: Laurent Vivier --- hw/usb/bus.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'hw') diff --git a/hw/usb/bus.c b/hw/usb/bus.c index b17bda3..2b11041 100644 --- a/hw/usb/bus.c +++ b/hw/usb/bus.c @@ -612,8 +612,8 @@ static char *usb_get_fw_dev_path(DeviceState *qdev) in++; } else { /* the device itself */ - pos += snprintf(fw_path + pos, fw_len - pos, "%s@%lx", - qdev_fw_name(qdev), nr); + snprintf(fw_path + pos, fw_len - pos, "%s@%lx", + qdev_fw_name(qdev), nr); break; } } -- cgit v1.1 From cad2197ba10f5634b87ded155ad85e060f6926eb Mon Sep 17 00:00:00 2001 From: Chen Qun Date: Thu, 27 Aug 2020 19:03:10 +0800 Subject: hw/intc: fix default registers value in exynos4210_combiner_read() Clang static code analyzer show warning: hw/intc/exynos4210_combiner.c:231:9: warning: Value stored to 'val' is never read val = s->reg_set[offset >> 2]; The default register return value should be return 'val'. Reported-by: Euler Robot Signed-off-by: Chen Qun Reviewed-by: Peter Maydell Message-Id: <20200827110311.164316-10-kuhn.chenqun@huawei.com> Signed-off-by: Laurent Vivier --- hw/intc/exynos4210_combiner.c | 1 - 1 file changed, 1 deletion(-) (limited to 'hw') diff --git a/hw/intc/exynos4210_combiner.c b/hw/intc/exynos4210_combiner.c index b8561e4..59dd27f 100644 --- a/hw/intc/exynos4210_combiner.c +++ b/hw/intc/exynos4210_combiner.c @@ -229,7 +229,6 @@ exynos4210_combiner_read(void *opaque, hwaddr offset, unsigned size) TARGET_FMT_plx "offset\n", offset); } val = s->reg_set[offset >> 2]; - return 0; } return val; } -- cgit v1.1 From 2d27ed8231ea3b28014ea2df638dbd020b406ee9 Mon Sep 17 00:00:00 2001 From: Chen Qun Date: Thu, 27 Aug 2020 19:03:11 +0800 Subject: hw/display/vga:Remove redundant statement in vga_draw_graphic() Clang static code analyzer show warning: hw/display/vga.c:1677:9: warning: Value stored to 'update' is never read update = full_update; ^ ~~~~~~~~~~~ Reported-by: Euler Robot Signed-off-by: Chen Qun Reviewed-by: Gerd Hoffmann Reviewed-by: Li Qiang Message-Id: <20200827110311.164316-11-kuhn.chenqun@huawei.com> Signed-off-by: Laurent Vivier --- hw/display/vga.c | 1 - 1 file changed, 1 deletion(-) (limited to 'hw') diff --git a/hw/display/vga.c b/hw/display/vga.c index 061fd9a..836ad50 100644 --- a/hw/display/vga.c +++ b/hw/display/vga.c @@ -1674,7 +1674,6 @@ static void vga_draw_graphic(VGACommonState *s, int full_update) if (!(s->cr[VGA_CRTC_MODE] & 2)) { addr = (addr & ~0x8000) | ((y1 & 2) << 14); } - update = full_update; page0 = addr & s->vbe_size_mask; page1 = (addr + bwidth - 1) & s->vbe_size_mask; if (full_update) { -- cgit v1.1