summaryrefslogtreecommitdiffstats
path: root/lib/libarchive/archive_entry.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_entry.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_entry.c')
-rw-r--r--lib/libarchive/archive_entry.c42
1 files changed, 26 insertions, 16 deletions
diff --git a/lib/libarchive/archive_entry.c b/lib/libarchive/archive_entry.c
index 7ec0052..1489839 100644
--- a/lib/libarchive/archive_entry.c
+++ b/lib/libarchive/archive_entry.c
@@ -27,8 +27,12 @@
#include "archive_platform.h"
__FBSDID("$FreeBSD$");
+#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
+#endif
+#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
+#endif
#ifdef MAJOR_IN_MKDEV
#include <sys/mkdev.h>
#else
@@ -39,11 +43,17 @@ __FBSDID("$FreeBSD$");
#ifdef HAVE_EXT2FS_EXT2_FS_H
#include <ext2fs/ext2_fs.h> /* for Linux file flags */
#endif
+#ifdef HAVE_LIMITS_H
#include <limits.h>
+#endif
#include <stddef.h>
#include <stdio.h>
+#ifdef HAVE_STDLIB_H
#include <stdlib.h>
+#endif
+#ifdef HAVE_STRING_H
#include <string.h>
+#endif
/* Obtain suitable wide-character manipulation functions. */
#ifdef HAVE_WCHAR_H
@@ -209,7 +219,7 @@ aes_copy(struct aes *dest, struct aes *src)
}
if (src->aes_wcs != NULL) {
- dest->aes_wcs_alloc = malloc((wcslen(src->aes_wcs) + 1)
+ dest->aes_wcs_alloc = (wchar_t *)malloc((wcslen(src->aes_wcs) + 1)
* sizeof(wchar_t));
dest->aes_wcs = dest->aes_wcs_alloc;
if (dest->aes_wcs == NULL)
@@ -231,7 +241,7 @@ aes_get_mbs(struct aes *aes)
* be a better way... XXX
*/
int mbs_length = wcslen(aes->aes_wcs) * 3 + 64;
- aes->aes_mbs_alloc = malloc(mbs_length);
+ aes->aes_mbs_alloc = (char *)malloc(mbs_length);
aes->aes_mbs = aes->aes_mbs_alloc;
if (aes->aes_mbs == NULL)
__archive_errx(1, "No memory for aes_get_mbs()");
@@ -253,7 +263,7 @@ aes_get_wcs(struct aes *aes)
*/
int wcs_length = strlen(aes->aes_mbs);
aes->aes_wcs_alloc
- = malloc((wcs_length + 1) * sizeof(wchar_t));
+ = (wchar_t *)malloc((wcs_length + 1) * sizeof(wchar_t));
aes->aes_wcs = aes->aes_wcs_alloc;
if (aes->aes_wcs == NULL)
__archive_errx(1, "No memory for aes_get_wcs()");
@@ -289,7 +299,7 @@ aes_copy_mbs(struct aes *aes, const char *mbs)
free(aes->aes_wcs_alloc);
aes->aes_wcs_alloc = NULL;
}
- aes->aes_mbs_alloc = malloc((strlen(mbs) + 1) * sizeof(char));
+ aes->aes_mbs_alloc = (char *)malloc((strlen(mbs) + 1) * sizeof(char));
if (aes->aes_mbs_alloc == NULL)
__archive_errx(1, "No memory for aes_copy_mbs()");
strcpy(aes->aes_mbs_alloc, mbs);
@@ -326,7 +336,7 @@ aes_copy_wcs(struct aes *aes, const wchar_t *wcs)
aes->aes_wcs_alloc = NULL;
}
aes->aes_mbs = NULL;
- aes->aes_wcs_alloc = malloc((wcslen(wcs) + 1) * sizeof(wchar_t));
+ aes->aes_wcs_alloc = (wchar_t *)malloc((wcslen(wcs) + 1) * sizeof(wchar_t));
if (aes->aes_wcs_alloc == NULL)
__archive_errx(1, "No memory for aes_copy_wcs()");
wcscpy(aes->aes_wcs_alloc, wcs);
@@ -354,7 +364,7 @@ archive_entry_clone(struct archive_entry *entry)
struct archive_entry *entry2;
/* Allocate new structure and copy over all of the fields. */
- entry2 = malloc(sizeof(*entry2));
+ entry2 = (struct archive_entry *)malloc(sizeof(*entry2));
if (entry2 == NULL)
return (NULL);
memset(entry2, 0, sizeof(*entry2));
@@ -386,7 +396,7 @@ archive_entry_new(void)
{
struct archive_entry *entry;
- entry = malloc(sizeof(*entry));
+ entry = (struct archive_entry *)malloc(sizeof(*entry));
if (entry == NULL)
return (NULL);
memset(entry, 0, sizeof(*entry));
@@ -901,7 +911,7 @@ acl_new_entry(struct archive_entry *entry,
}
/* Add a new entry to the list. */
- ap = malloc(sizeof(*ap));
+ ap = (struct ae_acl *)malloc(sizeof(*ap));
if (ap == NULL)
return (NULL);
memset(ap, 0, sizeof(*ap));
@@ -1083,7 +1093,7 @@ archive_entry_acl_text_w(struct archive_entry *entry, int flags)
return (NULL);
/* Now, allocate the string and actually populate it. */
- wp = entry->acl_text_w = malloc(length * sizeof(wchar_t));
+ wp = entry->acl_text_w = (wchar_t *)malloc(length * sizeof(wchar_t));
if (wp == NULL)
__archive_errx(1, "No memory to generate the text version of the ACL");
count = 0;
@@ -1338,7 +1348,7 @@ __archive_entry_acl_parse_w(struct archive_entry *entry,
free(namebuff);
namebuff_length = name_end - name_start + 256;
namebuff =
- malloc(namebuff_length * sizeof(wchar_t));
+ (wchar_t *)malloc(namebuff_length * sizeof(wchar_t));
if (namebuff == NULL)
goto fail;
}
@@ -1387,16 +1397,16 @@ archive_entry_xattr_add_entry(struct archive_entry *entry,
for (xp = entry->xattr_head; xp != NULL; xp = xp->next)
;
- if ((xp = malloc(sizeof(struct ae_xattr))) == NULL)
+ if ((xp = (struct ae_xattr *)malloc(sizeof(struct ae_xattr))) == NULL)
/* XXX Error XXX */
return;
xp->name = strdup(name);
- if ((xp -> value = malloc(size)) != NULL) {
- memcpy(xp -> value, value, size);
- xp -> size = size;
+ if ((xp->value = malloc(size)) != NULL) {
+ memcpy(xp->value, value, size);
+ xp->size = size;
} else
- xp -> size = 0;
+ xp->size = 0;
xp->next = entry->xattr_head;
entry->xattr_head = xp;
@@ -1632,7 +1642,7 @@ ae_fflagstostr(unsigned long bitset, unsigned long bitclear)
if (length == 0)
return (NULL);
- string = malloc(length);
+ string = (char *)malloc(length);
if (string == NULL)
return (NULL);
OpenPOWER on IntegriCloud