Skip to content

Commit 72b352b

Browse files
hyokleeclaude
andauthored
fix: zlib-ng build error on mingw (#6402)
Fixed integer size mismatch in Windows builds in issue #5730. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent efe6bd8 commit 72b352b

5 files changed

Lines changed: 35 additions & 14 deletions

File tree

src/H5Zdeflate.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,14 @@ H5Z__filter_deflate(unsigned flags, size_t cd_nelmts, const unsigned cd_values[]
173173
const Bytef *z_src = (const Bytef *)(*buf);
174174
Bytef *z_dst; /*destination buffer */
175175
#if defined(H5_HAVE_ZLIBNG_H)
176-
uLongf z_dst_buf_size = (uLongf)zng_compressBound(nbytes);
176+
size_t z_dst_buf_size = zng_compressBound(nbytes); /* 5730 */
177+
size_t z_dst_nbytes = z_dst_buf_size;
177178
#else
178179
uLongf z_dst_buf_size = (uLongf)compressBound(nbytes);
180+
uLongf z_dst_nbytes = z_dst_buf_size;
179181
#endif
180-
uLongf z_dst_nbytes = z_dst_buf_size;
181-
uLong z_src_nbytes = (uLong)nbytes;
182-
int aggression; /* Compression aggression setting */
182+
uLong z_src_nbytes = (uLong)nbytes;
183+
int aggression; /* Compression aggression setting */
183184

184185
/* Set the compression aggression level */
185186
H5_CHECKED_ASSIGN(aggression, int, cd_values[0], unsigned);

test/chunk_info.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,6 @@ test_get_chunk_info_highest_v18(hid_t fapl)
490490
void *inbuf = NULL; /* Pointer to new buffer */
491491
hsize_t chunk_size = CHK_SIZE; /* Size of a chunk, can be compressed or not */
492492
hsize_t ii, jj; /* Array indices */
493-
int n; /* Used as chunk index, but int to avoid conversion warning */
494493
herr_t ret; /* Temporary returned value for verifying failure */
495494

496495
TESTING("getting chunk information in file with version prior to 1.10");
@@ -547,7 +546,11 @@ test_get_chunk_info_highest_v18(hid_t fapl)
547546

548547
/* Perform compression from the source to the destination buffer */
549548
#if defined(H5_HAVE_ZLIBNG_H)
550-
ret = zng_compress2(z_dst, &z_dst_nbytes, z_src, z_src_nbytes, aggression);
549+
{
550+
size_t z_dst_nbytes_sz = (size_t)z_dst_nbytes;
551+
ret = zng_compress2(z_dst, &z_dst_nbytes_sz, z_src, z_src_nbytes, aggression);
552+
z_dst_nbytes = (uLongf)z_dst_nbytes_sz;
553+
}
551554
#else
552555
ret = compress2(z_dst, &z_dst_nbytes, z_src, z_src_nbytes, aggression);
553556
#endif
@@ -578,9 +581,8 @@ test_get_chunk_info_highest_v18(hid_t fapl)
578581
/* Write only NUM_CHUNKS_WRITTEN chunks at the following logical coords:
579582
* (0,2) (0,3) (1,2) (1,3)
580583
*/
581-
n = 0;
582584
for (ii = START_CHK_X; ii < END_CHK_X; ii++)
583-
for (jj = START_CHK_Y; jj < END_CHK_Y; jj++, n++) {
585+
for (jj = START_CHK_Y; jj < END_CHK_Y; jj++) {
584586
offset[0] = ii * CHUNK_NX;
585587
offset[1] = jj * CHUNK_NY;
586588
ret = H5Dwrite_chunk(dset, H5P_DEFAULT, flt_msk, offset, chunk_size, (void *)inbuf);

test/direct_chunk.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,11 @@ test_direct_chunk_write(hid_t file)
212212

213213
/* Perform compression from the source to the destination buffer */
214214
#if defined(H5_HAVE_ZLIBNG_H)
215-
ret = zng_compress2(z_dst, &z_dst_nbytes, z_src, z_src_nbytes, aggression);
215+
{
216+
size_t z_dst_nbytes_sz = (size_t)z_dst_nbytes;
217+
ret = zng_compress2(z_dst, &z_dst_nbytes_sz, z_src, z_src_nbytes, aggression);
218+
z_dst_nbytes = (uLongf)z_dst_nbytes_sz;
219+
}
216220
#else
217221
ret = compress2(z_dst, &z_dst_nbytes, z_src, z_src_nbytes, aggression);
218222
#endif
@@ -295,7 +299,11 @@ test_direct_chunk_write(hid_t file)
295299

296300
/* Perform compression from the source to the destination buffer */
297301
#if defined(H5_HAVE_ZLIBNG_H)
298-
ret = zng_compress2(z_dst, &z_dst_nbytes, z_src, z_src_nbytes, aggression);
302+
{
303+
size_t z_dst_nbytes_sz = (size_t)z_dst_nbytes;
304+
ret = zng_compress2(z_dst, &z_dst_nbytes_sz, z_src, z_src_nbytes, aggression);
305+
z_dst_nbytes = (uLongf)z_dst_nbytes_sz;
306+
}
299307
#else
300308
ret = compress2(z_dst, &z_dst_nbytes, z_src, z_src_nbytes, aggression);
301309
#endif
@@ -1686,7 +1694,10 @@ test_direct_chunk_read_no_cache(hid_t file)
16861694

16871695
/* Perform decompression from the source to the destination buffer */
16881696
#if defined(H5_HAVE_ZLIBNG_H)
1689-
ret = zng_uncompress(z_dst, &z_dst_nbytes, z_src, z_src_nbytes);
1697+
{
1698+
size_t z_dst_nbytes_sz = (size_t)z_dst_nbytes;
1699+
ret = zng_uncompress(z_dst, &z_dst_nbytes_sz, z_src, z_src_nbytes);
1700+
}
16901701
#else
16911702
ret = uncompress(z_dst, &z_dst_nbytes, z_src, z_src_nbytes);
16921703
#endif
@@ -1892,7 +1903,10 @@ test_direct_chunk_read_cache(hid_t file, bool flush)
18921903

18931904
/* Perform decompression from the source to the destination buffer */
18941905
#if defined(H5_HAVE_ZLIBNG_H)
1895-
ret = zng_uncompress(z_dst, &z_dst_nbytes, z_src, z_src_nbytes);
1906+
{
1907+
size_t z_dst_nbytes_sz = (size_t)z_dst_nbytes;
1908+
ret = zng_uncompress(z_dst, &z_dst_nbytes_sz, z_src, z_src_nbytes);
1909+
}
18961910
#else
18971911
ret = uncompress(z_dst, &z_dst_nbytes, z_src, z_src_nbytes);
18981912
#endif

tools/test/perform/direct_write_perf.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,9 @@ create_file(hid_t fapl_id)
245245

246246
/* Perform compression from the source to the destination buffer */
247247
#if defined(H5_HAVE_ZLIBNG_H)
248-
ret = zng_compress2(z_dst, &z_dst_nbytes, z_src, z_src_nbytes, aggression);
248+
size_t z_dst_nbytes_sz = (size_t)z_dst_nbytes;
249+
ret = zng_compress2(z_dst, &z_dst_nbytes_sz, z_src, z_src_nbytes, aggression);
250+
z_dst_nbytes = (uLongf)z_dst_nbytes_sz;
249251
#else
250252
ret = compress2(z_dst, &z_dst_nbytes, z_src, z_src_nbytes, aggression);
251253
#endif

tools/test/perform/zip_perf.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,9 @@ static void
166166
compress_buffer(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)
167167
{
168168
#if defined(H5_HAVE_ZLIBNG_H)
169-
int rc = zng_compress2(dest, destLen, source, sourceLen, compress_level);
169+
size_t destLen_sz = (size_t)*destLen;
170+
int rc = zng_compress2(dest, &destLen_sz, source, sourceLen, compress_level);
171+
*destLen = (uLongf)destLen_sz;
170172
#else
171173
int rc = compress2(dest, destLen, source, sourceLen, compress_level);
172174
#endif

0 commit comments

Comments
 (0)