Commit daeb6b6fbe27049f465c48a7d0ee5555c3b84064

Authored by Phillip Lougher
Committed by Linus Torvalds
1 parent 9c8a8228d0

bzip2/lzma/gzip: fix comments describing decompressor API

Fix and improve comments in decompress/generic.h that describe the
decompressor API.  Also remove an unused definition, and rename INBUF_LEN
in lib/decompress_inflate.c to conform to bzip2/lzma naming.

Signed-off-by: Phillip Lougher <phillip@lougher.demon.co.uk>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 2 changed files with 23 additions and 17 deletions Side-by-side Diff

include/linux/decompress/generic.h
1 1 #ifndef DECOMPRESS_GENERIC_H
2 2 #define DECOMPRESS_GENERIC_H
3 3  
4   -/* Minimal chunksize to be read.
5   - *Bzip2 prefers at least 4096
6   - *Lzma prefers 0x10000 */
7   -#define COMPR_IOBUF_SIZE 4096
8   -
9 4 typedef int (*decompress_fn) (unsigned char *inbuf, int len,
10 5 int(*fill)(void*, unsigned int),
11   - int(*writebb)(void*, unsigned int),
12   - unsigned char *output,
  6 + int(*flush)(void*, unsigned int),
  7 + unsigned char *outbuf,
13 8 int *posp,
14 9 void(*error)(char *x));
15 10  
16 11 /* inbuf - input buffer
17 12 *len - len of pre-read data in inbuf
18   - *fill - function to fill inbuf if empty
19   - *writebb - function to write out outbug
  13 + *fill - function to fill inbuf when empty
  14 + *flush - function to write out outbuf
  15 + *outbuf - output buffer
20 16 *posp - if non-null, input position (number of bytes read) will be
21 17 * returned here
22 18 *
23   - *If len != 0, the inbuf is initialized (with as much data), and fill
24   - *should not be called
25   - *If len = 0, the inbuf is allocated, but empty. Its size is IOBUF_SIZE
26   - *fill should be called (repeatedly...) to read data, at most IOBUF_SIZE
  19 + *If len != 0, inbuf should contain all the necessary input data, and fill
  20 + *should be NULL
  21 + *If len = 0, inbuf can be NULL, in which case the decompressor will allocate
  22 + *the input buffer. If inbuf != NULL it must be at least XXX_IOBUF_SIZE bytes.
  23 + *fill will be called (repeatedly...) to read data, at most XXX_IOBUF_SIZE
  24 + *bytes should be read per call. Replace XXX with the appropriate decompressor
  25 + *name, i.e. LZMA_IOBUF_SIZE.
  26 + *
  27 + *If flush = NULL, outbuf must be large enough to buffer all the expected
  28 + *output. If flush != NULL, the output buffer will be allocated by the
  29 + *decompressor (outbuf = NULL), and the flush function will be called to
  30 + *flush the output buffer at the appropriate time (decompressor and stream
  31 + *dependent).
27 32 */
  33 +
28 34  
29 35 /* Utility routine to detect the decompression method */
30 36 decompress_fn decompress_method(const unsigned char *inbuf, int len,
lib/decompress_inflate.c
... ... @@ -25,7 +25,7 @@
25 25 #include <linux/decompress/mm.h>
26 26 #include <linux/slab.h>
27 27  
28   -#define INBUF_LEN (16*1024)
  28 +#define GZIP_IOBUF_SIZE (16*1024)
29 29  
30 30 /* Included from initramfs et al code */
31 31 STATIC int INIT gunzip(unsigned char *buf, int len,
... ... @@ -55,7 +55,7 @@
55 55 if (buf)
56 56 zbuf = buf;
57 57 else {
58   - zbuf = malloc(INBUF_LEN);
  58 + zbuf = malloc(GZIP_IOBUF_SIZE);
59 59 len = 0;
60 60 }
61 61 if (!zbuf) {
... ... @@ -77,7 +77,7 @@
77 77 }
78 78  
79 79 if (len == 0)
80   - len = fill(zbuf, INBUF_LEN);
  80 + len = fill(zbuf, GZIP_IOBUF_SIZE);
81 81  
82 82 /* verify the gzip header */
83 83 if (len < 10 ||
... ... @@ -113,7 +113,7 @@
113 113 while (rc == Z_OK) {
114 114 if (strm->avail_in == 0) {
115 115 /* TODO: handle case where both pos and fill are set */
116   - len = fill(zbuf, INBUF_LEN);
  116 + len = fill(zbuf, GZIP_IOBUF_SIZE);
117 117 if (len < 0) {
118 118 rc = -1;
119 119 error("read error");