Skip to content

Commit

Permalink
Fix a handful of compiler warnings
Browse files Browse the repository at this point in the history
This fixes a couple of warnings raised by clang.
  • Loading branch information
AtariDreams committed Oct 18, 2023
1 parent 2edd881 commit 5f0588d
Show file tree
Hide file tree
Showing 13 changed files with 63 additions and 64 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,7 @@ MACRO(CHECK_ICONV LIB TRY_ICONV_CONST)
ENDIF(HAVE_ICONV_${LIB}_${TRY_ICONV_CONST})
CMAKE_POP_CHECK_STATE() # Restore the state of the variables
ENDIF(NOT HAVE_ICONV)
ENDMACRO(CHECK_ICONV TRY_ICONV_CONST)
ENDMACRO()

IF(ENABLE_ICONV)
CMAKE_PUSH_CHECK_STATE() # Save the state of the variables
Expand Down
17 changes: 9 additions & 8 deletions libarchive/archive_disk_acl_darwin.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ static const acl_perm_map_t acl_nfs4_perm_map[] = {
#endif
};

static const int acl_nfs4_perm_map_size =
(int)(sizeof(acl_nfs4_perm_map)/sizeof(acl_nfs4_perm_map[0]));
static const size_t acl_nfs4_perm_map_size =
(sizeof(acl_nfs4_perm_map) / sizeof(acl_nfs4_perm_map[0]));

static const acl_perm_map_t acl_nfs4_flag_map[] = {
{ARCHIVE_ENTRY_ACL_ENTRY_INHERITED, ACL_ENTRY_INHERITED},
Expand All @@ -87,8 +87,8 @@ static const acl_perm_map_t acl_nfs4_flag_map[] = {
{ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, ACL_ENTRY_ONLY_INHERIT}
};

static const int acl_nfs4_flag_map_size =
(int)(sizeof(acl_nfs4_flag_map)/sizeof(acl_nfs4_flag_map[0]));
static const size_t acl_nfs4_flag_map_size =
(sizeof(acl_nfs4_flag_map) / sizeof(acl_nfs4_flag_map[0]));

static int translate_guid(struct archive *a, acl_entry_t acl_entry,
int *ae_id, int *ae_tag, const char **ae_name)
Expand Down Expand Up @@ -124,7 +124,7 @@ static void
add_trivial_nfs4_acl(struct archive_entry *entry)
{
mode_t mode;
int i;
size_t i;
const int rperm = ARCHIVE_ENTRY_ACL_READ_DATA;
const int wperm = ARCHIVE_ENTRY_ACL_WRITE_DATA |
ARCHIVE_ENTRY_ACL_APPEND_DATA;
Expand Down Expand Up @@ -195,7 +195,7 @@ add_trivial_nfs4_acl(struct archive_entry *entry)
} else if ((mode & 0010) || (mode & 0001))
tacl_entry[1].permset |= eperm;

for (i = 0; i < 6; i++) {
for (i = 0; i < sizeof(tacl_entry) / sizeof(tacl_entry[0]); i++) {
if (tacl_entry[i].permset != 0) {
archive_entry_acl_add_entry(entry,
tacl_entry[i].type, tacl_entry[i].permset,
Expand All @@ -214,8 +214,9 @@ translate_acl(struct archive_read_disk *a,
acl_flagset_t acl_flagset;
acl_entry_t acl_entry;
acl_permset_t acl_permset;
int i, entry_acl_type;
int entry_acl_type;
int r, s, ae_id, ae_tag, ae_perm;
size_t i;
const char *ae_name;

s = acl_get_entry(acl, ACL_FIRST_ENTRY, &acl_entry);
Expand Down Expand Up @@ -333,7 +334,7 @@ set_acl(struct archive *a, int fd, const char *name,
gid_t ae_gid;
const char *ae_name;
int entries;
int i;
size_t i;

ret = ARCHIVE_OK;
entries = archive_acl_reset(abstract_acl, ae_requested_type);
Expand Down
15 changes: 8 additions & 7 deletions libarchive/archive_disk_acl_freebsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ static const acl_perm_map_t acl_nfs4_perm_map[] = {
{ARCHIVE_ENTRY_ACL_SYNCHRONIZE, ACL_SYNCHRONIZE}
};

static const int acl_nfs4_perm_map_size =
(int)(sizeof(acl_nfs4_perm_map)/sizeof(acl_nfs4_perm_map[0]));
static const size_t acl_nfs4_perm_map_size =
(sizeof(acl_nfs4_perm_map) / sizeof(acl_nfs4_perm_map[0]));

static const acl_perm_map_t acl_nfs4_flag_map[] = {
{ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT, ACL_ENTRY_FILE_INHERIT},
Expand All @@ -98,8 +98,8 @@ static const acl_perm_map_t acl_nfs4_flag_map[] = {
#endif
};

static const int acl_nfs4_flag_map_size =
(int)(sizeof(acl_nfs4_flag_map)/sizeof(acl_nfs4_flag_map[0]));
static const size_t acl_nfs4_flag_map_size =
(sizeof(acl_nfs4_flag_map) / sizeof(acl_nfs4_flag_map[0]));
#endif /* ARCHIVE_ACL_FREEBSD_NFS4 */

static int
Expand All @@ -114,8 +114,10 @@ translate_acl(struct archive_read_disk *a,
acl_tag_t acl_tag;
acl_entry_t acl_entry;
acl_permset_t acl_permset;
int i, entry_acl_type, perm_map_size;
int entry_acl_type;
size_t perm_map_size;
const acl_perm_map_t *perm_map;
size_t i;
int r, s, ae_id, ae_tag, ae_perm;
void *q;
const char *ae_name;
Expand Down Expand Up @@ -332,13 +334,12 @@ set_acl(struct archive *a, int fd, const char *name,
#endif
int ret;
int ae_type, ae_permset, ae_tag, ae_id;
int perm_map_size;
size_t i, perm_map_size;
const acl_perm_map_t *perm_map;
uid_t ae_uid;
gid_t ae_gid;
const char *ae_name;
int entries;
int i;

ret = ARCHIVE_OK;
entries = archive_acl_reset(abstract_acl, ae_requested_type);
Expand Down
22 changes: 12 additions & 10 deletions libarchive/archive_disk_acl_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ static const acl_perm_map_t acl_posix_perm_map[] = {
{ARCHIVE_ENTRY_ACL_READ, ACL_READ},
};

static const int acl_posix_perm_map_size =
(int)(sizeof(acl_posix_perm_map)/sizeof(acl_posix_perm_map[0]));
static const size_t acl_posix_perm_map_size =
(sizeof(acl_posix_perm_map) / sizeof(acl_posix_perm_map[0]));
#endif /* ARCHIVE_ACL_LIBACL */

#if ARCHIVE_ACL_LIBRICHACL
Expand All @@ -87,8 +87,8 @@ static const acl_perm_map_t acl_nfs4_perm_map[] = {
{ARCHIVE_ENTRY_ACL_SYNCHRONIZE, RICHACE_SYNCHRONIZE}
};

static const int acl_nfs4_perm_map_size =
(int)(sizeof(acl_nfs4_perm_map)/sizeof(acl_nfs4_perm_map[0]));
static const size_t acl_nfs4_perm_map_size =
(sizeof(acl_nfs4_perm_map)/sizeof(acl_nfs4_perm_map[0]));

static const acl_perm_map_t acl_nfs4_flag_map[] = {
{ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT, RICHACE_FILE_INHERIT_ACE},
Expand All @@ -98,8 +98,8 @@ static const acl_perm_map_t acl_nfs4_flag_map[] = {
{ARCHIVE_ENTRY_ACL_ENTRY_INHERITED, RICHACE_INHERITED_ACE}
};

static const int acl_nfs4_flag_map_size =
(int)(sizeof(acl_nfs4_flag_map)/sizeof(acl_nfs4_flag_map[0]));
static const size_t acl_nfs4_flag_map_size =
(sizeof(acl_nfs4_flag_map) / sizeof(acl_nfs4_flag_map[0]));
#endif /* ARCHIVE_ACL_LIBRICHACL */

#if ARCHIVE_ACL_LIBACL
Expand All @@ -113,8 +113,9 @@ translate_acl(struct archive_read_disk *a,
acl_tag_t acl_tag;
acl_entry_t acl_entry;
acl_permset_t acl_permset;
int i, entry_acl_type;
int entry_acl_type;
int r, s, ae_id, ae_tag, ae_perm;
size_t i;
void *q;
const char *ae_name;

Expand Down Expand Up @@ -219,7 +220,8 @@ translate_richacl(struct archive_read_disk *a, struct archive_entry *entry,
struct richacl *richacl)
{
int ae_id, ae_tag, ae_perm;
int entry_acl_type, i;
int entry_acl_type;
size_t i;
const char *ae_name;

struct richace *richace;
Expand Down Expand Up @@ -326,7 +328,7 @@ set_richacl(struct archive *a, int fd, const char *name,
gid_t ae_gid;
const char *ae_name;
int entries;
int i;
size_t i;
int ret;
int e = 0;
struct richacl *richacl = NULL;
Expand Down Expand Up @@ -469,7 +471,7 @@ set_acl(struct archive *a, int fd, const char *name,
gid_t ae_gid;
const char *ae_name;
int entries;
int i;
size_t i;
int ret;
acl_t acl = NULL;
acl_entry_t acl_entry;
Expand Down
16 changes: 8 additions & 8 deletions libarchive/archive_disk_acl_sunos.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ static const acl_perm_map_t acl_nfs4_perm_map[] = {
{ARCHIVE_ENTRY_ACL_SYNCHRONIZE, ACE_SYNCHRONIZE}
};

static const int acl_nfs4_perm_map_size =
(int)(sizeof(acl_nfs4_perm_map)/sizeof(acl_nfs4_perm_map[0]));
static const size_t acl_nfs4_perm_map_size =
(sizeof(acl_nfs4_perm_map)/sizeof(acl_nfs4_perm_map[0]));

static const acl_perm_map_t acl_nfs4_flag_map[] = {
{ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT, ACE_FILE_INHERIT_ACE},
Expand All @@ -96,8 +96,8 @@ static const acl_perm_map_t acl_nfs4_flag_map[] = {
#endif
};

const int acl_nfs4_flag_map_size =
(int)(sizeof(acl_nfs4_flag_map)/sizeof(acl_nfs4_flag_map[0]));
const size_t acl_nfs4_flag_map_size =
(sizeof(acl_nfs4_flag_map) / sizeof(acl_nfs4_flag_map[0]));

#endif /* ARCHIVE_ACL_SUNOS_NFS4 */

Expand Down Expand Up @@ -164,7 +164,7 @@ sun_acl_is_trivial(void *aclp, int aclcnt, mode_t mode, int is_nfs4,
int is_dir, int *trivialp)
{
#if ARCHIVE_ACL_SUNOS_NFS4
int i, p;
size_t i, p;
const uint32_t rperm = ACE_READ_DATA;
const uint32_t wperm = ACE_WRITE_DATA | ACE_APPEND_DATA;
const uint32_t eperm = ACE_EXECUTE;
Expand Down Expand Up @@ -316,10 +316,11 @@ translate_acl(struct archive_read_disk *a,
struct archive_entry *entry, void *aclp, int aclcnt,
int default_entry_acl_type)
{
int e, i;
int e;
int ae_id, ae_tag, ae_perm;
int entry_acl_type;
const char *ae_name;
size_t i;
aclent_t *aclent;
#if ARCHIVE_ACL_SUNOS_NFS4
ace_t *ace;
Expand Down Expand Up @@ -454,13 +455,12 @@ set_acl(struct archive *a, int fd, const char *name,
void *aclp;
int ret;
int ae_type, ae_permset, ae_tag, ae_id;
int perm_map_size;
size_t i, perm_map_size;
const acl_perm_map_t *perm_map;
uid_t ae_uid;
gid_t ae_gid;
const char *ae_name;
int entries;
int i;

ret = ARCHIVE_OK;
entries = archive_acl_reset(abstract_acl, ae_requested_type);
Expand Down
8 changes: 5 additions & 3 deletions libarchive/archive_read_disk_entry_from_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,8 @@ setup_xattrs(struct archive_read_disk *a,
struct archive_entry *entry, int *fd)
{
int namespaces[2];
int i, res;
int res;
unsigned i;

namespaces[0] = EXTATTR_NAMESPACE_USER;
namespaces[1] = EXTATTR_NAMESPACE_SYSTEM;
Expand Down Expand Up @@ -894,7 +895,8 @@ setup_sparse_fiemap(struct archive_read_disk *a,
do_fiemap = 1;
size = archive_entry_size(entry);
for (iters = 0; ; ++iters) {
int i, r;
size_t i;
int r;

r = ioctl(*fd, FS_IOC_FIEMAP, fm);
if (r < 0) {
Expand All @@ -911,7 +913,7 @@ setup_sparse_fiemap(struct archive_read_disk *a,
break;
}
fe = fm->fm_extents;
for (i = 0; i < (int)fm->fm_mapped_extents; i++, fe++) {
for (i = 0; i < fm->fm_mapped_extents; i++, fe++) {
if (!(fe->fe_flags & FIEMAP_EXTENT_UNWRITTEN)) {
/* The fe_length of the last block does not
* adjust itself to its size files. */
Expand Down
2 changes: 1 addition & 1 deletion libarchive/archive_read_open_fd.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,13 @@ file_skip(struct archive *a, void *client_data, int64_t request)
struct read_fd_data *mine = (struct read_fd_data *)client_data;
int64_t skip = request;
int64_t old_offset, new_offset;
int skip_bits = sizeof(skip) * 8 - 1; /* off_t is a signed type. */

if (!mine->use_lseek)
return (0);

/* Reduce a request that would overflow the 'skip' variable. */
if (sizeof(request) > sizeof(skip)) {
int skip_bits = sizeof(skip) * 8 - 1; /* off_t is a signed type. */
int64_t max_skip =
(((int64_t)1 << (skip_bits - 1)) - 1) * 2 + 1;
if (request > max_skip)
Expand Down
2 changes: 1 addition & 1 deletion libarchive/archive_read_open_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ file_skip(struct archive *a, void *client_data, int64_t request)
#else
long skip = (long)request;
#endif
int skip_bits = sizeof(skip) * 8 - 1;

(void)a; /* UNUSED */

Expand All @@ -145,6 +144,7 @@ file_skip(struct archive *a, void *client_data, int64_t request)

/* If request is too big for a long or an off_t, reduce it. */
if (sizeof(request) > sizeof(skip)) {
int skip_bits = sizeof(skip) * 8 - 1;
int64_t max_skip =
(((int64_t)1 << (skip_bits - 1)) - 1) * 2 + 1;
if (request > max_skip)
Expand Down
3 changes: 0 additions & 3 deletions libarchive/archive_read_support_filter_lzop.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ __FBSDID("$FreeBSD$");
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_LZO_LZOCONF_H
#include <lzo/lzoconf.h>
#endif
Expand Down
4 changes: 0 additions & 4 deletions libarchive/archive_read_support_filter_zstd.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@

__FBSDID("$FreeBSD$");

#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif

#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
Expand Down
24 changes: 12 additions & 12 deletions libarchive/archive_read_support_format_rar.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,10 +511,10 @@ rar_br_fillup(struct archive_read *a, struct rar_br *br)
((uint64_t)br->next_in[1]) << 48 |
((uint64_t)br->next_in[2]) << 40 |
((uint64_t)br->next_in[3]) << 32 |
((uint32_t)br->next_in[4]) << 24 |
((uint32_t)br->next_in[5]) << 16 |
((uint32_t)br->next_in[6]) << 8 |
(uint32_t)br->next_in[7];
((uint64_t)br->next_in[4]) << 24 |
((uint64_t)br->next_in[5]) << 16 |
((uint64_t)br->next_in[6]) << 8 |
(uint64_t)br->next_in[7];
br->next_in += 8;
br->avail_in -= 8;
br->cache_avail += 8 * 8;
Expand All @@ -530,10 +530,10 @@ rar_br_fillup(struct archive_read *a, struct rar_br *br)
((uint64_t)br->next_in[0]) << 48 |
((uint64_t)br->next_in[1]) << 40 |
((uint64_t)br->next_in[2]) << 32 |
((uint32_t)br->next_in[3]) << 24 |
((uint32_t)br->next_in[4]) << 16 |
((uint32_t)br->next_in[5]) << 8 |
(uint32_t)br->next_in[6];
((uint64_t)br->next_in[3]) << 24 |
((uint64_t)br->next_in[4]) << 16 |
((uint64_t)br->next_in[5]) << 8 |
(uint64_t)br->next_in[6];
br->next_in += 7;
br->avail_in -= 7;
br->cache_avail += 7 * 8;
Expand All @@ -548,10 +548,10 @@ rar_br_fillup(struct archive_read *a, struct rar_br *br)
(br->cache_buffer << 48) |
((uint64_t)br->next_in[0]) << 40 |
((uint64_t)br->next_in[1]) << 32 |
((uint32_t)br->next_in[2]) << 24 |
((uint32_t)br->next_in[3]) << 16 |
((uint32_t)br->next_in[4]) << 8 |
(uint32_t)br->next_in[5];
((uint64_t)br->next_in[2]) << 24 |
((uint64_t)br->next_in[3]) << 16 |
((uint64_t)br->next_in[4]) << 8 |
(uint64_t)br->next_in[5];
br->next_in += 6;
br->avail_in -= 6;
br->cache_avail += 6 * 8;
Expand Down

0 comments on commit 5f0588d

Please sign in to comment.