From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:40082) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sn2Uf-00037Y-N5 for qemu-devel@nongnu.org; Fri, 06 Jul 2012 02:58:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sn2Ub-0003Lc-8R for qemu-devel@nongnu.org; Fri, 06 Jul 2012 02:58:21 -0400 Received: from oxygen.pond.sub.org ([78.46.104.156]:50601) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sn2Ub-0003Ko-28 for qemu-devel@nongnu.org; Fri, 06 Jul 2012 02:58:17 -0400 From: Markus Armbruster Date: Fri, 6 Jul 2012 08:57:50 +0200 Message-Id: <1341557890-17464-13-git-send-email-armbru@redhat.com> In-Reply-To: <1341557890-17464-1-git-send-email-armbru@redhat.com> References: <1341557890-17464-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PATCH 12/32] hd-geometry: Clean up gratuitous goto in hd_geometry_guess() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, blauwirbel@gmail.com, stefanha@linux.vnet.ibm.com, pbonzini@redhat.com Signed-off-by: Markus Armbruster --- hw/hd-geometry.c | 22 ++++++++-------------- 1 files changed, 8 insertions(+), 14 deletions(-) diff --git a/hw/hd-geometry.c b/hw/hd-geometry.c index 1a58894..fb849a3 100644 --- a/hw/hd-geometry.c +++ b/hw/hd-geometry.c @@ -119,8 +119,7 @@ static void guess_chs_for_size(BlockDriverState *bs, void hd_geometry_guess(BlockDriverState *bs, int *pcyls, int *pheads, int *psecs) { - int translation, lba_detected = 0; - int cylinders, heads, secs; + int cylinders, heads, secs, translation; bdrv_get_geometry_hint(bs, &cylinders, &heads, &secs); translation = bdrv_get_translation_hint(bs); @@ -135,23 +134,18 @@ void hd_geometry_guess(BlockDriverState *bs, if (guess_disk_lchs(bs, &cylinders, &heads, &secs) < 0) { /* no LCHS guess: use a standard physical disk geometry */ - default_geometry: guess_chs_for_size(bs, pcyls, pheads, psecs); - if ((lba_detected == 1) && (translation == BIOS_ATA_TRANSLATION_AUTO)) { - if ((*pcyls * *pheads) <= 131072) { - bdrv_set_translation_hint(bs, - BIOS_ATA_TRANSLATION_LARGE); - } else { - bdrv_set_translation_hint(bs, - BIOS_ATA_TRANSLATION_LBA); - } - } } else if (heads > 16) { /* LCHS guess with heads > 16 means that a BIOS LBA translation was active, so a standard physical disk geometry is OK */ - lba_detected = 1; - goto default_geometry; + guess_chs_for_size(bs, pcyls, pheads, psecs); + if (translation == BIOS_ATA_TRANSLATION_AUTO) { + bdrv_set_translation_hint(bs, + *pcyls * *pheads <= 131072 + ? BIOS_ATA_TRANSLATION_LARGE + : BIOS_ATA_TRANSLATION_LBA); + } } else { /* LCHS guess with heads <= 16: use as physical geometry */ *pcyls = cylinders; -- 1.7.6.5