aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2011-01-12 17:01:14 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2011-01-13 08:03:23 -0800
commit93685ad247ef65b7d6f90ffe97b44f5cfeaf40d3 (patch)
tree979868b5a03a7e73c792e222646a1876b3dc0216 /lib
parent6b01ed64c19b52121a717274d271d9915f8d3e94 (diff)
Decompressors: get rid of set_error_fn() macro
set_error_fn() has become a useless complication after c1e7c3ae59 ("bzip2/lzma/gzip: pre-boot malloc doesn't return NULL on failure") fixed the use of error() in malloc(). Only decompress_unlzma.c had some use for it and that was easy to change too. This also gets rid of the static function pointer "error", which should have been marked as __initdata. Signed-off-by: Lasse Collin <lasse.collin@tukaani.org> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Alain Knaff <alain@knaff.lu> Cc: Albin Tonnerre <albin.tonnerre@free-electrons.com> Cc: Phillip Lougher <phillip@lougher.demon.co.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/decompress_bunzip2.c7
-rw-r--r--lib/decompress_inflate.c3
-rw-r--r--lib/decompress_unlzma.c11
-rw-r--r--lib/decompress_unlzo.c4
4 files changed, 11 insertions, 14 deletions
diff --git a/lib/decompress_bunzip2.c b/lib/decompress_bunzip2.c
index 81c8bb1cc6a..e805087f556 100644
--- a/lib/decompress_bunzip2.c
+++ b/lib/decompress_bunzip2.c
@@ -682,13 +682,12 @@ STATIC int INIT bunzip2(unsigned char *buf, int len,
int(*flush)(void*, unsigned int),
unsigned char *outbuf,
int *pos,
- void(*error_fn)(char *x))
+ void(*error)(char *x))
{
struct bunzip_data *bd;
int i = -1;
unsigned char *inbuf;
- set_error_fn(error_fn);
if (flush)
outbuf = malloc(BZIP2_IOBUF_SIZE);
@@ -751,8 +750,8 @@ STATIC int INIT decompress(unsigned char *buf, int len,
int(*flush)(void*, unsigned int),
unsigned char *outbuf,
int *pos,
- void(*error_fn)(char *x))
+ void(*error)(char *x))
{
- return bunzip2(buf, len - 4, fill, flush, outbuf, pos, error_fn);
+ return bunzip2(buf, len - 4, fill, flush, outbuf, pos, error);
}
#endif
diff --git a/lib/decompress_inflate.c b/lib/decompress_inflate.c
index 1eea07e8f21..9a7f5dfc0ed 100644
--- a/lib/decompress_inflate.c
+++ b/lib/decompress_inflate.c
@@ -38,13 +38,12 @@ STATIC int INIT gunzip(unsigned char *buf, int len,
int(*flush)(void*, unsigned int),
unsigned char *out_buf,
int *pos,
- void(*error_fn)(char *x)) {
+ void(*error)(char *x)) {
u8 *zbuf;
struct z_stream_s *strm;
int rc;
size_t out_len;
- set_error_fn(error_fn);
rc = -1;
if (flush) {
out_len = 0x8000; /* 32 K */
diff --git a/lib/decompress_unlzma.c b/lib/decompress_unlzma.c
index 951f7277e98..2787dc560e4 100644
--- a/lib/decompress_unlzma.c
+++ b/lib/decompress_unlzma.c
@@ -74,6 +74,7 @@ struct rc {
uint32_t code;
uint32_t range;
uint32_t bound;
+ void (*error)(char *);
};
@@ -92,7 +93,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;
}
@@ -536,7 +537,7 @@ STATIC inline int INIT unlzma(unsigned char *buf, int in_len,
int(*flush)(void*, unsigned int),
unsigned char *output,
int *posp,
- void(*error_fn)(char *x)
+ void(*error)(char *x)
)
{
struct lzma_header header;
@@ -552,7 +553,7 @@ STATIC inline int INIT unlzma(unsigned char *buf, int in_len,
unsigned char *inbuf;
int ret = -1;
- set_error_fn(error_fn);
+ rc.error = error;
if (buf)
inbuf = buf;
@@ -659,9 +660,9 @@ STATIC int INIT decompress(unsigned char *buf, int in_len,
int(*flush)(void*, unsigned int),
unsigned char *output,
int *posp,
- void(*error_fn)(char *x)
+ void(*error)(char *x)
)
{
- return unlzma(buf, in_len - 4, fill, flush, output, posp, error_fn);
+ return unlzma(buf, in_len - 4, fill, flush, output, posp, error);
}
#endif
diff --git a/lib/decompress_unlzo.c b/lib/decompress_unlzo.c
index bcb3a4bd68f..df3e98f945a 100644
--- a/lib/decompress_unlzo.c
+++ b/lib/decompress_unlzo.c
@@ -91,7 +91,7 @@ STATIC inline int INIT unlzo(u8 *input, int in_len,
int (*fill) (void *, unsigned int),
int (*flush) (void *, unsigned int),
u8 *output, int *posp,
- void (*error_fn) (char *x))
+ void (*error) (char *x))
{
u8 skip = 0, r = 0;
u32 src_len, dst_len;
@@ -99,8 +99,6 @@ STATIC inline int INIT unlzo(u8 *input, 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) {