diff options
author | Dana Robinson <43805+derobins@users.noreply.github.com> | 2021-05-21 19:38:34 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-21 19:38:34 (GMT) |
commit | 8a3dfc151743d4f2b94adbc2982710ab1728d1b0 (patch) | |
tree | 3f299a9964d0df40d69015f2ebce63182e914485 /test/chunk_info.c | |
parent | 9ed46a47c2aea4fc22f40aee93709f3cf2bcc404 (diff) | |
download | hdf5-8a3dfc151743d4f2b94adbc2982710ab1728d1b0.zip hdf5-8a3dfc151743d4f2b94adbc2982710ab1728d1b0.tar.gz hdf5-8a3dfc151743d4f2b94adbc2982710ab1728d1b0.tar.bz2 |
Fixes a minor valgrind issue in the chunk_info test (#675)
* Fixes a minor valgrind issue in the chunk_info test
The chunk_info test incorrectly set the number of bytes in a compressed
buffer, which caused valgrind to complain about writing uninitialized
bytes.
* Committing clang-format changes
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'test/chunk_info.c')
-rw-r--r-- | test/chunk_info.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/test/chunk_info.c b/test/chunk_info.c index 7f39557..cdbd762 100644 --- a/test/chunk_info.c +++ b/test/chunk_info.c @@ -449,7 +449,7 @@ error: * Return: Success: SUCCEED * Failure: FAIL * - * Note: Note that the dataspace argument in these new functions are + * Note: Note that the dataspace argument in these new functions is * currently not used. The functionality involved the dataspace * will be implemented in the next version. * @@ -486,10 +486,10 @@ test_get_chunk_info_highest_v18(hid_t fapl) hsize_t offset[2] = {0, 0}; /* Offset coordinates of a chunk */ #ifdef H5_HAVE_FILTER_DEFLATE const Bytef *z_src = (const Bytef *)(direct_buf); - Bytef * z_dst; /*destination buffer */ + Bytef * z_dst; /* Destination buffer */ uLongf z_dst_nbytes = (uLongf)DEFLATE_SIZE_ADJUST(CHK_SIZE); uLong z_src_nbytes = (uLong)CHK_SIZE; -#endif /* end H5_HAVE_FILTER_DEFLATE */ +#endif void * inbuf = NULL; /* Pointer to new buffer */ hsize_t chunk_size = CHK_SIZE; /* Size of a chunk, can be compressed or not */ hsize_t ii, jj; /* Array indices */ @@ -544,14 +544,15 @@ test_get_chunk_info_highest_v18(hid_t fapl) /* Allocate input (compressed) buffer */ inbuf = HDmalloc(z_dst_nbytes); - /* Set chunk size to the compressed chunk size and the chunk point - to the compressed data chunk */ - chunk_size = (hsize_t)z_dst_nbytes; - z_dst = (Bytef *)inbuf; + /* zlib-friendly alias for the input buffer */ + z_dst = (Bytef *)inbuf; /* Perform compression from the source to the destination buffer */ ret = compress2(z_dst, &z_dst_nbytes, z_src, z_src_nbytes, aggression); + /* Set the chunk size to the compressed chunk size */ + chunk_size = (hsize_t)z_dst_nbytes; + /* Check for various zlib errors */ if (Z_BUF_ERROR == ret) { HDfprintf(stderr, "overflow"); |