[parted-devel] [PATCH 7/8] libparted: do not call _device_get_partition_range() twice
Jim Meyering
jim at meyering.net
Sat Oct 1 07:39:20 UTC 2011
Petr Uzel wrote:
> PED_MIN can evaluate its arguments twice.
>
> * libparted/arch/linux.c (_disk_sync_part_table): Call
> _device_get_partition_range() outside PED_MIN.
> ---
> 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);
> +
That looks fine. I've adjusted the indentation above to
be consistent with the rest of this function.
Thanks.
> /* 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.
More information about the parted-devel
mailing list