summaryrefslogtreecommitdiffstats
path: root/lib/libarchive/archive_read.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.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.c')
-rw-r--r--lib/libarchive/archive_read.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/libarchive/archive_read.c b/lib/libarchive/archive_read.c
index f7f2204..eafe4a8 100644
--- a/lib/libarchive/archive_read.c
+++ b/lib/libarchive/archive_read.c
@@ -35,11 +35,19 @@
#include "archive_platform.h"
__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_UNISTD_H
#include <unistd.h>
+#endif
#include "archive.h"
#include "archive_entry.h"
@@ -57,7 +65,7 @@ archive_read_new(void)
struct archive *a;
unsigned char *nulls;
- a = malloc(sizeof(*a));
+ a = (struct archive *)malloc(sizeof(*a));
if (a == NULL) {
archive_set_error(a, ENOMEM, "Can't allocate archive object");
return (NULL);
@@ -69,7 +77,7 @@ archive_read_new(void)
a->bytes_per_block = ARCHIVE_DEFAULT_BYTES_PER_BLOCK;
a->null_length = 1024;
- nulls = malloc(a->null_length);
+ nulls = (unsigned char *)malloc(a->null_length);
if (nulls == NULL) {
archive_set_error(a, ENOMEM, "Can't allocate archive object 'nulls' element");
free(a);
@@ -399,7 +407,7 @@ archive_read_data(struct archive *a, void *buff, size_t s)
int r;
bytes_read = 0;
- dest = buff;
+ dest = (char *)buff;
while (s > 0) {
if (a->read_data_remaining <= 0) {
OpenPOWER on IntegriCloud