From d37e27eef65c6249631e8757601c43e813ded155 Mon Sep 17 00:00:00 2001 From: Mark Adler Date: Tue, 10 Feb 2026 22:32:14 -0800 Subject: Reduce warnings in contrib/minizip. --- contrib/minizip/crypt.h | 2 +- contrib/minizip/skipset.h | 3 ++- contrib/minizip/zip.c | 15 ++++++++------- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/contrib/minizip/crypt.h b/contrib/minizip/crypt.h index 8bde464b..821c9137 100644 --- a/contrib/minizip/crypt.h +++ b/contrib/minizip/crypt.h @@ -106,7 +106,7 @@ static unsigned crypthead(const char* passwd, /* password string */ */ if (++calls == 1) { - srand((unsigned)(time(NULL) ^ ZCR_SEED2)); + srand((unsigned)time(NULL) ^ ZCR_SEED2); } init_keys(passwd, pkeys, pcrc_32_tab); for (n = 0; n < RAND_HEAD_LEN-2; n++) diff --git a/contrib/minizip/skipset.h b/contrib/minizip/skipset.h index 9f0aad61..beb67887 100644 --- a/contrib/minizip/skipset.h +++ b/contrib/minizip/skipset.h @@ -184,7 +184,8 @@ void set_grow(set_t *set, set_node_t *node, int want, int fill) { int more = node->size ? node->size : 1; while (more < want) more <<= 1; - node->right = set_alloc(set, node->right, more * sizeof(set_node_t *)); + node->right = set_alloc(set, node->right, + (size_t)more * sizeof(set_node_t *)); node->size = (i16_t)more; } int i; diff --git a/contrib/minizip/zip.c b/contrib/minizip/zip.c index 13c36beb..60e603d7 100644 --- a/contrib/minizip/zip.c +++ b/contrib/minizip/zip.c @@ -337,7 +337,7 @@ local int block_get(block_t *block) { return -1; /* Update left in case more was filled in since we were last here. */ block->left = block->node->filled_in_this_block - - (block->next - block->node->data); + (size_t)(block->next - block->node->data); if (block->left != 0) /* There was indeed more data appended in the current datablock. */ break; @@ -357,8 +357,9 @@ local int block_get(block_t *block) { /* Return a 16-bit unsigned little-endian value from block, or a negative value // if the end is reached. */ local long block_get2(block_t *block) { - long got = block_get(block); - return got | ((unsigned long)block_get(block) << 8); + int low = block_get(block); + int high = block_get(block); + return low < 0 || high < 0 ? -1 : low | ((long)high << 8); } /* Read up to len bytes from block into buf. Return the number of bytes read. */ @@ -420,9 +421,9 @@ local char *block_central_name(block_t *block, set_t *set) { /* Go through the remaining fixed-length portion of the record, // extracting the lengths of the three variable-length fields. */ block_skip(block, 24); - unsigned flen = block_get2(block); /* file name length */ - unsigned xlen = block_get2(block); /* extra field length */ - unsigned clen = block_get2(block); /* comment field length */ + unsigned flen = (unsigned)block_get2(block); /* file name length */ + unsigned xlen = (unsigned)block_get2(block); /* extra length */ + unsigned clen = (unsigned)block_get2(block); /* comment length */ if (block_skip(block, 12) == -1) /* Premature end of the record. */ break; @@ -1283,7 +1284,7 @@ local int isutf8(char const *str, size_t len) { if (code > 1) utf8 = 1; str += code; - len -= code; + len -= (unsigned)code; } return utf8; } -- cgit v1.2.3-55-g6feb