Subject: bug#16370: [PATCH] parted: don't reload partition table on every command

From: "Brian C. Lane" <[email-masked]>
Date: Mon, 3 Mar 2014 12:06:43 -0800

On Sun, Jan 05, 2014 at 11:03:55PM -0500, Phillip Susi wrote:
>  Command*
>  command_create (const StrList* names,
> -		int (*method) (PedDevice** dev),
> +		int (*method) (PedDevice** dev, PedDisk** disk),

May as well call the argument diskp everywhere to be consistent.

> @@ -1274,11 +1270,15 @@ static int
>  _print_list ()
>  {
>          PedDevice *current_dev = NULL;
> +        PedDisk *disk = 0;

Why do you use 0 instead of NULL? To me seeing a 0 makes me think it is
supposed to have a value whereas NULL makes it clear it is
uninitialized.

> -        disk = ped_disk_new (*dev);
> -        if (!disk)
> +        if (*disk == 0)

No need to use == 0 here.

>  static void
> -_done (PedDevice* dev)
> +_done (PedDevice* dev, PedDisk* disk)
>  {
> +if (disk)
> +        ped_disk_destroy (disk);
>  if (dev->boot_dirty && dev->type != PED_DEVICE_FILE) {
>          ped_exception_throw (
>                  PED_EXCEPTION_WARNING,

Looks like _done could use some indentation fixes, may as well clean it
up while you're changing it.

-- 
Brian C. Lane | Anaconda Team | IRC: bcl #anaconda | Port Orchard, WA (PST8PDT)