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_write_set_compression_bzip2.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_write_set_compression_bzip2.c')
-rw-r--r-- | lib/libarchive/archive_write_set_compression_bzip2.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/libarchive/archive_write_set_compression_bzip2.c b/lib/libarchive/archive_write_set_compression_bzip2.c index 429cc15..1f567b2 100644 --- a/lib/libarchive/archive_write_set_compression_bzip2.c +++ b/lib/libarchive/archive_write_set_compression_bzip2.c @@ -31,11 +31,19 @@ __FBSDID("$FreeBSD$"); +#ifdef HAVE_ERRNO_H #include <errno.h> +#endif #include <stdio.h> +#ifdef HAVE_STDLIB_H #include <stdlib.h> +#endif +#ifdef HAVE_STRING_H #include <string.h> +#endif +#ifdef HAVE_BZLIB_H #include <bzlib.h> +#endif #include "archive.h" #include "archive_private.h" @@ -53,7 +61,7 @@ struct private_data { * of ugly hackery to convert a const * pointer to a non-const pointer. */ #define SET_NEXT_IN(st,src) \ - (st)->stream.next_in = (void *)(uintptr_t)(const void *)(src) + (st)->stream.next_in = (char *)(uintptr_t)(const void *)(src) static int archive_compressor_bzip2_finish(struct archive *); static int archive_compressor_bzip2_init(struct archive *); @@ -93,7 +101,7 @@ archive_compressor_bzip2_init(struct archive *a) return (ret); } - state = malloc(sizeof(*state)); + state = (struct private_data *)malloc(sizeof(*state)); if (state == NULL) { archive_set_error(a, ENOMEM, "Can't allocate data for compression"); @@ -102,7 +110,7 @@ archive_compressor_bzip2_init(struct archive *a) memset(state, 0, sizeof(*state)); state->compressed_buffer_size = a->bytes_per_block; - state->compressed = malloc(state->compressed_buffer_size); + state->compressed = (char *)malloc(state->compressed_buffer_size); if (state->compressed == NULL) { archive_set_error(a, ENOMEM, @@ -163,7 +171,7 @@ archive_compressor_bzip2_write(struct archive *a, const void *buff, { struct private_data *state; - state = a->compression_data; + state = (struct private_data *)a->compression_data; if (a->client_writer == NULL) { archive_set_error(a, ARCHIVE_ERRNO_PROGRAMMER, "No write callback is registered? " @@ -197,7 +205,7 @@ archive_compressor_bzip2_finish(struct archive *a) ssize_t bytes_written; unsigned tocopy; - state = a->compression_data; + state = (struct private_data *)a->compression_data; ret = ARCHIVE_OK; if (a->client_writer == NULL) { archive_set_error(a, ARCHIVE_ERRNO_PROGRAMMER, |