Skip to content

Commit 93685ad

Browse files
Larhzutorvalds
authored andcommitted
Decompressors: get rid of set_error_fn() macro
set_error_fn() has become a useless complication after c1e7c3a ("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>
1 parent 6b01ed6 commit 93685ad

5 files changed

Lines changed: 11 additions & 19 deletions

File tree

‎include/linux/decompress/mm.h‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ static void free(void *where)
6161
#define large_malloc(a) malloc(a)
6262
#define large_free(a) free(a)
6363

64-
#define set_error_fn(x)
65-
6664
#define INIT
6765

6866
#else /* STATIC */
@@ -84,9 +82,6 @@ static void free(void *where)
8482
#define large_malloc(a) vmalloc(a)
8583
#define large_free(a) vfree(a)
8684

87-
static void(*error)(char *m);
88-
#define set_error_fn(x) error = x;
89-
9085
#define INIT __init
9186
#define STATIC
9287

‎lib/decompress_bunzip2.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -682,13 +682,12 @@ STATIC int INIT bunzip2(unsigned char *buf, int len,
682682
int(*flush)(void*, unsigned int),
683683
unsigned char *outbuf,
684684
int *pos,
685-
void(*error_fn)(char *x))
685+
void(*error)(char *x))
686686
{
687687
struct bunzip_data *bd;
688688
int i = -1;
689689
unsigned char *inbuf;
690690

691-
set_error_fn(error_fn);
692691
if (flush)
693692
outbuf = malloc(BZIP2_IOBUF_SIZE);
694693

@@ -751,8 +750,8 @@ STATIC int INIT decompress(unsigned char *buf, int len,
751750
int(*flush)(void*, unsigned int),
752751
unsigned char *outbuf,
753752
int *pos,
754-
void(*error_fn)(char *x))
753+
void(*error)(char *x))
755754
{
756-
return bunzip2(buf, len - 4, fill, flush, outbuf, pos, error_fn);
755+
return bunzip2(buf, len - 4, fill, flush, outbuf, pos, error);
757756
}
758757
#endif

‎lib/decompress_inflate.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,12 @@ STATIC int INIT gunzip(unsigned char *buf, int len,
3838
int(*flush)(void*, unsigned int),
3939
unsigned char *out_buf,
4040
int *pos,
41-
void(*error_fn)(char *x)) {
41+
void(*error)(char *x)) {
4242
u8 *zbuf;
4343
struct z_stream_s *strm;
4444
int rc;
4545
size_t out_len;
4646

47-
set_error_fn(error_fn);
4847
rc = -1;
4948
if (flush) {
5049
out_len = 0x8000; /* 32 K */

‎lib/decompress_unlzma.c‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ struct rc {
7474
uint32_t code;
7575
uint32_t range;
7676
uint32_t bound;
77+
void (*error)(char *);
7778
};
7879

7980

@@ -92,7 +93,7 @@ static void INIT rc_read(struct rc *rc)
9293
{
9394
rc->buffer_size = rc->fill((char *)rc->buffer, LZMA_IOBUF_SIZE);
9495
if (rc->buffer_size <= 0)
95-
error("unexpected EOF");
96+
rc->error("unexpected EOF");
9697
rc->ptr = rc->buffer;
9798
rc->buffer_end = rc->buffer + rc->buffer_size;
9899
}
@@ -536,7 +537,7 @@ STATIC inline int INIT unlzma(unsigned char *buf, int in_len,
536537
int(*flush)(void*, unsigned int),
537538
unsigned char *output,
538539
int *posp,
539-
void(*error_fn)(char *x)
540+
void(*error)(char *x)
540541
)
541542
{
542543
struct lzma_header header;
@@ -552,7 +553,7 @@ STATIC inline int INIT unlzma(unsigned char *buf, int in_len,
552553
unsigned char *inbuf;
553554
int ret = -1;
554555

555-
set_error_fn(error_fn);
556+
rc.error = error;
556557

557558
if (buf)
558559
inbuf = buf;
@@ -659,9 +660,9 @@ STATIC int INIT decompress(unsigned char *buf, int in_len,
659660
int(*flush)(void*, unsigned int),
660661
unsigned char *output,
661662
int *posp,
662-
void(*error_fn)(char *x)
663+
void(*error)(char *x)
663664
)
664665
{
665-
return unlzma(buf, in_len - 4, fill, flush, output, posp, error_fn);
666+
return unlzma(buf, in_len - 4, fill, flush, output, posp, error);
666667
}
667668
#endif

‎lib/decompress_unlzo.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,14 @@ STATIC inline int INIT unlzo(u8 *input, int in_len,
9191
int (*fill) (void *, unsigned int),
9292
int (*flush) (void *, unsigned int),
9393
u8 *output, int *posp,
94-
void (*error_fn) (char *x))
94+
void (*error) (char *x))
9595
{
9696
u8 skip = 0, r = 0;
9797
u32 src_len, dst_len;
9898
size_t tmp;
9999
u8 *in_buf, *in_buf_save, *out_buf;
100100
int ret = -1;
101101

102-
set_error_fn(error_fn);
103-
104102
if (output) {
105103
out_buf = output;
106104
} else if (!flush) {

0 commit comments

Comments
 (0)