From aa1eeda578151e40c41ef39dd198979d4bae29a5 Mon Sep 17 00:00:00 2001 From: Tim Kientzle Date: Fri, 10 Nov 2006 06:39:46 +0000 Subject: Portability and style fixes: * Actually use the HAVE_
_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. ;-) --- .../archive_read_support_compression_bzip2.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'lib/libarchive/archive_read_support_compression_bzip2.c') diff --git a/lib/libarchive/archive_read_support_compression_bzip2.c b/lib/libarchive/archive_read_support_compression_bzip2.c index 79742e884419e..a389fdd9a025c 100644 --- a/lib/libarchive/archive_read_support_compression_bzip2.c +++ b/lib/libarchive/archive_read_support_compression_bzip2.c @@ -28,11 +28,19 @@ __FBSDID("$FreeBSD$"); +#ifdef HAVE_ERRNO_H #include +#endif #include +#ifdef HAVE_STDLIB_H #include +#endif +#ifdef HAVE_STRING_H #include +#endif +#ifdef HAVE_UNISTD_H #include +#endif #ifdef HAVE_BZLIB_H #include #endif @@ -81,7 +89,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] != 'B') /* Verify first ID byte. */ return (0); @@ -153,7 +161,7 @@ init(struct archive *a, const void *buff, size_t n) a->compression_code = ARCHIVE_COMPRESSION_BZIP2; a->compression_name = "bzip2"; - 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", @@ -163,7 +171,7 @@ init(struct archive *a, const void *buff, size_t n) memset(state, 0, sizeof(*state)); state->uncompressed_buffer_size = 64 * 1024; - state->uncompressed_buffer = malloc(state->uncompressed_buffer_size); + state->uncompressed_buffer = (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; @@ -182,7 +190,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 = (char *)(uintptr_t)(const void *)buff; state->stream.avail_in = n; a->compression_read_ahead = read_ahead; @@ -245,7 +253,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, @@ -286,7 +294,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) @@ -304,7 +312,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 (BZ2_bzDecompressEnd(&(state->stream))) { case BZ_OK: -- cgit v1.3