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.
+ result = 0;
+
cleanup:
VIR_FREE(connectionType);
VIR_FREE(addressType);
@@ -1891,13 +1898,12 @@ esxVMX_ParseEthernet(virConfPtr conf, int controller,
virDomainNetDefPtr *def)
return result;
- failure:
- result = -1;
-
ignore:
virDomainNetDefFree(*def);
*def = NULL;
+ result = 0;
+
goto cleanup;
And again.
+ result = 0;
+
cleanup:
VIR_FREE(fileType);
VIR_FREE(fileName);
return result;
- failure:
- result = -1;
-
ignore:
virDomainChrDefFree(*def);
*def = NULL;
+ result = 0;
+
goto cleanup;
And again.
+ result = 0;
+
cleanup:
VIR_FREE(fileType);
VIR_FREE(fileName);
return result;
- failure:
- result = -1;
-
ignore:
virDomainChrDefFree(*def);
*def = NULL;
+ result = 0;
+
goto cleanup;
And again.
ACK, once you either figure out whether that idiom was safe, or fix
those four cases.
--
Eric Blake eblake(a)redhat.com +1-801-349-2682
Libvirt virtualization library
http://libvirt.org