aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxc/xc_dom_bzimageloader.c
diff options
context:
space:
mode:
authorIan Campbell <ian.campbell@citrix.com>2011-03-11 18:20:53 +0000
committerIan Campbell <ian.campbell@citrix.com>2011-03-11 18:20:53 +0000
commit96a312ead28be5d398f267671fa01c4babcb7f4d (patch)
tree5a6b649f5db435625f486e2121d9d173709296af /tools/libxc/xc_dom_bzimageloader.c
parent44baceec2d35beb902ddf909d667f2329576381f (diff)
downloadxen-96a312ead28be5d398f267671fa01c4babcb7f4d.tar.gz
xen-96a312ead28be5d398f267671fa01c4babcb7f4d.tar.bz2
xen-96a312ead28be5d398f267671fa01c4babcb7f4d.zip
libxc: move error checking next to the function which returned the error.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
Diffstat (limited to 'tools/libxc/xc_dom_bzimageloader.c')
-rw-r--r--tools/libxc/xc_dom_bzimageloader.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/tools/libxc/xc_dom_bzimageloader.c b/tools/libxc/xc_dom_bzimageloader.c
index 8559e4c1a9..9a755eb62a 100644
--- a/tools/libxc/xc_dom_bzimageloader.c
+++ b/tools/libxc/xc_dom_bzimageloader.c
@@ -142,8 +142,9 @@ static int xc_try_bzip2_decode(
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 @@ static int _xc_try_lzma_decode(
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 @@ static int xc_try_xz_decode(
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) */