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

From: Phillip Susi <[email-masked]>
Date: Mon, 03 Mar 2014 19:46:21 -0500

On 03/03/2014 03:06 PM, Brian C. Lane wrote:
> 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.

Good point.

>> @@ -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.

Because programmers are notoriously lazy typists ;)

Also at least at some time in the past on certain compilers in C++,
NULL could cause errors where 0 wouldn't so I guess I got into the habit.

I suppose I can change it since I'm making changes anyhow.

>> -        disk = ped_disk_new (*dev); -        if (!disk) +
>> if (*disk == 0)
> 
> No need to use == 0 here.

I suppose !*disk works too, though it's a bit less readable.

>> 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.

I didn't want the diff being larger than needed, but yea, it should be
fixed while I'm in the area.