
On 04/13/2011 12:12 PM, Daniel P. Berrange wrote:
The dispatcher functions have numerous places where they return to the caller. This leads to duplicated cleanup code, often resulting in memory leaks. It makes it harder to ensure that errors are dispatched before freeing objects, which may overwrite the original error.
The standard pattern is now
remoteDispatchXXX(...) { int rv = -1;
.... if (XXX < 0) goto cleanup; ... if (XXXX < 0) goto cleanup; ...
rv = 0; cleanup: if (rv < 0) remoteDispatchError(rerr); ...free all other stuff.. return rv; }
* daemon/remote.c: Centralize all cleanup paths * daemon/stream.c: s/remoteDispatchConnError/remoteDispatchError/ * daemon/dispatch.c, daemon/dispatch.h: Replace remoteDispatchConnError with remoteDispatchError removing unused virConnectPtr
Sounds good.
NB this was a tedious manual conversion of the code, so it has potential for errors....
Indeed - so I'll be looking at it closely; just getting this email out now to avoid anyone else spending duplicate time on it. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org