From 2f1f6c9a808987c288e83a1e91a23e5d6243066c Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Fri, 30 Dec 2011 21:03:06 +0100 Subject: [PATCH] gpt: eliminate four PED_ASSERT uses * libparted/labels/gpt.c (_parse_header): Convert a few PED_ASSERT uses to friendlier 'test-and-return-0's. Reported by Graham Markall in http://thread.gmane.org/gmane.comp.gnu.parted.bugs/10653 --- libparted/labels/gpt.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c index 9d464c6..b812c4a 100644 --- a/libparted/labels/gpt.c +++ b/libparted/labels/gpt.c @@ -728,19 +728,18 @@ _parse_header (PedDisk *disk, const GuidPartitionTableHeader_t *gpt, GPT_DEFAULT_PARTITION_ENTRY_ARRAY_SIZE / disk->dev->sector_size; if (last_usable_if_grown > last_usable_min_default) - { - last_usable_if_grown = last_usable_min_default; - } + last_usable_if_grown = last_usable_min_default; - PED_ASSERT (last_usable > first_usable); - PED_ASSERT (last_usable <= disk->dev->length); + if (last_usable <= first_usable + || disk->dev->length < last_usable) + return 0; - PED_ASSERT (last_usable_if_grown > first_usable); - PED_ASSERT (last_usable_if_grown <= disk->dev->length); + if (last_usable_if_grown <= first_usable + || disk->dev->length < last_usable_if_grown) + return 0; if (!asked_already && last_usable < last_usable_if_grown) { - PedExceptionOption q; q = ped_exception_throw -- 2.11.0