summaryrefslogtreecommitdiffstats
path: root/lib/libarchive/archive_read_support_compression_compress.c
diff options
context:
space:
mode:
authorkientzle <kientzle@FreeBSD.org>2006-11-10 06:39:46 +0000
committerkientzle <kientzle@FreeBSD.org>2006-11-10 06:39:46 +0000
commit50bb724108b7417b0df3bbf7029c43dbd734df49 (patch)
treef89881956f7ca553a6834444961e2cb90388cc29 /lib/libarchive/archive_read_support_compression_compress.c
parent56ac4302e20c910a87bfc933138eb38f4c21af7a (diff)
downloadFreeBSD-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_compress.c')
-rw-r--r--lib/libarchive/archive_read_support_compression_compress.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/lib/libarchive/archive_read_support_compression_compress.c b/lib/libarchive/archive_read_support_compression_compress.c
index 5f893ca..e984459 100644
--- a/lib/libarchive/archive_read_support_compression_compress.c
+++ b/lib/libarchive/archive_read_support_compression_compress.c
@@ -67,10 +67,18 @@
#include "archive_platform.h"
__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
#include "archive.h"
#include "archive_private.h"
@@ -155,7 +163,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);
@@ -193,7 +201,7 @@ init(struct archive *a, const void *buff, size_t n)
a->compression_skip = NULL; /* not supported */
a->compression_finish = finish;
- 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",
@@ -213,9 +221,9 @@ init(struct archive *a, const void *buff, size_t n)
goto fatal;
}
- state->next_in = buff;
+ state->next_in = (const unsigned char *)buff;
state->avail_in = n;
- state->read_next = state->next_out = state->uncompressed_buffer;
+ state->read_next = state->next_out = (unsigned char *)state->uncompressed_buffer;
state->avail_out = state->uncompressed_buffer_size;
code = getbits(a, state, 8);
@@ -268,7 +276,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,
@@ -289,7 +297,7 @@ read_ahead(struct archive *a, const void **p, size_t min)
if (read_avail < (int)min) {
memmove(state->uncompressed_buffer, state->read_next,
read_avail);
- state->read_next = state->uncompressed_buffer;
+ state->read_next = (unsigned char *)state->uncompressed_buffer;
state->next_out = state->read_next + read_avail;
state->avail_out
= state->uncompressed_buffer_size - read_avail;
@@ -322,7 +330,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->next_out)
@@ -340,7 +348,7 @@ finish(struct archive *a)
struct private_data *state;
int ret = ARCHIVE_OK;
- state = a->compression_data;
+ state = (struct private_data *)a->compression_data;
if (state != NULL) {
if (state->uncompressed_buffer != NULL)
OpenPOWER on IntegriCloud