diff options
author | kientzle <kientzle@FreeBSD.org> | 2006-11-10 06:39:46 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2006-11-10 06:39:46 +0000 |
commit | 50bb724108b7417b0df3bbf7029c43dbd734df49 (patch) | |
tree | f89881956f7ca553a6834444961e2cb90388cc29 /lib/libarchive/archive_read_support_compression_gzip.c | |
parent | 56ac4302e20c910a87bfc933138eb38f4c21af7a (diff) | |
download | FreeBSD-src-50bb724108b7417b0df3bbf7029c43dbd734df49.zip FreeBSD-src-50bb724108b7417b0df3bbf7029c43dbd734df49.tar.gz |
Portability and style fixes:
* Actually use the HAVE_<header>_H macros to conditionally include
system headers. They've been defined for a long time, but only
used in a few places. Now they're used pretty consistently
throughout.
* Fill in a lot of missing casts for conversions from void*.
Although Standard C doesn't require this, some people have been
trying to use C++ compilers with this code, and they do require it.
Bit-for-bit, the compiled object files are identical, except for
one assert() whose line number changed, so I'm pretty confident I
didn't break anything. ;-)
Diffstat (limited to 'lib/libarchive/archive_read_support_compression_gzip.c')
-rw-r--r-- | lib/libarchive/archive_read_support_compression_gzip.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/libarchive/archive_read_support_compression_gzip.c b/lib/libarchive/archive_read_support_compression_gzip.c index 873ef86..4fa3ca0 100644 --- a/lib/libarchive/archive_read_support_compression_gzip.c +++ b/lib/libarchive/archive_read_support_compression_gzip.c @@ -29,10 +29,18 @@ __FBSDID("$FreeBSD$"); +#ifdef HAVE_ERRNO_H #include <errno.h> +#endif +#ifdef HAVE_STDLIB_H #include <stdlib.h> +#endif +#ifdef HAVE_STRING_H #include <string.h> +#endif +#ifdef HAVE_UNISTD_H #include <unistd.h> +#endif #ifdef HAVE_ZLIB_H #include <zlib.h> #endif @@ -83,7 +91,7 @@ bid(const void *buff, size_t len) if (len < 1) return (0); - buffer = buff; + buffer = (const unsigned char *)buff; bits_checked = 0; if (buffer[0] != 037) /* Verify first ID byte. */ return (0); @@ -154,7 +162,7 @@ init(struct archive *a, const void *buff, size_t n) a->compression_code = ARCHIVE_COMPRESSION_GZIP; a->compression_name = "gzip"; - state = malloc(sizeof(*state)); + state = (struct private_data *)malloc(sizeof(*state)); if (state == NULL) { archive_set_error(a, ENOMEM, "Can't allocate data for %s decompression", @@ -167,7 +175,7 @@ init(struct archive *a, const void *buff, size_t n) state->header_done = 0; /* We've not yet begun to parse header... */ state->uncompressed_buffer_size = 64 * 1024; - state->uncompressed_buffer = malloc(state->uncompressed_buffer_size); + state->uncompressed_buffer = (unsigned char *)malloc(state->uncompressed_buffer_size); state->stream.next_out = state->uncompressed_buffer; state->read_next = state->uncompressed_buffer; state->stream.avail_out = state->uncompressed_buffer_size; @@ -186,7 +194,7 @@ init(struct archive *a, const void *buff, size_t n) * next_in pointer, only reads it). The result: this ugly * cast to remove 'const'. */ - state->stream.next_in = (void *)(uintptr_t)(const void *)buff; + state->stream.next_in = (Bytef *)(uintptr_t)(const void *)buff; state->stream.avail_in = n; a->compression_read_ahead = read_ahead; @@ -250,7 +258,7 @@ read_ahead(struct archive *a, const void **p, size_t min) struct private_data *state; int read_avail, was_avail, ret; - state = a->compression_data; + state = (struct private_data *)a->compression_data; was_avail = -1; if (!a->client_reader) { archive_set_error(a, ARCHIVE_ERRNO_PROGRAMMER, @@ -291,7 +299,7 @@ read_consume(struct archive *a, size_t n) { struct private_data *state; - state = a->compression_data; + state = (struct private_data *)a->compression_data; a->file_position += n; state->read_next += n; if (state->read_next > state->stream.next_out) @@ -309,7 +317,7 @@ finish(struct archive *a) struct private_data *state; int ret; - state = a->compression_data; + state = (struct private_data *)a->compression_data; ret = ARCHIVE_OK; switch (inflateEnd(&(state->stream))) { case Z_OK: |