From 45a62b2d46523c15a7d2bc7f52db2b756b40df26 Mon Sep 17 00:00:00 2001 From: kmu Date: Wed, 11 Dec 2019 10:44:56 -0600 Subject: fix and address comments --- src/H5B2cache.c | 3 +++ src/H5C.c | 2 +- src/H5Dchunk.c | 11 +++++------ src/H5EAcache.c | 4 ++++ src/H5FAcache.c | 2 ++ test/cache_tagging.c | 2 ++ test/th5s.c | 15 ++++++++------- tools/lib/h5diff.c | 12 +++--------- tools/lib/h5diff_attr.c | 12 +++--------- tools/src/h5import/h5import.c | 4 ++-- tools/test/h5repack/h5repackgentest.c | 2 +- 11 files changed, 34 insertions(+), 35 deletions(-) diff --git a/src/H5B2cache.c b/src/H5B2cache.c index 09bb389..65286e6 100644 --- a/src/H5B2cache.c +++ b/src/H5B2cache.c @@ -398,6 +398,7 @@ H5B2__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED le *image++ = H5B2_HDR_VERSION; /* B-tree type */ + HDassert(hdr->cls->id <= 255); *image++ = (uint8_t)hdr->cls->id; /* Node size (in bytes) */ @@ -818,6 +819,7 @@ H5B2__cache_int_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED le *image++ = H5B2_INT_VERSION; /* B-tree type */ + HDassert(internal->hdr->cls->id <= 255); *image++ = (uint8_t)internal->hdr->cls->id; HDassert((size_t)(image - (uint8_t *)_image) == (H5B2_INT_PREFIX_SIZE - H5B2_SIZEOF_CHKSUM)); @@ -1219,6 +1221,7 @@ H5B2__cache_leaf_serialize(const H5F_t H5_ATTR_UNUSED *f, void *_image, size_t H *image++ = H5B2_LEAF_VERSION; /* B-tree type */ + HDassert(leaf->hdr->cls->id <= 255); *image++ = (uint8_t)leaf->hdr->cls->id; HDassert((size_t)(image - (uint8_t *)_image) == (H5B2_LEAF_PREFIX_SIZE - H5B2_SIZEOF_CHKSUM)); diff --git a/src/H5C.c b/src/H5C.c index d6e2147..e530eef 100644 --- a/src/H5C.c +++ b/src/H5C.c @@ -3856,7 +3856,7 @@ H5C__unpin_entry_real(H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr, { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC_NOERR + FUNC_ENTER_STATIC /* Sanity checking */ HDassert(cache_ptr); diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index db234bb..66b6676 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -2179,7 +2179,7 @@ H5D__create_chunk_mem_map_1d(const H5D_chunk_map_t *fm) /* Iterate over each chunk in the chunk list */ curr_node = H5SL_first(fm->sel_chunks); while(curr_node) { - hsize_t schunk_points; /* Number of elements in chunk selection */ + hsize_t chunk_points; /* Number of elements in chunk selection */ hsize_t tmp_count = 1; /* Get pointer to chunk's information */ @@ -2190,12 +2190,12 @@ H5D__create_chunk_mem_map_1d(const H5D_chunk_map_t *fm) if((chunk_info->mspace = H5S_copy(fm->mem_space, TRUE, FALSE)) == NULL) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy memory space") - schunk_points = H5S_GET_SELECT_NPOINTS(chunk_info->fspace); + chunk_points = (hsize_t)H5S_GET_SELECT_NPOINTS(chunk_info->fspace); - if(H5S_select_hyperslab(chunk_info->mspace, H5S_SELECT_SET, mem_sel_start, NULL, &tmp_count, &schunk_points) < 0) + if(H5S_select_hyperslab(chunk_info->mspace, H5S_SELECT_SET, mem_sel_start, NULL, &tmp_count, &chunk_points) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSELECT, FAIL, "can't create chunk memory selection") - mem_sel_start[0] += schunk_points; + mem_sel_start[0] += chunk_points; /* Get the next chunk node in the skip list */ curr_node = H5SL_next(curr_node); @@ -5665,7 +5665,6 @@ H5D__chunk_addrmap_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) H5D_chunk_it_ud2_t *udata = (H5D_chunk_it_ud2_t *)_udata; /* User data for callback */ unsigned rank = udata->common.layout->ndims - 1; /* # of dimensions of dataset */ hsize_t chunk_index; - int ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -5675,7 +5674,7 @@ H5D__chunk_addrmap_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) /* Set it in the userdata to return */ udata->chunk_addr[chunk_index] = chunk_rec->chunk_addr; - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(H5_ITER_CONT) } /* H5D__chunk_addrmap_cb() */ diff --git a/src/H5EAcache.c b/src/H5EAcache.c index 7b1968e..1fd9c44 100644 --- a/src/H5EAcache.c +++ b/src/H5EAcache.c @@ -487,6 +487,7 @@ H5EA__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED le *image++ = H5EA_HDR_VERSION; /* Extensible array type */ + HDassert(hdr->cparam.cls->id <= 255); *image++ = (uint8_t)hdr->cparam.cls->id; /* General array creation/configuration information */ @@ -875,6 +876,7 @@ H5EA__cache_iblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED *image++ = H5EA_IBLOCK_VERSION; /* Extensible array type */ + HDassert(iblock->hdr->cparam.cls->id <= 255); *image++ = (uint8_t)iblock->hdr->cparam.cls->id; /* Address of array header for array which owns this block */ @@ -1284,6 +1286,7 @@ H5EA__cache_sblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED *image++ = H5EA_SBLOCK_VERSION; /* Extensible array type */ + HDassert(sblock->hdr->cparam.cls->id <= 255); *image++ = (uint8_t)sblock->hdr->cparam.cls->id; /* Address of array header for array which owns this block */ @@ -1698,6 +1701,7 @@ H5EA__cache_dblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED *image++ = H5EA_DBLOCK_VERSION; /* Extensible array type */ + HDassert(dblock->hdr->cparam.cls->id <= 255); *image++ = (uint8_t)dblock->hdr->cparam.cls->id; /* Address of array header for array which owns this block */ diff --git a/src/H5FAcache.c b/src/H5FAcache.c index e142ae2..2f0d1b4 100644 --- a/src/H5FAcache.c +++ b/src/H5FAcache.c @@ -417,6 +417,7 @@ H5FA__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED le *image++ = H5FA_HDR_VERSION; /* Fixed array type */ + HDassert(hdr->cparam.cls->id <= 255); *image++ = (uint8_t)hdr->cparam.cls->id; /* General array creation/configuration information */ @@ -805,6 +806,7 @@ H5FA__cache_dblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED *image++ = H5FA_DBLOCK_VERSION; /* Fixed array type */ + HDassert(dblock->hdr->cparam.cls->id <= 255); *image++ = (uint8_t)dblock->hdr->cparam.cls->id; /* Address of array header for array which owns this block */ diff --git a/test/cache_tagging.c b/test/cache_tagging.c index 7ce4e88..dad9426 100644 --- a/test/cache_tagging.c +++ b/test/cache_tagging.c @@ -3836,12 +3836,14 @@ check_invalid_tag_application(void) return 0; +#if 0 error: #if H5C_DO_TAGGING_SANITY_CHECKS if(api_ctx_pushed) H5CX_pop(); #endif /* H5C_DO_TAGGING_SANITY_CHECKS */ return 1; +#endif } /* check_invalid_tag_application */ diff --git a/test/th5s.c b/test/th5s.c index 5ef5368..7e1e547 100644 --- a/test/th5s.c +++ b/test/th5s.c @@ -1583,7 +1583,7 @@ test_h5s_encode1(void) ****************************************************************/ static herr_t test_h5s_check_encoding(hid_t in_fapl, hid_t in_sid, - uint32_t expected_version, uint32_t expected_enc_size, hbool_t expected_to_fail) + uint32_t expected_version, uint8_t expected_enc_size, hbool_t expected_to_fail) { char *buf = NULL; /* Pointer to the encoded buffer */ size_t buf_size; /* Size of the encoded buffer */ @@ -1697,7 +1697,7 @@ test_h5s_encode_regular_hyper(H5F_libver_t low, H5F_libver_t high) unsigned unlim; /* H5S_UNLIMITED setting or not */ herr_t ret; /* Generic return value */ uint32_t expected_version = 0; /* Expected version for selection info */ - uint32_t expected_enc_size = 0; /* Expected encoded size for selection info */ + uint8_t expected_enc_size = 0; /* Expected encoded size for selection info */ /* Output message about test being performed */ MESSAGE(5, ("Testing Dataspace encoding of regular hyperslabs\n")); @@ -1739,12 +1739,12 @@ test_h5s_encode_regular_hyper(H5F_libver_t low, H5F_libver_t high) case CONFIG_16: stride = POWER16 - 1; block = 4; - expected_enc_size = expected_version == 3 ? 2 : 4; + expected_enc_size = (uint8_t)(expected_version == 3 ? 2 : 4); break; case CONFIG_32: stride = POWER32 - 1; block = 4; - expected_enc_size = expected_version == 3 ? 4 : 8; + expected_enc_size = (uint8_t)(expected_version == 3 ? 4 : 8); break; default: @@ -1765,12 +1765,12 @@ test_h5s_encode_regular_hyper(H5F_libver_t low, H5F_libver_t high) case CONFIG_16: stride = POWER16 - 1; block = POWER16 - 2; - expected_enc_size = expected_version == 3 ? 2 : 4; + expected_enc_size = (uint8_t)(expected_version == 3 ? 2 : 4); break; case CONFIG_32: stride = POWER32 - 1; block = POWER32 - 2; - expected_enc_size = expected_version == 3 ? 4 : 8; + expected_enc_size = (uint8_t)(expected_version == 3 ? 4 : 8); break; default: HDassert(0); @@ -1984,7 +1984,8 @@ test_h5s_encode_irregular_hyper(H5F_libver_t low, H5F_libver_t high) VERIFY(is_regular, FALSE, "H5Sis_regular_hyperslab"); /* Verify the version and encoded size expected for the configuration */ - ret = test_h5s_check_encoding(fapl, sid, expected_version, expected_enc_size, expected_to_fail); + HDassert(expected_enc_size <= 255); + ret = test_h5s_check_encoding(fapl, sid, expected_version, (uint8_t)expected_enc_size, expected_to_fail); CHECK(ret, FAIL, "test_h5s_check_encoding"); } /* for config */ diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c index 5acdde8..d0371c7 100644 --- a/tools/lib/h5diff.c +++ b/tools/lib/h5diff.c @@ -907,15 +907,9 @@ h5diff(const char *fname1, parallel_print("file1 file2\n"); parallel_print("---------------------------------------\n"); for(u = 0; u < match_list->nobjs; u++) { - char c1, c2; - if (match_list->objs[u].flags[0]) - c1 = 'x'; - else - c1 = ' '; - if (match_list->objs[u].flags[1]) - c2 = 'x'; - else - c2 = ' '; + int c1, c2; + c1 = (match_list->objs[u].flags[0]) ? 'x' : ' '; + c2 = (match_list->objs[u].flags[1]) ? 'x' : ' '; parallel_print("%5c %6c %-15s\n", c1, c2, match_list->objs[u].name); } /* end for */ parallel_print ("\n"); diff --git a/tools/lib/h5diff_attr.c b/tools/lib/h5diff_attr.c index a648be1..8f5ab0f 100644 --- a/tools/lib/h5diff_attr.c +++ b/tools/lib/h5diff_attr.c @@ -273,15 +273,9 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t parallel_print(" obj1 obj2\n"); parallel_print(" --------------------------------------\n"); for(i = 0; i < (unsigned int) table_lp->nattrs; i++) { - char c1, c2; - if (table_lp->attrs[i].exist[0]) - c1 = 'x'; - else - c1 = ' '; - if (table_lp->attrs[i].exist[1]) - c2 = 'x'; - else - c2 = ' '; + int c1, c2; + c1 = (table_lp->attrs[i].exist[0]) ? 'x' : ' '; + c2 = (table_lp->attrs[i].exist[1]) ? 'x' : ' '; parallel_print("%5c %6c %-15s\n", c1, c2, table_lp->attrs[i].name); } /* end for */ } diff --git a/tools/src/h5import/h5import.c b/tools/src/h5import/h5import.c index 179dac4..f2e264c 100644 --- a/tools/src/h5import/h5import.c +++ b/tools/src/h5import/h5import.c @@ -4709,12 +4709,12 @@ static int process(struct Options *opt) uint16_t swap_uint16(uint16_t val) { - return (uint16_t)(((val & 0xff) << 8) | ((val & 0xff00) >> 8)); + return (uint16_t)((val << 8) | (val >> 8)); } int16_t swap_int16(int16_t val) { - return (uint16_t)(((val & 0xff) << 8) | ((val & 0xff00) >> 8)); + return (uint16_t)((val << 8) | ((val >> 8) & 0xFF)); } uint32_t swap_uint32(uint32_t val) diff --git a/tools/test/h5repack/h5repackgentest.c b/tools/test/h5repack/h5repackgentest.c index c2398b6..77fb28a 100644 --- a/tools/test/h5repack/h5repackgentest.c +++ b/tools/test/h5repack/h5repackgentest.c @@ -266,7 +266,7 @@ generate_uint8be(hbool_t external) { for (i = 0, n = 0; i < dims[0]; i++) { for (j = 0; j < dims[1]; j++) { for (k = 0; k < dims[2]; k++, n++) { - H5_CHECKED_ASSIGN(wdata[n], uint8_t, n * ((n & 1) ? (-1) : (1)), int); + wdata[n] = (uint8_t)((n & 1) ? -n : n); } } } -- cgit v0.12