Re: [libvirt] [PATCH] esx_vi: remove unreachable code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Matthias Bolte wrote:
> 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
>
> diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
> index 724e945..0919774 100644
> --- a/src/esx/esx_vi.c
> +++ b/src/esx/esx_vi.c
> @@ -764,9 +764,9 @@ esxVI_Enumeration_Deserialize(virConnectPtr conn,
>      return result;
>
>    failure:
> -    goto cleanup;
> -
>      result = -1;
> +
> +    goto cleanup;
>  }

Of course!  I should have seen that.
Here's the corrected patch:

>From b29fab8d6a8eece3ecea14b5cfa598d3b90b14e3 Mon Sep 17 00:00:00 2001
From: Matthias Bolte <matthias.bolte@xxxxxxxxxxxxxx>
Date: Thu, 3 Sep 2009 16:35:47 +0200
Subject: [PATCH] esx_vi: return -1 upon failure, as intended

* src/esx/esx_vi.c (esxVI_Enumeration_Deserialize): Fix
reversed goto and result=-1 statements.
---
 src/esx/esx_vi.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index 0da908b..10dd7fd 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -856,9 +856,8 @@ esxVI_Enumeration_Deserialize(virConnectPtr conn,
     return result;

   failure:
-    goto cleanup;
-
     result = -1;
+    goto cleanup;
 }


--
1.6.4.2.395.ge3d52

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]