]> xenbits.xensource.com Git - xen.git/commitdiff
Decompressors: get rid of set_error_fn() macro
authorLasse Collin <lasse.collin@tukaani.org>
Fri, 11 Nov 2011 13:29:21 +0000 (14:29 +0100)
committerLasse Collin <lasse.collin@tukaani.org>
Fri, 11 Nov 2011 13:29:21 +0000 (14:29 +0100)
From: Lasse Collin <lasse.collin@tukaani.org>

set_error_fn() is a useless complication. Only unlzma.c had some use
for it and that was easy to change too.

This also gets rid of the static function pointer "error".

Signed-off-by: Lasse Collin <lasse.collin@tukaani.org>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
Committed-by: Jan Beulich <jbeulich@suse.com>
xen/common/bunzip2.c
xen/common/decompress.h
xen/common/unlzma.c
xen/common/unlzo.c
xen/common/unxz.c

index 9d3cc18e44b0c0df2960147ef57b760da91997f0..eaf920231aabc754109ce2912ac247c49c6a88f4 100644 (file)
@@ -666,13 +666,12 @@ STATIC int INIT bunzip2(unsigned char *buf, unsigned int len,
                        int(*flush)(void*, unsigned int),
                        unsigned char *outbuf,
                        unsigned int *pos,
-                       void(*error_fn)(const char *x))
+                       void(*error)(const char *x))
 {
        struct bunzip_data *bd;
        int i = -1;
        unsigned char *inbuf;
 
-       set_error_fn(error_fn);
        if (flush)
                outbuf = malloc(BZIP2_IOBUF_SIZE);
 
index f329770749473fe132ff8a3c4ed4495cb707d04d..bd62b5dc748d24cf38a3f4a96b3c07725aa171f7 100644 (file)
@@ -10,9 +10,6 @@
 #define INIT __init
 #define INITDATA __initdata
 
-static void(*__initdata error)(const char *);
-#define set_error_fn(x) error = x;
-
 #define malloc xmalloc_bytes
 #define free xfree
 
index bf772d06e81e898e368ddd9c7a333c12d6ed6247..689b72a66231c33041afc0417e0c97f7e4c84aa1 100644 (file)
@@ -67,6 +67,7 @@ struct rc {
        uint32_t code;
        uint32_t range;
        uint32_t bound;
+       void (*error)(const char *);
 };
 
 
@@ -85,7 +86,7 @@ static void INIT rc_read(struct rc *rc)
 {
        rc->buffer_size = rc->fill((char *)rc->buffer, LZMA_IOBUF_SIZE);
        if (rc->buffer_size <= 0)
-               error("unexpected EOF");
+               rc->error("unexpected EOF");
        rc->ptr = rc->buffer;
        rc->buffer_end = rc->buffer + rc->buffer_size;
 }
@@ -529,7 +530,7 @@ STATIC int INIT unlzma(unsigned char *buf, unsigned int in_len,
                       int(*flush)(void*, unsigned int),
                       unsigned char *output,
                       unsigned int *posp,
-                      void(*error_fn)(const char *x)
+                      void(*error)(const char *x)
        )
 {
        struct lzma_header header;
@@ -545,7 +546,7 @@ STATIC int INIT unlzma(unsigned char *buf, unsigned int in_len,
        unsigned char *inbuf;
        int ret = -1;
 
-       set_error_fn(error_fn);
+       rc.error = error;
 
        if (buf)
                inbuf = buf;
index 70910a8b7077a53caf3fc21763d8d1aa90b6f5c8..08117e244e0ff3818338a4d7166644db6a0273bc 100644 (file)
@@ -105,7 +105,7 @@ STATIC int INIT unlzo(u8 *input, unsigned int in_len,
                      int (*fill) (void *, unsigned int),
                      int (*flush) (void *, unsigned int),
                      u8 *output, unsigned int *posp,
-                     void (*error_fn) (const char *x))
+                     void (*error) (const char *x))
 {
        u8 skip = 0, r = 0;
        u32 src_len, dst_len;
@@ -113,8 +113,6 @@ STATIC int INIT unlzo(u8 *input, unsigned int in_len,
        u8 *in_buf, *in_buf_save, *out_buf;
        int ret = -1;
 
-       set_error_fn(error_fn);
-
        if (output) {
                out_buf = output;
        } else if (!flush) {
index 132168f9240553c942131b93f220d938fdc547b1..cf25c9fc8ed00d1000653ec22a873653996aa7da 100644 (file)
@@ -161,15 +161,13 @@ STATIC int INIT unxz(unsigned char *in, unsigned int in_size,
                     int (*fill)(void *dest, unsigned int size),
                     int (*flush)(void *src, unsigned int size),
                     unsigned char *out, unsigned int *in_used,
-                    void (*error_fn)(const char *x))
+                    void (*error)(const char *x))
 {
        struct xz_buf b;
        struct xz_dec *s;
        enum xz_ret ret;
        bool_t must_free_in = false;
 
-       set_error_fn(error_fn);
-
        xz_crc32_init();
 
        if (in_used != NULL)