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

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



2010/5/27 Eric Blake <eblake redhat com>:
> 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


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