[parted-devel] [PATCH 7/8] libparted: do not call _device_get_partition_range() twice
Petr Uzel
petr.uzel at suse.cz
Wed Sep 28 08:45:08 UTC 2011
PED_MIN can evaluate its arguments twice.
* libparted/arch/linux.c (_disk_sync_part_table): Call
_device_get_partition_range() outside PED_MIN.
Signed-off-by: Petr Uzel <petr.uzel at suse.cz>
---
libparted/arch/linux.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index bc42750..b6f7e0b 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2464,11 +2464,13 @@ _disk_sync_part_table (PedDisk* disk)
PED_ASSERT(disk->dev != NULL);
int lpn;
+ unsigned int part_range = _device_get_partition_range(disk->dev);
+
/* lpn = largest partition number. */
if (ped_disk_get_max_supported_partition_count(disk, &lpn))
- lpn = PED_MIN(lpn, _device_get_partition_range(disk->dev));
+ lpn = PED_MIN(lpn, part_range);
else
- lpn = _device_get_partition_range(disk->dev);
+ lpn = part_range;
/* Its not possible to support largest_partnum < 0.
* largest_partnum == 0 would mean does not support partitions.
--
1.7.3.4
More information about the parted-devel
mailing list