Skip to content

Commit 3aeea1e

Browse files
committed
archive_write_set_format_cpio_binary: fix compilation on OpenBSD
Rename swap16 and swap32 to la_swap16 and la_swap32.
1 parent 8a1bd5c commit 3aeea1e

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

libarchive/archive_write_set_format_cpio_binary.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ PACKED(struct cpio_binary_header {
124124
* ...but it feels a little better to do it like this:
125125
*/
126126

127-
static uint16_t swap16(uint16_t in) {
127+
static uint16_t la_swap16(uint16_t in) {
128128
union {
129129
uint16_t s[2];
130130
uint8_t c[4];
@@ -141,7 +141,7 @@ static uint16_t swap16(uint16_t in) {
141141
/* NOTREACHED */
142142
}
143143

144-
static uint32_t swap32(uint32_t in) {
144+
static uint32_t la_swap32(uint32_t in) {
145145
union {
146146
uint32_t l;
147147
uint16_t s[2];
@@ -156,8 +156,8 @@ static uint32_t swap32(uint32_t in) {
156156
U.s[1] = t;
157157
} else if (U.c[3]) { /* Big-endian */
158158
U.l = in;
159-
U.s[0] = swap16(U.s[0]);
160-
U.s[1] = swap16(U.s[1]);
159+
U.s[0] = la_swap16(U.s[0]);
160+
U.s[1] = la_swap16(U.s[1]);
161161
} else { /* PDP-endian */
162162
U.l = in;
163163
}
@@ -426,8 +426,8 @@ write_header(struct archive_write *a, struct archive_entry *entry)
426426
/* Include trailing null */
427427
pathlength = (int)len + 1;
428428

429-
h.h_magic = swap16(070707);
430-
h.h_dev = swap16(archive_entry_dev(entry));
429+
h.h_magic = la_swap16(070707);
430+
h.h_dev = la_swap16(archive_entry_dev(entry));
431431

432432
ino = synthesize_ino_value(cpio, entry);
433433
if (ino < 0) {
@@ -441,7 +441,7 @@ write_header(struct archive_write *a, struct archive_entry *entry)
441441
ret_final = ARCHIVE_FATAL;
442442
goto exit_write_header;
443443
}
444-
h.h_ino = swap16(ino);
444+
h.h_ino = la_swap16(ino);
445445

446446
h.h_mode = archive_entry_mode(entry);
447447
if (((h.h_mode & AE_IFMT) == AE_IFSOCK) || ((h.h_mode & AE_IFMT) == AE_IFIFO)) {
@@ -460,20 +460,20 @@ write_header(struct archive_write *a, struct archive_entry *entry)
460460
/* we could turn off AE_IFREG here, but it does no harm, */
461461
/* and allows v7 cpio to read the entry without confusion */
462462
}
463-
h.h_mode = swap16(h.h_mode);
463+
h.h_mode = la_swap16(h.h_mode);
464464

465-
h.h_uid = swap16(archive_entry_uid(entry));
466-
h.h_gid = swap16(archive_entry_gid(entry));
467-
h.h_nlink = swap16(archive_entry_nlink(entry));
465+
h.h_uid = la_swap16(archive_entry_uid(entry));
466+
h.h_gid = la_swap16(archive_entry_gid(entry));
467+
h.h_nlink = la_swap16(archive_entry_nlink(entry));
468468

469469
if (archive_entry_filetype(entry) == AE_IFBLK
470470
|| archive_entry_filetype(entry) == AE_IFCHR)
471-
h.h_majmin = swap16(archive_entry_rdev(entry));
471+
h.h_majmin = la_swap16(archive_entry_rdev(entry));
472472
else
473473
h.h_majmin = 0;
474474

475-
h.h_mtime = swap32(archive_entry_mtime(entry));
476-
h.h_namesize = swap16(pathlength);
475+
h.h_mtime = la_swap32(archive_entry_mtime(entry));
476+
h.h_namesize = la_swap16(pathlength);
477477

478478
/* Non-regular files don't store bodies. */
479479
if (archive_entry_filetype(entry) != AE_IFREG)
@@ -502,7 +502,7 @@ write_header(struct archive_write *a, struct archive_entry *entry)
502502
ret_final = ARCHIVE_FATAL;
503503
goto exit_write_header;
504504
}
505-
h.h_filesize = swap32(strlen(p)); /* symlink */
505+
h.h_filesize = la_swap32(strlen(p)); /* symlink */
506506
} else {
507507
if ((a->archive.archive_format == ARCHIVE_FORMAT_CPIO_PWB) &&
508508
(archive_entry_size(entry) > 256*256*256-1)) {
@@ -516,7 +516,7 @@ write_header(struct archive_write *a, struct archive_entry *entry)
516516
ret_final = ARCHIVE_FAILED;
517517
goto exit_write_header;
518518
}
519-
h.h_filesize = swap32(archive_entry_size(entry)); /* file */
519+
h.h_filesize = la_swap32(archive_entry_size(entry)); /* file */
520520
}
521521

522522
ret = __archive_write_output(a, &h, HSIZE);

0 commit comments

Comments
 (0)