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

[Xen-changelog] [xen-unstable] libxc: move error checking next to the fu

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] libxc: move error checking next to the function which returned the error.
From: Xen patchbot-unstable <patchbot@xxxxxxx>
Date: Sun, 13 Mar 2011 07:05:17 +0000
Delivery-date: Sat, 12 Mar 2011 23:06:58 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1299867653 0
# Node ID 9070fc88309b5712d658ee19431f2df7647b8553
# Parent  c355dbc07b36596afef9ae88a1b4cec5360142d3
libxc: move error checking next to the function which returned the error.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Committed-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---


diff -r c355dbc07b36 -r 9070fc88309b tools/libxc/xc_dom_bzimageloader.c
--- a/tools/libxc/xc_dom_bzimageloader.c        Fri Mar 11 18:18:18 2011 +0000
+++ b/tools/libxc/xc_dom_bzimageloader.c        Fri Mar 11 18:20:53 2011 +0000
@@ -142,8 +142,9 @@
 
 static int _xc_try_lzma_decode(
     struct xc_dom_image *dom, void **blob, size_t *size,
-    lzma_stream *stream, lzma_ret ret, const char *what)
+    lzma_stream *stream, const char *what)
 {
+    lzma_ret ret;
     lzma_action action = LZMA_RUN;
     unsigned char *out_buf;
     unsigned char *tmp_buf;
@@ -151,12 +152,6 @@
     int outsize;
     const char *msg;
 
-    if ( ret != LZMA_OK )
-    {
-        DOMPRINTF("%s: Failed to init decoder", what);
-        return -1;
-    }
-
     /* sigh.  We don't know up-front how much memory we are going to need
      * for the output buffer.  Allocate the output buffer to be equal
      * the input buffer to start, and we'll realloc as needed.
@@ -259,18 +254,28 @@
     struct xc_dom_image *dom, void **blob, size_t *size)
 {
     lzma_stream stream = LZMA_STREAM_INIT;
-    lzma_ret ret = lzma_stream_decoder(&stream, LZMA_BLOCK_SIZE, 0);
 
-    return _xc_try_lzma_decode(dom, blob, size, &stream, ret, "XZ");
+    if ( lzma_stream_decoder(&stream, LZMA_BLOCK_SIZE, 0) != LZMA_OK )
+    {
+        DOMPRINTF("XZ: Failed to init decoder");
+        return -1;
+    }
+
+    return _xc_try_lzma_decode(dom, blob, size, &stream, "XZ");
 }
 
 static int xc_try_lzma_decode(
     struct xc_dom_image *dom, void **blob, size_t *size)
 {
     lzma_stream stream = LZMA_STREAM_INIT;
-    lzma_ret ret = lzma_alone_decoder(&stream, LZMA_BLOCK_SIZE);
 
-    return _xc_try_lzma_decode(dom, blob, size, &stream, ret, "LZMA");
+    if ( lzma_alone_decoder(&stream, LZMA_BLOCK_SIZE) != LZMA_OK )
+    {
+        DOMPRINTF("LZMA: Failed to init decoder");
+        return -1;
+    }
+
+    return _xc_try_lzma_decode(dom, blob, size, &stream, "LZMA");
 }
 
 #else /* !defined(HAVE_LZMA) */

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

<Prev in Thread] Current Thread [Next in Thread>