From: Graham Percival Date: Sun, 29 Dec 2024 18:20:24 +0000 (-0800) Subject: Add more casts for %c, %o, and %x (#2463) X-Git-Tag: v3.7.8~18 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3971e6dfcfb70ab1b36c0114072cbcc92ad34a7e;p=thirdparty%2Flibarchive.git Add more casts for %c, %o, and %x (#2463) (cherry picked from commit 4ce9c2f4bedfef8e4c5962c4d0f59bc400e2a976) --- diff --git a/libarchive/archive_read_support_format_rar5.c b/libarchive/archive_read_support_format_rar5.c index b99105d0c..aceb8501e 100644 --- a/libarchive/archive_read_support_format_rar5.c +++ b/libarchive/archive_read_support_format_rar5.c @@ -691,7 +691,8 @@ static int run_filter(struct archive_read* a, struct filter_info* flt) { default: archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, - "Unsupported filter type: 0x%x", flt->type); + "Unsupported filter type: 0x%x", + (unsigned int)flt->type); return ARCHIVE_FATAL; } @@ -3983,7 +3984,7 @@ static int do_unpack(struct archive_read* a, struct rar5* rar, archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, "Compression method not supported: 0x%x", - rar->cstate.method); + (unsigned int)rar->cstate.method); return ARCHIVE_FATAL; } diff --git a/libarchive/archive_write_set_format_iso9660.c b/libarchive/archive_write_set_format_iso9660.c index bc86047f6..3c5b88994 100644 --- a/libarchive/archive_write_set_format_iso9660.c +++ b/libarchive/archive_write_set_format_iso9660.c @@ -4037,7 +4037,7 @@ set_option_info(struct archive_string *info, int *opt, const char *key, case KEY_HEX: d = va_arg(ap, int); archive_string_sprintf(info, "%c%s=%x", - prefix, key, d); + prefix, key, (unsigned int)d); break; } va_end(ap); diff --git a/tar/util.c b/tar/util.c index e91234c92..3b099cb5f 100644 --- a/tar/util.c +++ b/tar/util.c @@ -202,7 +202,8 @@ bsdtar_expand_char(char *buff, size_t buffsize, size_t offset, char c) case '\v': buff[i++] = 'v'; break; case '\\': buff[i++] = '\\'; break; default: - snprintf(buff + i, buffsize - i, "%03o", 0xFF & (int)c); + snprintf(buff + i, buffsize - i, "%03o", + 0xFF & (unsigned int)c); i += 3; } } diff --git a/test_utils/test_main.c b/test_utils/test_main.c index abd99b5da..b2eae6381 100644 --- a/test_utils/test_main.c +++ b/test_utils/test_main.c @@ -758,7 +758,7 @@ static void strdump(const char *e, const char *p, int ewidth, int utf8) case '\r': logprintf("\\r"); break; default: if (c >= 32 && c < 127) - logprintf("%c", c); + logprintf("%c", (int)c); else logprintf("\\x%02X", c); } @@ -832,7 +832,7 @@ wcsdump(const char *e, const wchar_t *w) while (*w != L'\0') { unsigned int c = *w++; if (c >= 32 && c < 127) - logprintf("%c", c); + logprintf("%c", (int)c); else if (c < 256) logprintf("\\x%02X", c); else if (c < 0x10000) @@ -3415,8 +3415,9 @@ assertion_entry_compare_acls(const char *file, int line, } if ((permset << 6) != (mode & 0700)) { failure_start(file, line, "USER_OBJ permset " - "(%02o) != user mode (%02o)", permset, - 07 & (mode >> 6)); + "(%02o) != user mode (%02o)", + (unsigned int)permset, + (unsigned int)(07 & (mode >> 6))); failure_finish(NULL); ret = 1; } @@ -3430,8 +3431,9 @@ assertion_entry_compare_acls(const char *file, int line, } if ((permset << 3) != (mode & 0070)) { failure_start(file, line, "GROUP_OBJ permset " - "(%02o) != group mode (%02o)", permset, - 07 & (mode >> 3)); + "(%02o) != group mode (%02o)", + (unsigned int)permset, + (unsigned int)(07 & (mode >> 3))); failure_finish(NULL); ret = 1; } @@ -3445,8 +3447,9 @@ assertion_entry_compare_acls(const char *file, int line, } if ((permset << 0) != (mode & 0007)) { failure_start(file, line, "OTHER permset " - "(%02o) != other mode (%02o)", permset, - mode & 07); + "(%02o) != other mode (%02o)", + (unsigned int)permset, + (unsigned int)mode & 07); failure_finish(NULL); ret = 1; }