WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 6 of 8] tools: libxl: fixup error handling in libxl__

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 6 of 8] tools: libxl: fixup error handling in libxl__build_hvm
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Fri, 13 May 2011 14:42:35 +0100
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Delivery-date: Fri, 13 May 2011 06:50:35 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1305294149@xxxxxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <patchbomb.1305294149@xxxxxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.6.4
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1305294079 -3600
# Node ID e2aa33c8019ebd849f87e3d68350e2d26f42b15d
# Parent  5e7615dbe3008fd25edabb3fda3cb80a76015ed1
tools: libxl: fixup error handling in libxl__build_hvm.

We first pointless initialise rc and immediately overwrite the value, then fail
to return it on error anyway...

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

diff -r 5e7615dbe300 -r e2aa33c8019e tools/libxl/libxl_dom.c
--- a/tools/libxl/libxl_dom.c   Fri May 13 14:41:19 2011 +0100
+++ b/tools/libxl/libxl_dom.c   Fri May 13 14:41:19 2011 +0100
@@ -284,15 +284,17 @@ int libxl__build_hvm(libxl__gc *gc, uint
               libxl__domain_build_state *state)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
-    int ret, rc = ERROR_INVAL;
+    int ret, rc = ERROR_FAIL;
+    const char *firmware = libxl__domain_firmware(gc, info, dm_info);
 
-    rc = ERROR_FAIL;
+    if (!firmware)
+        goto out;
     ret = xc_hvm_build_target_mem(
         ctx->xch,
         domid,
         (info->max_memkb - info->video_memkb) / 1024,
         (info->target_memkb - info->video_memkb) / 1024,
-        libxl__domain_firmware(gc, info, dm_info));
+        firmware);
     if (ret) {
         LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, ret, "hvm building failed");
         goto out;
@@ -305,7 +307,7 @@ int libxl__build_hvm(libxl__gc *gc, uint
     }
     rc = 0;
 out:
-    return 0;
+    return rc;
 }
 
 int libxl__domain_restore_common(libxl__gc *gc, uint32_t domid,

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel