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 1/9] Decompressors: get rid of set_error_fn() macro

To: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH 1/9] Decompressors: get rid of set_error_fn() macro
From: "Jan Beulich" <JBeulich@xxxxxxxx>
Date: Fri, 11 Nov 2011 11:26:26 +0000
Cc: lasse.collin@xxxxxxxxxxx
Delivery-date: Fri, 11 Nov 2011 03:27:28 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
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>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
From: Lasse Collin <lasse.collin@xxxxxxxxxxx>

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@xxxxxxxxxxx>
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

--- a/xen/common/decompress.h
+++ b/xen/common/decompress.h
@@ -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
 
--- a/xen/common/bunzip2.c
+++ b/xen/common/bunzip2.c
@@ -666,13 +666,12 @@ STATIC int INIT bunzip2(unsigned char *b
                        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);
 
--- a/xen/common/unlzma.c
+++ b/xen/common/unlzma.c
@@ -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 *bu
                       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 *bu
        unsigned char *inbuf;
        int ret = -1;
 
-       set_error_fn(error_fn);
+       rc.error = error;
 
        if (buf)
                inbuf = buf;
--- a/xen/common/unlzo.c
+++ b/xen/common/unlzo.c
@@ -105,7 +105,7 @@ STATIC int INIT unlzo(u8 *input, unsigne
                      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, unsigne
        u8 *in_buf, *in_buf_save, *out_buf;
        int ret = -1;
 
-       set_error_fn(error_fn);
-
        if (output) {
                out_buf = output;
        } else if (!flush) {
--- a/xen/common/unxz.c
+++ b/xen/common/unxz.c
@@ -161,15 +161,13 @@ STATIC int INIT unxz(unsigned char *in, 
                     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)



Attachment: decompress-no-error-fn.patch
Description: Text document

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH 1/9] Decompressors: get rid of set_error_fn() macro, Jan Beulich <=