From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43209) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZEjN9-0004Jg-OZ for qemu-devel@nongnu.org; Mon, 13 Jul 2015 15:26:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZEjN8-0000o6-Oq for qemu-devel@nongnu.org; Mon, 13 Jul 2015 15:26:39 -0400 From: John Snow Date: Mon, 13 Jul 2015 15:26:29 -0400 Message-Id: <1436815589-19194-1-git-send-email-jsnow@redhat.com> Subject: [Qemu-devel] [PATCH] ide: coverity touchups List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-trivial@nongnu.org Cc: John Snow , pbonzini@redhat.com, mjt@tls.msk.ru, qemu-devel@nongnu.org, qemu-block@nongnu.org Just a handful of casts to quiet coverity up. s->ports should never exceed 32, but coverity doesn't know that. ncq_tfs->sector_count should also never exceed 64K. Why not make Coverity a happy camper, though. Signed-off-by: John Snow --- hw/ide/ahci.c | 8 ++++---- hw/ide/macio.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index bb6a92f..c45983c 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -356,7 +356,7 @@ static uint64_t ahci_mem_read_32(void *opaque, hwaddr addr) DPRINTF(-1, "(addr 0x%08X), val 0x%08X\n", (unsigned) addr, val); } else if ((addr >= AHCI_PORT_REGS_START_ADDR) && (addr < (AHCI_PORT_REGS_START_ADDR + - (s->ports * AHCI_PORT_ADDR_OFFSET_LEN)))) { + (s->ports * (hwaddr)AHCI_PORT_ADDR_OFFSET_LEN)))) { val = ahci_port_read(s, (addr - AHCI_PORT_REGS_START_ADDR) >> 7, addr & AHCI_PORT_ADDR_OFFSET_MASK); } @@ -433,7 +433,7 @@ static void ahci_mem_write(void *opaque, hwaddr addr, } } else if ((addr >= AHCI_PORT_REGS_START_ADDR) && (addr < (AHCI_PORT_REGS_START_ADDR + - (s->ports * AHCI_PORT_ADDR_OFFSET_LEN)))) { + (s->ports * (hwaddr)AHCI_PORT_ADDR_OFFSET_LEN)))) { ahci_port_write(s, (addr - AHCI_PORT_REGS_START_ADDR) >> 7, addr & AHCI_PORT_ADDR_OFFSET_MASK, val); } @@ -1571,8 +1571,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, - 0); + ncq_tfs->cmdh, + (int64_t)ncq_tfs->sector_count * 512, 0); if (ncq_tfs->sector_count != ncq_tfs->sglist.size >> 9) { return -1; } diff --git a/hw/ide/macio.c b/hw/ide/macio.c index a55a479..340774b 100644 --- a/hw/ide/macio.c +++ b/hw/ide/macio.c @@ -253,7 +253,7 @@ static void pmac_ide_atapi_transfer_cb(void *opaque, int ret) } /* Calculate current offset */ - offset = (int64_t)(s->lba << 11) + s->io_buffer_index; + offset = ((int64_t)s->lba << 11) + s->io_buffer_index; pmac_dma_read(s->blk, offset, io->len, pmac_ide_atapi_transfer_cb, io); return; -- 2.1.0