Merge all returns paths from dispatcher into single path
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 13 Apr 2011 15:21:35 +0000 (16:21 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Mon, 18 Apr 2011 14:20:33 +0000 (15:20 +0100)
commit158ba8730e44b7dd07a21ab90499996c5dec080a
tree3dae8bf73ec907d5c229e11d3cce813b5f716e71
parent16d6b0d80afabe455f5d00e4a696913c281d0649
Merge all returns paths from dispatcher into single path

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
daemon/dispatch.c
daemon/dispatch.h
daemon/remote.c
daemon/stream.c