Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JHLh5-0005UH-He for qemu-devel@nongnu.org; Tue, 22 Jan 2008 11:09:47 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JHLh3-0005Sb-OA for qemu-devel@nongnu.org; Tue, 22 Jan 2008 11:09:46 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JHLh3-0005SO-2l for qemu-devel@nongnu.org; Tue, 22 Jan 2008 11:09:45 -0500 Received: from province.act-europe.fr ([212.99.106.214]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JHLh2-0008Px-8o for qemu-devel@nongnu.org; Tue, 22 Jan 2008 11:09:44 -0500 Received: from localhost (localhost [127.0.0.1]) by filtered-province.act-europe.fr (Postfix) with ESMTP id CF717165D17 for ; Tue, 22 Jan 2008 17:09:22 +0100 (CET) Received: from province.act-europe.fr ([127.0.0.1]) by localhost (province.act-europe.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6v+BWn4Tn47Y for ; Tue, 22 Jan 2008 17:09:22 +0100 (CET) Received: from [10.10.127.242] (dhcp-guest-242.act-europe.fr [10.10.127.242]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by province.act-europe.fr (Postfix) with ESMTP id A0985165712 for ; Tue, 22 Jan 2008 17:09:22 +0100 (CET) Mime-Version: 1.0 (Apple Message framework v753) Message-Id: Content-Type: multipart/mixed; boundary=Apple-Mail-6--627008344 From: Tristan Gingold Date: Tue, 22 Jan 2008 17:14:50 +0100 Subject: [Qemu-devel] PATCH: minor simplification in ide.c 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 --Apple-Mail-6--627008344 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Hi, there is no need to alloc and free a buffer in guess_disk_lchs. io_buffer can be used instead. This slightly simplify the code. --Apple-Mail-6--627008344 Content-Transfer-Encoding: 7bit Content-Type: application/octet-stream; x-unix-mode=0644; name=ide.diff Content-Disposition: attachment; filename=ide.diff Index: hw/ide.c =================================================================== RCS file: /sources/qemu/qemu/hw/ide.c,v retrieving revision 1.81 diff -c -r1.81 ide.c *** hw/ide.c 14 Jan 2008 03:15:20 -0000 1.81 --- hw/ide.c 22 Jan 2008 16:04:39 -0000 *************** *** 2474,2495 **** static int guess_disk_lchs(IDEState *s, int *pcylinders, int *pheads, int *psectors) { ! uint8_t *buf; int ret, i, heads, sectors, cylinders; struct partition *p; uint32_t nr_sects; - buf = qemu_memalign(512, 512); - if (buf == NULL) - return -1; ret = bdrv_read(s->bs, 0, buf, 1); if (ret < 0) { - qemu_free(buf); return -1; } /* test msdos magic */ if (buf[510] != 0x55 || buf[511] != 0xaa) { - qemu_free(buf); return -1; } for(i = 0; i < 4; i++) { --- 2474,2490 ---- static int guess_disk_lchs(IDEState *s, int *pcylinders, int *pheads, int *psectors) { ! uint8_t *buf = s->io_buffer; int ret, i, heads, sectors, cylinders; struct partition *p; uint32_t nr_sects; ret = bdrv_read(s->bs, 0, buf, 1); if (ret < 0) { return -1; } /* test msdos magic */ if (buf[510] != 0x55 || buf[511] != 0xaa) { return -1; } for(i = 0; i < 4; i++) { *************** *** 2512,2522 **** printf("guessed geometry: LCHS=%d %d %d\n", cylinders, heads, sectors); #endif - qemu_free(buf); return 0; } } - qemu_free(buf); return -1; } --- 2507,2515 ---- --Apple-Mail-6--627008344--