[libvirt] [PATCHv2 10/10] build: silence coverity false positive

Daniel Veillard veillard at redhat.com
Fri Jun 3 04:34:44 UTC 2011


On Thu, Jun 02, 2011 at 05:24:25PM -0600, Eric Blake wrote:
> Coverity couldn't see that priv is clean on failure.  But on failure,
> we might as well guarantee that callers don't try to free uninitialized
> memory.
> 
> * src/remote/remote_driver.c (remoteGenericOpen): Even on failure,
> pass priv back to caller.
> ---
> 
> In reading my own mail, I decided that patch 10 can be made simpler.
> 
> v2: rewrite to avoid sa_assert and be more robust.
> 
>  src/remote/remote_driver.c |    6 ++----
>  1 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
> index 14c3d24..8335a1a 100644
> --- a/src/remote/remote_driver.c
> +++ b/src/remote/remote_driver.c
> @@ -2545,10 +2545,8 @@ remoteGenericOpen(virConnectPtr conn, virConnectAuthPtr auth,
>           * use the UNIX transport. This handles Xen driver
>           * which doesn't have its own impl of the network APIs. */
>          struct private_data *priv;
> -        int ret;
> -        ret = remoteOpenSecondaryDriver(conn, auth, flags, &priv);
> -        if (ret == VIR_DRV_OPEN_SUCCESS)
> -            *genericPrivateData = priv;
> +        int ret = remoteOpenSecondaryDriver(conn, auth, flags, &priv);
> +        *genericPrivateData = priv;
>          return ret;
>      }
>  }

  I really prefer the second version, ACK

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel at veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/




More information about the libvir-list mailing list