Re: [PATCH] esx: Simplify goto usage (part 2/2)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2010/5/27 Eric Blake <eblake@xxxxxxxxxx>:
> On 05/26/2010 10:31 AM, Matthias Bolte wrote:
>> Eliminate almost all backward jumps by replacing this common pattern:
>>
>> ---
>>
>> I've split this 200kb patch into two 100kb parts.
>
> More of the same mechanical changes.
>
>>
>> +    result = 0;
>> +
>>    cleanup:
>>      VIR_FREE(prefix);
>>      VIR_FREE(deviceType);
>> @@ -1666,13 +1672,12 @@ esxVMX_ParseDisk(esxVI_Context *ctx, virConfPtr conf, int device, int bus,
>>
>>      return result;
>>
>> -  failure:
>> -    result = -1;
>> -
>>    ignore:
>>      virDomainDiskDefFree(*def);
>>      *def = NULL;
>>
>> +    result = 0;
>> +
>>      goto cleanup;
>
> This looks fishy - failure used to fall through to ignore, but now you
> lose the virDomainDiskDefFree.

Good catch! I added

   cleanup:
+    if (result < 0) {
+        virDomainDiskDefFree(*def);
+        *def = NULL;
+    }

to preserve the original behavior.

I added the same pattern to all 4 functions containing an ignore label.

>
> ACK, once you either figure out whether that idiom was safe, or fix
> those four cases.
>

Thanks, pushed both parts as one patch.

Matthias

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]