[libvirt] [PATCH 5/9] rpc: Add coverity[dead_error_begin] tag

Eric Blake eblake at redhat.com
Tue Jan 22 16:39:29 UTC 2013


On 01/22/2013 07:41 AM, John Ferlan wrote:
> Coverity misses the nuance of VIR_FREE(privkey) setting privkey = NULL when
> if (!(virFileExists(privkey))) is true and thus declares the code dead.
> ---
>  src/rpc/virnetclient.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
> index 44638e2..7550968 100644
> --- a/src/rpc/virnetclient.c
> +++ b/src/rpc/virnetclient.c
> @@ -430,6 +430,7 @@ virNetClientPtr virNetClientNewLibSSH2(const char *host,
>                  VIR_FREE(privkey);
>              /* DSA */
>              if (!privkey) {
> +                /* coverity[dead_error_begin] */

I think a LOT of these cleanups would have been easier to evaluate if we
had seen the actual Coverity trace that was being silenced.

For this particular code, avoiding the Coverity comment may be as simple
as reindenting things, turning the old:

if (!(virFileExists(privkey)))
    VIR_FREE(privkey);
if (!privkey) {
    privkey = ...
    ...
}

into:

if (!virFileExists(privkey)) {
    VIR_FREE(privkey);
    privkey = ...
    ...
}

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130122/e8eb6f65/attachment-0001.sig>


More information about the libvir-list mailing list