summaryrefslogtreecommitdiffstats
path: root/lib/libarchive/archive_write_open_fd.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_write_open_fd.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_write_open_fd.c')
-rw-r--r--lib/libarchive/archive_write_open_fd.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/libarchive/archive_write_open_fd.c b/lib/libarchive/archive_write_open_fd.c
index 58bfbd3..b61ee08 100644
--- a/lib/libarchive/archive_write_open_fd.c
+++ b/lib/libarchive/archive_write_open_fd.c
@@ -27,11 +27,21 @@
#include "archive_platform.h"
__FBSDID("$FreeBSD$");
+#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
+#endif
+#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"
@@ -50,7 +60,7 @@ archive_write_open_fd(struct archive *a, int fd)
{
struct write_fd_data *mine;
- mine = malloc(sizeof(*mine));
+ mine = (struct write_fd_data *)malloc(sizeof(*mine));
if (mine == NULL) {
archive_set_error(a, ENOMEM, "No memory");
return (ARCHIVE_FATAL);
@@ -67,7 +77,7 @@ file_open(struct archive *a, void *client_data)
struct stat st, *pst;
pst = NULL;
- mine = client_data;
+ mine = (struct write_fd_data *)client_data;
/*
* If client hasn't explicitly set the last block handling,
@@ -113,7 +123,7 @@ file_write(struct archive *a, void *client_data, void *buff, size_t length)
struct write_fd_data *mine;
ssize_t bytesWritten;
- mine = client_data;
+ mine = (struct write_fd_data *)client_data;
bytesWritten = write(mine->fd, buff, length);
if (bytesWritten <= 0) {
archive_set_error(a, errno, "Write error");
@@ -125,7 +135,7 @@ file_write(struct archive *a, void *client_data, void *buff, size_t length)
static int
file_close(struct archive *a, void *client_data)
{
- struct write_fd_data *mine = client_data;
+ struct write_fd_data *mine = (struct write_fd_data *)client_data;
(void)a; /* UNUSED */
free(mine);
OpenPOWER on IntegriCloud