From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1J0EQP-0007Wq-Dw for qemu-devel@nongnu.org; Thu, 06 Dec 2007 05:57:49 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1J0EQN-0007We-Lh for qemu-devel@nongnu.org; Thu, 06 Dec 2007 05:57:49 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1J0EQN-0007Wb-I1 for qemu-devel@nongnu.org; Thu, 06 Dec 2007 05:57:47 -0500 Received: from outbound-blu.frontbridge.com ([65.55.251.16] helo=outbound9-blu-R.bigfish.com) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1J0EQN-0003gi-4D for qemu-devel@nongnu.org; Thu, 06 Dec 2007 05:57:47 -0500 Received: from outbound9-blu.bigfish.com (localhost.localdomain [127.0.0.1]) by outbound9-blu-R.bigfish.com (Postfix) with ESMTP id 61216D0AC8B for ; Thu, 6 Dec 2007 10:57:46 +0000 (UTC) Received: from mail130-blu-R.bigfish.com (unknown [10.1.252.3]) by outbound9-blu.bigfish.com (Postfix) with ESMTP id 5425F17E004D for ; Thu, 6 Dec 2007 10:57:46 +0000 (UTC) Received: from mail130-blu (localhost.localdomain [127.0.0.1]) by mail130-blu-R.bigfish.com (Postfix) with ESMTP id E1EDA34850E for ; Thu, 6 Dec 2007 10:57:45 +0000 (UTC) Received: from ausb3extmailp02.amd.com (rebel3.amd.com [163.181.251.22]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail130-blu.bigfish.com (Postfix) with ESMTP id 67B2B8B0046 for ; Thu, 6 Dec 2007 10:57:45 +0000 (UTC) Received: from SAUSGW02.amd.com (sausgw02.amd.com [163.181.250.22]) by ausb3extmailp02.amd.com (Switch-3.2.7/Switch-3.2.7) with ESMTP id lB6AsFH3022787 for ; Thu, 6 Dec 2007 04:54:35 -0600 Message-ID: <4757D4AD.2010309@amd.com> Date: Thu, 06 Dec 2007 11:53:33 +0100 From: "Andre Przywara" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary=------------080407050806040209050402 Subject: [Qemu-devel] [PATCH 4/5] gcc4 warnings: fix bdrv_get_geometry to return uint64_t Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is a multi-part message in MIME format. --------------080407050806040209050402 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: 7bit bdrv_get_geometry never returns a negative number, so I changed the return type to unsigned, changes quite a lot of declarations. -- Andre Przywara AMD-Operating System Research Center (OSRC), Dresden, Germany Tel: +49 351 277-84917 ----to satisfy European Law for business letters: AMD Saxony Limited Liability Company & Co. KG, Wilschdorfer Landstr. 101, 01109 Dresden, Germany Register Court Dresden: HRA 4896, General Partner authorized to represent: AMD Saxony LLC (Wilmington, Delaware, US) General Manager of AMD Saxony LLC: Dr. Hans-R. Deppe, Thomas McCoy --------------080407050806040209050402 Content-Type: text/plain; name=nb_sectors.diff Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename=nb_sectors.diff Index: block.c =================================================================== RCS file: /sources/qemu/qemu/block.c,v retrieving revision 1.50 diff -p -u -r1.50 block.c --- block.c 2 Dec 2007 05:18:18 -0000 1.50 +++ block.c 5 Dec 2007 23:38:57 -0000 @@ -717,7 +717,7 @@ int64_t bdrv_getlength(BlockDriverState } /* return 0 as number of sectors if no device present or error */ -void bdrv_get_geometry(BlockDriverState *bs, int64_t *nb_sectors_ptr) +void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr) { int64_t length; length = bdrv_getlength(bs); Index: block.h =================================================================== RCS file: /sources/qemu/qemu/block.h,v retrieving revision 1.3 diff -p -u -r1.3 block.h --- block.h 2 Dec 2007 05:18:18 -0000 1.3 +++ block.h 5 Dec 2007 23:38:57 -0000 @@ -72,7 +72,7 @@ int bdrv_pwrite(BlockDriverState *bs, in const void *buf, int count); int bdrv_truncate(BlockDriverState *bs, int64_t offset); int64_t bdrv_getlength(BlockDriverState *bs); -void bdrv_get_geometry(BlockDriverState *bs, int64_t *nb_sectors_ptr); +void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr); int bdrv_commit(BlockDriverState *bs); void bdrv_set_boot_sector(BlockDriverState *bs, const uint8_t *data, int size); /* async block I/O */ Index: hw/fdc.c =================================================================== RCS file: /sources/qemu/qemu/hw/fdc.c,v retrieving revision 1.33 diff -p -u -r1.33 fdc.c --- hw/fdc.c 17 Nov 2007 17:14:41 -0000 1.33 +++ hw/fdc.c 5 Dec 2007 23:38:57 -0000 @@ -234,7 +234,7 @@ static const fd_format_t fd_formats[] = static void fd_revalidate (fdrive_t *drv) { const fd_format_t *parse; - int64_t nb_sectors, size; + uint64_t nb_sectors, size; int i, first_match, match; int nb_heads, max_track, last_sect, ro; Index: hw/ide.c =================================================================== RCS file: /sources/qemu/qemu/hw/ide.c,v retrieving revision 1.72 diff -p -u -r1.72 ide.c --- hw/ide.c 18 Nov 2007 01:44:37 -0000 1.72 +++ hw/ide.c 5 Dec 2007 23:38:57 -0000 @@ -1465,12 +1464,12 @@ static void ide_atapi_cmd(IDEState *s) break; case GPCMD_SEEK: { - int lba; - int64_t total_sectors; + unsigned int lba; + uint64_t total_sectors; bdrv_get_geometry(s->bs, &total_sectors); total_sectors >>= 2; - if (total_sectors <= 0) { + if (total_sectors == 0) { ide_atapi_cmd_error(s, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT); break; @@ -1516,11 +1515,11 @@ static void ide_atapi_cmd(IDEState *s) case GPCMD_READ_TOC_PMA_ATIP: { int format, msf, start_track, len; - int64_t total_sectors; + uint64_t total_sectors; bdrv_get_geometry(s->bs, &total_sectors); total_sectors >>= 2; - if (total_sectors <= 0) { + if (total_sectors == 0) { ide_atapi_cmd_error(s, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT); break; @@ -1560,11 +1559,11 @@ static void ide_atapi_cmd(IDEState *s) break; case GPCMD_READ_CDVD_CAPACITY: { - int64_t total_sectors; + uint64_t total_sectors; bdrv_get_geometry(s->bs, &total_sectors); total_sectors >>= 2; - if (total_sectors <= 0) { + if (total_sectors == 0) { ide_atapi_cmd_error(s, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT); break; @@ -1580,7 +1579,7 @@ static void ide_atapi_cmd(IDEState *s) int media = packet[1]; int layer = packet[6]; int format = packet[2]; - int64_t total_sectors; + uint64_t total_sectors; if (media != 0 || layer != 0) { @@ -1592,6 +1591,11 @@ static void ide_atapi_cmd(IDEState *s) case 0: bdrv_get_geometry(s->bs, &total_sectors); total_sectors >>= 2; + if (total_sectors == 0) { + ide_atapi_cmd_error(s, SENSE_NOT_READY, + ASC_MEDIUM_NOT_PRESENT); + break; + } memset(buf, 0, 2052); @@ -1636,7 +1640,7 @@ static void ide_atapi_cmd(IDEState *s) break; case GPCMD_GET_CONFIGURATION: { - int64_t total_sectors; + uint64_t total_sectors; /* only feature 0 is supported */ if (packet[2] != 0 || packet[3] != 0) { @@ -1721,7 +1725,7 @@ static void ide_cfata_metadata_write(IDE static void cdrom_change_cb(void *opaque) { IDEState *s = opaque; - int64_t nb_sectors; + uint64_t nb_sectors; /* XXX: send interrupt too */ bdrv_get_geometry(s->bs, &nb_sectors); @@ -2416,7 +2420,7 @@ static void ide_init2(IDEState *ide_stat IDEState *s; static int drive_serial = 1; int i, cylinders, heads, secs, translation, lba_detected = 0; - int64_t nb_sectors; + uint64_t nb_sectors; for(i = 0; i < 2; i++) { s = ide_state + i; Index: hw/scsi-disk.c =================================================================== RCS file: /sources/qemu/qemu/hw/scsi-disk.c,v retrieving revision 1.16 diff -p -u -r1.16 scsi-disk.c --- hw/scsi-disk.c 17 Nov 2007 17:14:47 -0000 1.16 +++ hw/scsi-disk.c 5 Dec 2007 23:38:58 -0000 @@ -278,7 +278,7 @@ uint8_t *scsi_get_buf(SCSIDevice *s, uin int32_t scsi_send_command(SCSIDevice *s, uint32_t tag, uint8_t *buf, int lun) { - int64_t nb_sectors; + uint64_t nb_sectors; uint32_t lba; uint32_t len; int cmdlen; Index: qemu-img.c =================================================================== RCS file: /sources/qemu/qemu/qemu-img.c,v retrieving revision 1.25 diff -p -u -r1.25 qemu-img.c --- qemu-img.c 11 Nov 2007 03:33:13 -0000 1.25 +++ qemu-img.c 5 Dec 2007 23:38:57 -0000 @@ -235,7 +235,7 @@ static int img_create(int argc, char **a const char *fmt = "raw"; const char *filename; const char *base_filename = NULL; - int64_t size; + uint64_t size; const char *p; BlockDriver *drv; @@ -300,7 +300,7 @@ static int img_create(int argc, char **a printf(", backing_file=%s", base_filename); } - printf(", size=%" PRId64 " kB\n", (int64_t) (size / 1024)); + printf(", size=%" PRIu64 " kB\n", size / 1024); ret = bdrv_create(drv, filename, size / 512, base_filename, flags); if (ret < 0) { if (ret == -ENOTSUP) { @@ -410,7 +410,8 @@ static int img_convert(int argc, char ** const char *fmt, *out_fmt, *out_filename; BlockDriver *drv; BlockDriverState **bs, *out_bs; - int64_t total_sectors, nb_sectors, sector_num, bs_offset, bs_sectors; + int64_t total_sectors, nb_sectors, sector_num, bs_offset; + uint64_t bs_sectors; uint8_t buf[IO_BUF_SIZE]; const uint8_t *buf1; BlockDriverInfo bdi; @@ -655,7 +656,8 @@ static int img_info(int argc, char **arg BlockDriver *drv; BlockDriverState *bs; char fmt_name[128], size_buf[128], dsize_buf[128]; - int64_t total_sectors, allocated_size; + uint64_t total_sectors; + int64_t allocated_size; char backing_filename[1024]; char backing_filename2[1024]; BlockDriverInfo bdi; --------------080407050806040209050402--