From patchwork Sat Sep 4 14:17:05 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Blue Swirl X-Patchwork-Id: 63777 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B2D60B7142 for ; Sun, 5 Sep 2010 00:18:32 +1000 (EST) Received: from localhost ([127.0.0.1]:33037 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OrtZd-0000k3-Ks for incoming@patchwork.ozlabs.org; Sat, 04 Sep 2010 10:18:29 -0400 Received: from [140.186.70.92] (port=60259 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OrtYd-0000iz-9b for qemu-devel@nongnu.org; Sat, 04 Sep 2010 10:17:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OrtYb-0007xr-TA for qemu-devel@nongnu.org; Sat, 04 Sep 2010 10:17:27 -0400 Received: from mail-qw0-f45.google.com ([209.85.216.45]:37512) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OrtYb-0007xn-OA for qemu-devel@nongnu.org; Sat, 04 Sep 2010 10:17:25 -0400 Received: by qwh5 with SMTP id 5so2800166qwh.4 for ; Sat, 04 Sep 2010 07:17:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:from:date :message-id:subject:to:content-type; bh=eyBMtr3SDc996NyhpJd9gpMzECWYFJQLDtfBtt4hQrM=; b=Q7zVg8vEGGzzDgre69VCKkrLLf6MAzl0x+7Oq40LtU7IdivbygjFyxI4/sFxtZzIQo z+kxQck2IxHhIbA5VxUclvWb7w/GNuJuLllOQGyXftmjEoRPB4aQayzIT+RHEkNLmyq7 FUj1KMO+2+ZZMJm9sSehKCefzCRHKdYsTP39E= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; b=iYFBF9+LzMJIHnasYhvYpsx/7UphtE9gt3LHkqoAG04CUxccut9fxlfn3T+nMfhUz2 rTpTvwk7Xgtdw5Loq+/usRiFzR27uPsxYvtz0E7XOCz9tOTHPbfOmQcLXCZoZMX/7flN DDxebrPY72lrwmMKm9+j/e1kZJfWOROS+b+NE= Received: by 10.224.106.133 with SMTP id x5mr1044700qao.146.1283609845216; Sat, 04 Sep 2010 07:17:25 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.240.135 with HTTP; Sat, 4 Sep 2010 07:17:05 -0700 (PDT) From: Blue Swirl Date: Sat, 4 Sep 2010 14:17:05 +0000 Message-ID: To: qemu-devel X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [Qemu-devel] [PATCH 1/5] Suppress some gcc warnings with -Wtype-limits X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Add various casts, adjust types etc. to make the warnings with gcc flag -Wtype-limits disappear. Signed-off-by: Blue Swirl --- block/blkdebug.c | 2 +- hw/mips_fulong2e.c | 2 +- hw/omap1.c | 2 +- hw/ppc405_boards.c | 23 +++++++++++++---------- hw/ppc_newworld.c | 3 ++- hw/ppc_prep.c | 3 ++- hw/pxa2xx.c | 2 +- hw/sm501.c | 4 ++-- linux-user/flatload.c | 3 ++- linux-user/mmap.c | 2 +- linux-user/syscall.c | 20 +++++++++++++------- 11 files changed, 39 insertions(+), 27 deletions(-) @@ -1656,8 +1658,9 @@ static abi_long do_accept(int fd, abi_ulong target_addr, if (get_user_u32(addrlen, target_addrlen_addr)) return -TARGET_EINVAL; - if (addrlen < 0) + if ((int)addrlen < 0) { return -TARGET_EINVAL; + } if (!access_ok(VERIFY_WRITE, target_addr, addrlen)) return -TARGET_EINVAL; @@ -1684,8 +1687,9 @@ static abi_long do_getpeername(int fd, abi_ulong target_addr, if (get_user_u32(addrlen, target_addrlen_addr)) return -TARGET_EFAULT; - if (addrlen < 0) + if ((int)addrlen < 0) { return -TARGET_EINVAL; + } if (!access_ok(VERIFY_WRITE, target_addr, addrlen)) return -TARGET_EFAULT; @@ -1712,8 +1716,9 @@ static abi_long do_getsockname(int fd, abi_ulong target_addr, if (get_user_u32(addrlen, target_addrlen_addr)) return -TARGET_EFAULT; - if (addrlen < 0) + if ((int)addrlen < 0) { return -TARGET_EINVAL; + } if (!access_ok(VERIFY_WRITE, target_addr, addrlen)) return -TARGET_EFAULT; @@ -1753,8 +1758,9 @@ static abi_long do_sendto(int fd, abi_ulong msg, size_t len, int flags, void *host_msg; abi_long ret; - if (addrlen < 0) + if ((int)addrlen < 0) { return -TARGET_EINVAL; + } host_msg = lock_user(VERIFY_READ, msg, len, 1); if (!host_msg) @@ -1792,7 +1798,7 @@ static abi_long do_recvfrom(int fd, abi_ulong msg, size_t len, int flags, ret = -TARGET_EFAULT; goto fail; } - if (addrlen < 0) { + if ((int)addrlen < 0) { ret = -TARGET_EINVAL; goto fail; } diff --git a/block/blkdebug.c b/block/blkdebug.c index 2a63df9..b5083bc 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -439,7 +439,7 @@ static void blkdebug_debug_event(BlockDriverState *bs, BlkDebugEvent event) struct BlkdebugRule *rule; BlkdebugVars old_vars = s->vars; - if (event < 0 || event >= BLKDBG_EVENT_MAX) { + if ((unsigned int)event >= BLKDBG_EVENT_MAX) { return; } diff --git a/hw/mips_fulong2e.c b/hw/mips_fulong2e.c index cbe7156..ac82067 100644 --- a/hw/mips_fulong2e.c +++ b/hw/mips_fulong2e.c @@ -258,7 +258,7 @@ static void mips_fulong2e_init(ram_addr_t ram_size, const char *boot_device, { char *filename; unsigned long ram_offset, bios_offset; - unsigned long bios_size; + long bios_size; int64_t kernel_entry; qemu_irq *i8259; qemu_irq *cpu_exit_irq; diff --git a/hw/omap1.c b/hw/omap1.c index 06370b6..b04aa80 100644 --- a/hw/omap1.c +++ b/hw/omap1.c @@ -3675,7 +3675,7 @@ static int omap_validate_emiff_addr(struct omap_mpu_state_s *s, static int omap_validate_emifs_addr(struct omap_mpu_state_s *s, target_phys_addr_t addr) { - return addr >= OMAP_EMIFS_BASE && addr < OMAP_EMIFF_BASE; + return addr < OMAP_EMIFF_BASE; } static int omap_validate_imif_addr(struct omap_mpu_state_s *s, diff --git a/hw/ppc405_boards.c b/hw/ppc405_boards.c index 662d7c4..db8e5ec 100644 --- a/hw/ppc405_boards.c +++ b/hw/ppc405_boards.c @@ -182,10 +182,12 @@ static void ref405ep_init (ram_addr_t ram_size, qemu_irq *pic; ram_addr_t sram_offset, bios_offset, bdloc; target_phys_addr_t ram_bases[2], ram_sizes[2]; - target_ulong sram_size, bios_size; + target_ulong sram_size; + long bios_size; //int phy_addr = 0; //static int phy_addr = 1; - target_ulong kernel_base, kernel_size, initrd_base, initrd_size; + target_ulong kernel_base, initrd_base; + long kernel_size, initrd_size; int linux_boot; int fl_idx, fl_sectors, len; DriveInfo *dinfo; @@ -221,8 +223,8 @@ static void ref405ep_init (ram_addr_t ram_size, bios_offset = qemu_ram_alloc(NULL, "ef405ep.bios", bios_size); fl_sectors = (bios_size + 65535) >> 16; #ifdef DEBUG_BOARD_INIT - printf("Register parallel flash %d size " TARGET_FMT_lx - " at offset %08lx addr " TARGET_FMT_lx " '%s' %d\n", + printf("Register parallel flash %d size %lx" + " at offset %08lx addr %lx '%s' %d\n", fl_idx, bios_size, bios_offset, -bios_size, bdrv_get_device_name(dinfo->bdrv), fl_sectors); #endif @@ -308,7 +310,7 @@ static void ref405ep_init (ram_addr_t ram_size, kernel_filename); exit(1); } - printf("Load kernel size " TARGET_FMT_ld " at " TARGET_FMT_lx, + printf("Load kernel size %ld at " TARGET_FMT_lx, kernel_size, kernel_base); /* load initrd */ if (initrd_filename) { @@ -503,8 +505,9 @@ static void taihu_405ep_init(ram_addr_t ram_size, qemu_irq *pic; ram_addr_t bios_offset; target_phys_addr_t ram_bases[2], ram_sizes[2]; - target_ulong bios_size; - target_ulong kernel_base, kernel_size, initrd_base, initrd_size; + long bios_size; + target_ulong kernel_base, initrd_base; + long kernel_size, initrd_size; int linux_boot; int fl_idx, fl_sectors; DriveInfo *dinfo; @@ -534,8 +537,8 @@ static void taihu_405ep_init(ram_addr_t ram_size, fl_sectors = (bios_size + 65535) >> 16; bios_offset = qemu_ram_alloc(NULL, "taihu_405ep.bios", bios_size); #ifdef DEBUG_BOARD_INIT - printf("Register parallel flash %d size " TARGET_FMT_lx - " at offset %08lx addr " TARGET_FMT_lx " '%s' %d\n", + printf("Register parallel flash %d size %lx" + " at offset %08lx addr %lx '%s' %d\n", fl_idx, bios_size, bios_offset, -bios_size, bdrv_get_device_name(dinfo->bdrv), fl_sectors); #endif @@ -576,7 +579,7 @@ static void taihu_405ep_init(ram_addr_t ram_size, bios_size = 32 * 1024 * 1024; fl_sectors = (bios_size + 65535) >> 16; #ifdef DEBUG_BOARD_INIT - printf("Register parallel flash %d size " TARGET_FMT_lx + printf("Register parallel flash %d size %lx" " at offset %08lx addr " TARGET_FMT_lx " '%s'\n", fl_idx, bios_size, bios_offset, (target_ulong)0xfc000000, bdrv_get_device_name(dinfo->bdrv)); diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c index 809a1cf..fb07c83 100644 --- a/hw/ppc_newworld.c +++ b/hw/ppc_newworld.c @@ -135,7 +135,8 @@ static void ppc_core99_init (ram_addr_t ram_size, int unin_memory; int linux_boot, i; ram_addr_t ram_offset, bios_offset, vga_bios_offset; - uint32_t kernel_base, kernel_size, initrd_base, initrd_size; + uint32_t kernel_base, initrd_base; + long kernel_size, initrd_size; PCIBus *pci_bus; MacIONVRAMState *nvr; int nvram_mem_index; diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c index 52fa9b6..0e5b88c 100644 --- a/hw/ppc_prep.c +++ b/hw/ppc_prep.c @@ -572,7 +572,8 @@ static void ppc_prep_init (ram_addr_t ram_size, int PPC_io_memory; int linux_boot, i, nb_nics1, bios_size; ram_addr_t ram_offset, bios_offset; - uint32_t kernel_base, kernel_size, initrd_base, initrd_size; + uint32_t kernel_base, initrd_base; + long kernel_size, initrd_size; PCIBus *pci_bus; qemu_irq *i8259; qemu_irq *cpu_exit_irq; diff --git a/hw/pxa2xx.c b/hw/pxa2xx.c index 26b9205..3c06bf9 100644 --- a/hw/pxa2xx.c +++ b/hw/pxa2xx.c @@ -125,7 +125,7 @@ static void pxa2xx_pm_write(void *opaque, target_phys_addr_t addr, break; default: /* Read-write registers */ - if (addr >= PMCR && addr <= PCMD31 && !(addr & 3)) { + if (addr <= PCMD31 && !(addr & 3)) { s->pm_regs[addr >> 2] = value; break; } diff --git a/hw/sm501.c b/hw/sm501.c index 8e6932d..1eb6b63 100644 --- a/hw/sm501.c +++ b/hw/sm501.c @@ -814,7 +814,7 @@ static uint32_t sm501_palette_read(void *opaque, target_phys_addr_t addr) /* TODO : consider BYTE/WORD access */ /* TODO : consider endian */ - assert(0 <= addr && addr < 0x400 * 3); + assert(addr < 0x400 * 3); return *(uint32_t*)&s->dc_palette[addr]; } @@ -828,7 +828,7 @@ static void sm501_palette_write(void *opaque, /* TODO : consider BYTE/WORD access */ /* TODO : consider endian */ - assert(0 <= addr && addr < 0x400 * 3); + assert(addr < 0x400 * 3); *(uint32_t*)&s->dc_palette[addr] = value; } diff --git a/linux-user/flatload.c b/linux-user/flatload.c index 8ad130a..8f9f4a5 100644 --- a/linux-user/flatload.c +++ b/linux-user/flatload.c @@ -383,7 +383,8 @@ static int load_flat_file(struct linux_binprm * bprm, struct lib_info *libinfo, int id, abi_ulong *extra_stack) { struct flat_hdr * hdr; - abi_ulong textpos = 0, datapos = 0, result; + abi_ulong textpos = 0, datapos = 0; + abi_long result; abi_ulong realdatastart = 0; abi_ulong text_len, data_len, bss_len, stack_len, flags; abi_ulong memp = 0; /* for finding the brk area */ diff --git a/linux-user/mmap.c b/linux-user/mmap.c index e10a6ef..67d020d 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -342,7 +342,7 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size) munmap(ptr, size); /* ENOMEM if we checked the whole of the target address space. */ - if (addr == -1ul) { + if (addr == (abi_ulong)-1ul) { return (abi_ulong)-1; } else if (addr == 0) { if (wrapped) { diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 0ebe7e1..d44f512 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1551,8 +1551,9 @@ static abi_long do_bind(int sockfd, abi_ulong target_addr, void *addr; abi_long ret; - if (addrlen < 0) + if ((int)addrlen < 0) { return -TARGET_EINVAL; + } addr = alloca(addrlen+1); @@ -1570,8 +1571,9 @@ static abi_long do_connect(int sockfd, abi_ulong target_addr, void *addr; abi_long ret; - if (addrlen < 0) + if ((int)addrlen < 0) { return -TARGET_EINVAL; + } addr = alloca(addrlen);