From cfbbb255a2046921a87e847847222c610a5a0292 Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Wed, 15 Jun 2022 08:56:02 +0300 Subject: [PATCH] minor warning fixes --- src/physfs_archiver_iso9660.c | 2 +- src/physfs_archiver_slb.c | 2 +- src/physfs_archiver_zip.c | 4 ++-- src/physfs_miniz.h | 16 +++++++++++----- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/physfs_archiver_iso9660.c b/src/physfs_archiver_iso9660.c index 6d68150..e92d677 100644 --- a/src/physfs_archiver_iso9660.c +++ b/src/physfs_archiver_iso9660.c @@ -251,7 +251,7 @@ static int parseVolumeDescriptor(PHYSFS_Io *io, PHYSFS_uint64 *_rootpos, pos += 2048; /* each volume descriptor is 2048 bytes */ BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, &type, 1), 0); - BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, &identifier, 5), 0); + BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, identifier, 5), 0); if (memcmp(identifier, "CD001", 5) != 0) /* maybe not an iso? */ { diff --git a/src/physfs_archiver_slb.c b/src/physfs_archiver_slb.c index 7a0a448..58f3bc8 100644 --- a/src/physfs_archiver_slb.c +++ b/src/physfs_archiver_slb.c @@ -36,7 +36,7 @@ static int slbLoadEntries(PHYSFS_Io *io, const PHYSFS_uint32 count, void *arc) BAIL_IF(backslash != '\\', PHYSFS_ERR_CORRUPT, 0); /* read the rest of the buffer, 63 bytes */ - BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, &name, 63), 0); + BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, name, 63), 0); name[63] = '\0'; /* in case the name lacks the null terminator */ /* convert backslashes */ diff --git a/src/physfs_archiver_zip.c b/src/physfs_archiver_zip.c index 5cd657d..1430f57 100644 --- a/src/physfs_archiver_zip.c +++ b/src/physfs_archiver_zip.c @@ -568,7 +568,7 @@ static PHYSFS_sint64 zip_find_end_of_central_dir(PHYSFS_Io *io, PHYSFS_sint64 *l { if (!__PHYSFS_readAll(io, buf, maxread - 4)) return -1; - memcpy(&buf[maxread - 4], &extra, sizeof (extra)); + memcpy(&buf[maxread - 4], extra, sizeof (extra)); totalread += maxread - 4; } /* if */ else @@ -578,7 +578,7 @@ static PHYSFS_sint64 zip_find_end_of_central_dir(PHYSFS_Io *io, PHYSFS_sint64 *l totalread += maxread; } /* else */ - memcpy(&extra, buf, sizeof (extra)); + memcpy(extra, buf, sizeof (extra)); for (i = maxread - 4; i > 0; i--) { diff --git a/src/physfs_miniz.h b/src/physfs_miniz.h index 489c52d..1d3a34c 100644 --- a/src/physfs_miniz.h +++ b/src/physfs_miniz.h @@ -117,6 +117,8 @@ struct tinfl_decompressor_tag #define MZ_MAX(a,b) (((a)>(b))?(a):(b)) #define MZ_MIN(a,b) (((a)<(b))?(a):(b)) #define MZ_CLEAR_OBJ(obj) memset(&(obj), 0, sizeof(obj)) +#define MZ_CLEAR_ARR(obj) memset((obj), 0, sizeof(obj)) +#define MZ_CLEAR_PTR(obj) memset((obj), 0, sizeof(*obj)) #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN #define MZ_READ_LE16(p) *((const mz_uint16 *)(p)) @@ -166,13 +168,17 @@ struct tinfl_decompressor_tag if (temp >= 0) { \ code_len = temp >> 9; \ if ((code_len) && (num_bits >= code_len)) \ - break; \ + break; \ } else if (num_bits > TINFL_FAST_LOOKUP_BITS) { \ code_len = TINFL_FAST_LOOKUP_BITS; \ do { \ temp = (pHuff)->m_tree[~temp + ((bit_buf >> code_len++) & 1)]; \ - } while ((temp < 0) && (num_bits >= (code_len + 1))); if (temp >= 0) break; \ - } TINFL_GET_BYTE(state_index, c); bit_buf |= (((tinfl_bit_buf_t)c) << num_bits); num_bits += 8; \ + } while ((temp < 0) && (num_bits >= (code_len + 1))); \ + if (temp >= 0) break; \ + } \ + TINFL_GET_BYTE(state_index, c); \ + bit_buf |= (((tinfl_bit_buf_t)c) << num_bits); \ + num_bits += 8; \ } while (num_bits < 15); /* TINFL_HUFF_DECODE() decodes the next Huffman coded symbol. It's more complex than you would initially expect because the zlib API expects the decompressor to never read */ @@ -274,13 +280,13 @@ static tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_ else { for (counter = 0; counter < 3; counter++) { TINFL_GET_BITS(11, r->m_table_sizes[counter], "\05\05\04"[counter]); r->m_table_sizes[counter] += s_min_table_sizes[counter]; } - MZ_CLEAR_OBJ(r->m_tables[2].m_code_size); for (counter = 0; counter < r->m_table_sizes[2]; counter++) { mz_uint s; TINFL_GET_BITS(14, s, 3); r->m_tables[2].m_code_size[s_length_dezigzag[counter]] = (mz_uint8)s; } + MZ_CLEAR_ARR(r->m_tables[2].m_code_size); for (counter = 0; counter < r->m_table_sizes[2]; counter++) { mz_uint s; TINFL_GET_BITS(14, s, 3); r->m_tables[2].m_code_size[s_length_dezigzag[counter]] = (mz_uint8)s; } r->m_table_sizes[2] = 19; } for ( ; (int)r->m_type >= 0; r->m_type--) { int tree_next, tree_cur; tinfl_huff_table *pTable; - mz_uint i, j, used_syms, total, sym_index, next_code[17], total_syms[16]; pTable = &r->m_tables[r->m_type]; MZ_CLEAR_OBJ(total_syms); MZ_CLEAR_OBJ(pTable->m_look_up); MZ_CLEAR_OBJ(pTable->m_tree); + mz_uint i, j, used_syms, total, sym_index, next_code[17], total_syms[16]; pTable = &r->m_tables[r->m_type]; MZ_CLEAR_ARR(total_syms); MZ_CLEAR_ARR(pTable->m_look_up); MZ_CLEAR_ARR(pTable->m_tree); for (i = 0; i < r->m_table_sizes[r->m_type]; ++i) total_syms[pTable->m_code_size[i]]++; used_syms = 0, total = 0; next_code[0] = next_code[1] = 0; for (i = 1; i <= 15; ++i) { used_syms += total_syms[i]; next_code[i + 1] = (total = ((total + total_syms[i]) << 1)); }