[libvirt] [PATCH] xm_internal.c: remove misleading dead code

Jim Meyering jim at meyering.net
Mon Dec 14 20:40:59 UTC 2009


This code triggered a warning about possible NULL-dereference.
Actually it's more about being self-contradictory, since
the NULL-dereference is not possible.

>From 796e3a3254cb08fc20bce790997b5787dab51902 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering at redhat.com>
Date: Mon, 14 Dec 2009 21:37:54 +0100
Subject: [PATCH] xm_internal.c: remove misleading dead code

* src/xen/xm_internal.c (xenXMConfigGetULong): Remove useless and
misleading test (always false) for val->str == NULL before code that
always dereferences val->str.  "val" comes from virConfGetValue, and
at that point, val->str is guaranteed to be non-NULL.
(xenXMConfigGetBool): Likewise.
---
 src/xen/xm_internal.c |    6 ------
 1 files changed, 0 insertions(+), 6 deletions(-)

diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
index 3dc655b..944d5d5 100644
--- a/src/xen/xm_internal.c
+++ b/src/xen/xm_internal.c
@@ -152,9 +152,6 @@ static int xenXMConfigGetBool(virConnectPtr conn,
     if (val->type == VIR_CONF_LONG) {
         *value = val->l ? 1 : 0;
     } else if (val->type == VIR_CONF_STRING) {
-        if (!val->str) {
-            *value = def;
-        }
         *value = STREQ(val->str, "1") ? 1 : 0;
     } else {
         xenXMError(conn, VIR_ERR_INTERNAL_ERROR,
@@ -183,9 +180,6 @@ static int xenXMConfigGetULong(virConnectPtr conn,
         *value = val->l;
     } else if (val->type == VIR_CONF_STRING) {
         char *ret;
-        if (!val->str) {
-            *value = def;
-        }
         *value = strtol(val->str, &ret, 10);
         if (ret == val->str) {
             xenXMError(conn, VIR_ERR_INTERNAL_ERROR,
--
1.6.6.rc2.275.g51e2d




More information about the libvir-list mailing list