[libvirt] [PATCH] esx_vi: remove unreachable code

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

 



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@xxxxxxxxxx>
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;
}

--
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]