[libvirt] [PATCH] esx_vi: remove unreachable code

Jim Meyering jim at meyering.net
Thu Sep 3 14:41:07 UTC 2009


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.



int
esxVI_Enumeration_Deserialize(virConnectPtr conn,
                              const esxVI_Enumeration *enumeration,
                              xmlNodePtr node, int *value)
{
    int i;
    int result = 0;
    char *name = NULL;

    if (value == NULL) {
        ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR, "Invalid argument");
        goto failure;
    }

    *value = 0; /* undefined */

    if (esxVI_String_DeserializeValue(conn, node, &name) < 0) {
        goto failure;
    }

    for (i = 0; enumeration->values[i].name != NULL; ++i) {
        if (STREQ(name, enumeration->values[i].name)) {
            *value = enumeration->values[i].value;
            goto cleanup;
        }
    }

    ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR, "Unknown value '%s' for %s",
                 name, enumeration->type);

  cleanup:
    VIR_FREE(name);

    return result;

  failure:
    goto cleanup;
}




More information about the libvir-list mailing list