From c39372f5b4734cde6f1812e5e7603ce2fe578af5 Mon Sep 17 00:00:00 2001 From: Duncan Horn <40036384+dunhor@users.noreply.github.com> Date: Wed, 14 Aug 2024 01:09:01 -0700 Subject: [PATCH] Fix compilation warnings (#2246) Fix warnings I'm hitting, at least with MSVC --- libarchive/archive_read_support_format_rar.c | 2 +- libarchive/archive_read_support_format_tar.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libarchive/archive_read_support_format_rar.c b/libarchive/archive_read_support_format_rar.c index f4dcb7528..e041ff765 100644 --- a/libarchive/archive_read_support_format_rar.c +++ b/libarchive/archive_read_support_format_rar.c @@ -3690,7 +3690,7 @@ execute_filter_e8(struct rar_filter *filter, struct rar_virtual_machine *vm, siz { uint32_t currpos = (uint32_t)pos + i + 1; int32_t address = (int32_t)vm_read_32(vm, i + 1); - if (address < 0 && currpos >= -(uint32_t)address) + if (address < 0 && currpos >= (~(uint32_t)address + 1)) vm_write_32(vm, i + 1, address + filesize); else if (address >= 0 && (uint32_t)address < filesize) vm_write_32(vm, i + 1, address - currpos); diff --git a/libarchive/archive_read_support_format_tar.c b/libarchive/archive_read_support_format_tar.c index f8005e1a2..af601efba 100644 --- a/libarchive/archive_read_support_format_tar.c +++ b/libarchive/archive_read_support_format_tar.c @@ -2476,13 +2476,13 @@ pax_attribute(struct archive_read *a, struct tar *tar, struct archive_entry *ent } else if (key_length == 8 && memcmp(key, "devmajor", 8) == 0) { if ((err = pax_attribute_read_number(a, value_length, &t)) == ARCHIVE_OK) { - archive_entry_set_rdevmajor(entry, t); + archive_entry_set_rdevmajor(entry, (dev_t)t); } return (err); } else if (key_length == 8 && memcmp(key, "devminor", 8) == 0) { if ((err = pax_attribute_read_number(a, value_length, &t)) == ARCHIVE_OK) { - archive_entry_set_rdevminor(entry, t); + archive_entry_set_rdevminor(entry, (dev_t)t); } return (err); } @@ -2505,7 +2505,7 @@ pax_attribute(struct archive_read *a, struct tar *tar, struct archive_entry *ent } else if (key_length == 3 && memcmp(key, "dev", 3) == 0) { if ((err = pax_attribute_read_number(a, value_length, &t)) == ARCHIVE_OK) { - archive_entry_set_dev(entry, t); + archive_entry_set_dev(entry, (dev_t)t); } return (err); } @@ -2517,7 +2517,7 @@ pax_attribute(struct archive_read *a, struct tar *tar, struct archive_entry *ent } else if (key_length == 5 && memcmp(key, "nlink", 5) == 0) { if ((err = pax_attribute_read_number(a, value_length, &t)) == ARCHIVE_OK) { - archive_entry_set_nlink(entry, t); + archive_entry_set_nlink(entry, (unsigned int)t); } return (err); } -- 2.47.2