[libvirt] [PATCH] esx_vi: remove unreachable code

Matthias Bolte matthias.bolte at googlemail.com
Thu Sep 3 14:51:47 UTC 2009


2009/9/3 Jim Meyering <jim at meyering.net>:
> This removes dead code and suppresses a warning from clang.
> However, see below:
>
> >From 2ed548cbe948aa7ef37ccd121bd084bd05019ac8 Mon Sep 17 00:00:00 2001
> From: Jim Meyering <meyering at redhat.com>
> Date: Thu, 3 Sep 2009 16:35:47 +0200
> Subject: [PATCH] esx_vi: remove unreachable code
>
> * src/esx/esx_vi.c (esxVI_Enumeration_Deserialize): Remove
> unreachable code.
> ---
>  src/esx/esx_vi.c |    2 --
>  1 files changed, 0 insertions(+), 2 deletions(-)
>
> diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
> index 0da908b..c689a7a 100644
> --- a/src/esx/esx_vi.c
> +++ b/src/esx/esx_vi.c
> @@ -857,8 +857,6 @@ esxVI_Enumeration_Deserialize(virConnectPtr conn,
>
>   failure:
>     goto cleanup;
> -
> -    result = -1;
>  }
>
> --------------------------------------------
>
> This function does not allow the caller to distinguish
> via its return value whether it has failed.
> It always returns 0.
>
> I see that this function's return value is used in numerous places
> (each esxVI_.*Deserialize function), so this should be fixed.
>

Oops, however that happened... good find. The clang analyzer seems to
be a valuable tool.

The fix for this is to swap "goto cleanup;" and "result = -1;" (see
attached patch).

Matthias
-------------- next part --------------
A non-text attachment was scrubbed...
Name: esx_fix_failure_case_of_esxVI_Enumeration_Deserialize.patch
Type: application/mbox
Size: 296 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20090903/6727491a/attachment-0001.mbox>


More information about the libvir-list mailing list