diff options
-rw-r--r-- | src/H5A.c | 7 | ||||
-rw-r--r-- | src/H5Aint.c | 10 | ||||
-rw-r--r-- | src/H5Dfill.c | 12 | ||||
-rw-r--r-- | src/H5F.c | 14 | ||||
-rw-r--r-- | src/H5FDsec2.c | 7 | ||||
-rw-r--r-- | src/H5Faccum.c | 3 | ||||
-rw-r--r-- | src/H5Gent.c | 4 | ||||
-rw-r--r-- | src/H5HFtiny.c | 3 | ||||
-rw-r--r-- | src/H5Ocopy.c | 10 | ||||
-rw-r--r-- | src/H5Odtype.c | 2 | ||||
-rw-r--r-- | src/H5Olayout.c | 11 | ||||
-rwxr-xr-x | src/H5SM.c | 2 | ||||
-rw-r--r-- | src/H5SMcache.c | 5 | ||||
-rw-r--r-- | src/H5SMmessage.c | 4 | ||||
-rw-r--r-- | src/H5Tvlen.c | 171 | ||||
-rw-r--r-- | src/H5Zdeflate.c | 25 | ||||
-rw-r--r-- | src/H5Zscaleoffset.c | 13 | ||||
-rw-r--r-- | test/cmpd_dset.c | 64 | ||||
-rw-r--r-- | test/dsets.c | 27 | ||||
-rw-r--r-- | test/dt_arith.c | 415 | ||||
-rw-r--r-- | test/dtypes.c | 4 | ||||
-rw-r--r-- | test/fillval.c | 2 | ||||
-rw-r--r-- | test/gheap.c | 69 | ||||
-rw-r--r-- | test/hyperslab.c | 30 | ||||
-rwxr-xr-x | test/objcopy.c | 33 | ||||
-rw-r--r-- | test/pool.c | 4 | ||||
-rw-r--r-- | test/stab.c | 2 | ||||
-rw-r--r-- | test/tattr.c | 16 | ||||
-rw-r--r-- | test/th5s.c | 4 | ||||
-rw-r--r-- | test/tsohm.c | 198 |
30 files changed, 677 insertions, 494 deletions
@@ -2424,18 +2424,19 @@ H5A_close(H5A_t *attr) HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release object header info") /* Reference count can be 0. It only happens when H5A_create fails. */ - if(1 >= attr->shared->nrefs) { + if(attr->shared->nrefs <= 1) { /* Free dynamicly allocated items */ if(H5A_free(attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release attribute info") /* Destroy shared attribute struct */ attr->shared = H5FL_FREE(H5A_shared_t, attr->shared); - } else if(attr->shared->nrefs > 1) { + } /* end if */ + else { /* There are other references to the shared part of the attribute. * Only decrement the reference count. */ --attr->shared->nrefs; - } + } /* end else */ /* Free group hierarchy path */ if(H5G_name_free(&(attr->path)) < 0) diff --git a/src/H5Aint.c b/src/H5Aint.c index 81b5c60..b57896e 100644 --- a/src/H5Aint.c +++ b/src/H5Aint.c @@ -1149,8 +1149,8 @@ H5A_dense_copy_file_cb(const H5A_t *attr_src, void *_udata) HDassert(udata->file); HDassert(udata->cpy_info); - if ( NULL == (attr_dst=H5A_attr_copy_file(attr_src, udata->file, - udata->recompute_size, udata->cpy_info, udata->dxpl_id))) + if(NULL == (attr_dst = H5A_attr_copy_file(attr_src, udata->file, + udata->recompute_size, udata->cpy_info, udata->dxpl_id))) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy attribute") /* Reset shared location information */ @@ -1162,10 +1162,8 @@ H5A_dense_copy_file_cb(const H5A_t *attr_src, void *_udata) HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, H5_ITER_ERROR, "unable to add to dense storage") done: - if(attr_dst) { - (void)H5A_free(attr_dst); - attr_dst = H5FL_FREE(H5A_t, attr_dst); - } /* end if */ + if(attr_dst && H5A_close(attr_dst) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close destination attribute") FUNC_LEAVE_NOAPI(ret_value) } /* end H5A_dense_copy_file_cb() */ diff --git a/src/H5Dfill.c b/src/H5Dfill.c index 467ce4b..cf78b94 100644 --- a/src/H5Dfill.c +++ b/src/H5Dfill.c @@ -585,7 +585,7 @@ H5D_fill_refill_vl(H5D_fill_buf_info_t *fb_info, size_t nelmts, hid_t dxpl_id) HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "data type conversion failed") /* Replicate the fill value into the cached buffer */ - H5V_array_fill(fb_info->fill_buf, fb_info->fill_buf, fb_info->mem_elmt_size, nelmts); + H5V_array_fill((void *)((unsigned char *)fb_info->fill_buf + fb_info->mem_elmt_size), fb_info->fill_buf, fb_info->mem_elmt_size, (nelmts - 1)); /* Reset the entire background buffer, if necessary */ if(H5T_path_bkg(fb_info->mem_to_dset_tpath)) @@ -606,12 +606,14 @@ H5D_fill_refill_vl(H5D_fill_buf_info_t *fb_info, size_t nelmts, hid_t dxpl_id) HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "data type conversion failed") done: - if (buf) { + if(buf) { /* Free dynamically allocated VL elements in fill buffer */ - if (fb_info->fill->type) - H5T_vlen_reclaim_elmt(buf, fb_info->fill->type, dxpl_id); + if(fb_info->fill->type) + if(H5T_vlen_reclaim_elmt(buf, fb_info->fill->type, dxpl_id) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't reclaim vlen element") else - H5T_vlen_reclaim_elmt(buf, fb_info->mem_type, dxpl_id); + if(H5T_vlen_reclaim_elmt(buf, fb_info->mem_type, dxpl_id) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't reclaim vlen element") /* Free temporary fill buffer */ if(fb_info->fill_free_func) @@ -1191,12 +1191,18 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, tent_flags = flags; if(NULL == (lf = H5FD_open(name, tent_flags, fapl_id, HADDR_UNDEF))) { - if(tent_flags == flags) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file") + if(tent_flags == flags) { + time_t mytime = HDtime(NULL); + + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: time = %s, name = '%s', tent_flags = %x", HDctime(&mytime), name, tent_flags) + } /* end if */ H5E_clear_stack(NULL); tent_flags = flags; - if(NULL == (lf = H5FD_open(name, tent_flags, fapl_id, HADDR_UNDEF))) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file") + if(NULL == (lf = H5FD_open(name, tent_flags, fapl_id, HADDR_UNDEF))) { + time_t mytime = HDtime(NULL); + + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: time = %s, name = '%s', tent_flags = %x", HDctime(&mytime), name, tent_flags) + } /* end if */ } /* end if */ /* Is the file already open? */ diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c index 7e54063..d9fa4d9 100644 --- a/src/H5FDsec2.c +++ b/src/H5FDsec2.c @@ -356,9 +356,8 @@ H5FD_sec2_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) /* Open the file */ if((fd = HDopen(name, o_flags, 0666)) < 0) { int myerrno = errno; - time_t mytime = HDtime(NULL); - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: time = %s, name = '%s', errno = %d, error message = '%s', flags = %x, o_flags = %x", HDctime(&mytime), name, myerrno, HDstrerror(myerrno), flags, (unsigned)o_flags); + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: name = '%s', errno = %d, error message = '%s', flags = %x, o_flags = %x", name, myerrno, HDstrerror(myerrno), flags, (unsigned)o_flags); } /* end if */ if(HDfstat(fd, &sb) < 0) HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, NULL, "unable to fstat file") @@ -822,9 +821,9 @@ H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, had if(!H5F_addr_defined(addr)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined, addr = %llu", (unsigned long long)addr) if(REGION_OVERFLOW(addr, size)) - HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu", (unsigned long long)addr) + HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu, size = %llu", (unsigned long long)addr, (unsigned long long)size) if((addr + size) > file->eoa) - HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu", (unsigned long long)addr) + HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu, size = %llu, eoa = %llu", (unsigned long long)addr, (unsigned long long)size, (unsigned long long)file->eoa) /* Seek to the correct location */ if((addr != file->pos || OP_WRITE != file->op) && diff --git a/src/H5Faccum.c b/src/H5Faccum.c index c170671..975a6e8 100644 --- a/src/H5Faccum.c +++ b/src/H5Faccum.c @@ -648,6 +648,9 @@ HDmemset(f->shared->accum.buf + clear_size, 0, (f->shared->accum.alloc_size - cl /* Note the new buffer size */ f->shared->accum.alloc_size = new_size; +#ifdef H5_CLEAR_MEMORY +HDmemset(f->shared->accum.buf + size, 0, (f->shared->accum.alloc_size - size)); +#endif /* H5_CLEAR_MEMORY */ } /* end if */ /* Update the metadata accumulator information */ diff --git a/src/H5Gent.c b/src/H5Gent.c index 69037d4..a2e6159 100644 --- a/src/H5Gent.c +++ b/src/H5Gent.c @@ -248,8 +248,8 @@ H5G_ent_encode(const H5F_t *f, uint8_t **pp, const H5G_entry_t *ent) } /* end else */ /* fill with zero */ - while(*pp < p_ret) - *(*pp)++ = 0; + if(*pp < p_ret) + HDmemset(*pp, 0, (p_ret - *pp)); *pp = p_ret; done: diff --git a/src/H5HFtiny.c b/src/H5HFtiny.c index ce91bd1..f11b6c0 100644 --- a/src/H5HFtiny.c +++ b/src/H5HFtiny.c @@ -178,6 +178,9 @@ HDfprintf(stderr, "%s: obj_size = %Zu\n", FUNC, obj_size); *id++ = enc_obj_size & H5HF_TINY_MASK_EXT_2; } /* end else */ HDmemcpy(id, obj, obj_size); +#ifdef H5_CLEAR_MEMORY +HDmemset(id + obj_size, 0, (hdr->id_len - (1 + hdr->tiny_len_extended + obj_size))); +#endif /* H5_CLEAR_MEMORY */ /* Update statistics about heap */ hdr->tiny_size += obj_size; diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c index 2238be2..4419bd5 100644 --- a/src/H5Ocopy.c +++ b/src/H5Ocopy.c @@ -575,7 +575,15 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */, addr_new = oh_dst->chunk[0].addr; /* Create memory image for the new chunk */ - if(NULL == (oh_dst->chunk[0].image = H5FL_BLK_MALLOC(chunk_image, (size_t)dst_oh_size))) + /* Note: we use calloc() instead of malloc() here because older versions of + * some messages don't initialize "unused" bytes and because we want to + * write out the same version of the object header and older versions of + * object headers aligned messages. In both those situations, it's + * complex and error-prone to determine all the proper ways/places to + * clear to zero bytes, so we just set the buffer to zero's here. + * (QAK - 2010/08/17) + */ + if(NULL == (oh_dst->chunk[0].image = H5FL_BLK_CALLOC(chunk_image, (size_t)dst_oh_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Set dest. chunk information */ diff --git a/src/H5Odtype.c b/src/H5Odtype.c index fec695e..51694a3 100644 --- a/src/H5Odtype.c +++ b/src/H5Odtype.c @@ -1272,7 +1272,7 @@ H5O_dtype_size(const H5F_t *f, const void *_mesg) /* (starting with version 3 of the datatype message, use the minimum # of bytes required) */ if(dt->shared->version >= H5O_DTYPE_VERSION_3) ret_value += offset_nbytes; /*member offset*/ - if(dt->shared->version >= H5O_DTYPE_VERSION_2) + else if(dt->shared->version == H5O_DTYPE_VERSION_2) ret_value += 4; /*member offset*/ else ret_value += 4 + /*member offset*/ diff --git a/src/H5Olayout.c b/src/H5Olayout.c index 67dbf4d..e413598 100644 --- a/src/H5Olayout.c +++ b/src/H5Olayout.c @@ -584,6 +584,7 @@ H5O_layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, H5D_copy_file_ud_t *udata = (H5D_copy_file_ud_t *)_udata; /* Dataset copying user data */ H5O_layout_t *layout_src = (H5O_layout_t *) mesg_src; H5O_layout_t *layout_dst = NULL; + hbool_t copied = FALSE; /* Whether the data was copied */ void *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_layout_copy_file) @@ -607,6 +608,7 @@ H5O_layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, /* copy compact raw data */ if(H5D_compact_copy(file_src, &layout_src->storage.u.compact, file_dst, &layout_dst->storage.u.compact, udata->src_dtype, cpy_info, dxpl_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy chunked storage") + copied = TRUE; } /* end if */ break; @@ -615,7 +617,7 @@ H5O_layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, * layout message less than version 3 because versions 1 & 2 would * truncate the dimension sizes to 32-bits of information. - QAK 5/26/04 */ - if(layout_src->version < 3) + if(layout_src->version < H5O_LAYOUT_VERSION_3) layout_dst->storage.u.contig.size = H5S_extent_nelem(udata->src_space_extent) * H5T_get_size(udata->src_dtype); @@ -623,6 +625,7 @@ H5O_layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, /* copy contiguous raw data */ if(H5D_contig_copy(file_src, &layout_src->storage.u.contig, file_dst, &layout_dst->storage.u.contig, udata->src_dtype, cpy_info, dxpl_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy contiguous storage") + copied = TRUE; } /* end if */ break; @@ -631,6 +634,7 @@ H5O_layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, /* Create chunked layout */ if(H5D_chunk_copy(file_src, &layout_src->storage.u.chunk, &layout_src->u.chunk, file_dst, &layout_dst->storage.u.chunk, udata->src_space_extent, udata->src_dtype, udata->common.src_pline, cpy_info, dxpl_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy chunked storage") + copied = TRUE; } /* end if */ break; @@ -638,8 +642,9 @@ H5O_layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "Invalid layout class") } /* end switch */ - /* Freed by copy routine */ - udata->src_dtype = NULL; + /* Check if copy routine was invoked (which frees the source datatype) */ + if(copied) + udata->src_dtype = NULL; /* Set return value */ ret_value = layout_dst; @@ -1742,7 +1742,7 @@ H5SM_delete_from_index(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, /* If this returns failure, it means that the message wasn't found. * If it succeeds, a copy of the modified message will be returned. */ - if(H5B2_modify(bt2, dxpl_id, &key, H5SM_decr_ref, &message) <0) + if(H5B2_modify(bt2, dxpl_id, &key, H5SM_decr_ref, &message) < 0) HGOTO_ERROR(H5E_SOHM, H5E_NOTFOUND, FAIL, "message not in index") /* Point to the message */ diff --git a/src/H5SMcache.c b/src/H5SMcache.c index d1912ee..ad89c85 100644 --- a/src/H5SMcache.c +++ b/src/H5SMcache.c @@ -603,7 +603,7 @@ H5SM_list_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5SM_lis if(H5SM_message_encode(p, &(list->messages[x]), &ctx) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTFLUSH, FAIL, "unable to write shared message to disk") - p+=H5SM_SOHM_ENTRY_SIZE(f); + p += H5SM_SOHM_ENTRY_SIZE(f); ++mesgs_written; } /* end if */ } /* end for */ @@ -612,6 +612,9 @@ H5SM_list_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5SM_lis /* Compute checksum on buffer */ computed_chksum = H5_checksum_metadata(buf, (size_t)(p - buf), 0); UINT32ENCODE(p, computed_chksum); +#ifdef H5_CLEAR_MEMORY +HDmemset(p, 0, (list->header->list_size - (p - buf))); +#endif /* H5_CLEAR_MEMORY */ /* Write the list to disk */ HDassert((size_t)(p - buf) <= list->header->list_size); diff --git a/src/H5SMmessage.c b/src/H5SMmessage.c index 32ded03..0d41a09 100644 --- a/src/H5SMmessage.c +++ b/src/H5SMmessage.c @@ -309,7 +309,7 @@ H5SM_message_encode(uint8_t *raw, const void *_nrecord, void *_ctx) *raw++ = 0; /* reserved (possible flags byte) */ *raw++ = (uint8_t)message->msg_type_id; UINT16ENCODE(raw, message->u.mesg_loc.index); - H5F_addr_encode_len(ctx->sizeof_addr, &raw, message->u.mesg_loc.oh_addr); + H5F_addr_encode_len((size_t)ctx->sizeof_addr, &raw, message->u.mesg_loc.oh_addr); } /* end else */ FUNC_LEAVE_NOAPI(SUCCEED) @@ -350,7 +350,7 @@ H5SM_message_decode(const uint8_t *raw, void *_nrecord, void *_ctx) raw++; /* reserved */ message->msg_type_id = *raw++; UINT16DECODE(raw, message->u.mesg_loc.index); - H5F_addr_decode_len(ctx->sizeof_addr, &raw, &message->u.mesg_loc.oh_addr); + H5F_addr_decode_len((size_t)ctx->sizeof_addr, &raw, &message->u.mesg_loc.oh_addr); } /* end else */ FUNC_LEAVE_NOAPI(SUCCEED) diff --git a/src/H5Tvlen.c b/src/H5Tvlen.c index 95f4086..f1b1f00 100644 --- a/src/H5Tvlen.c +++ b/src/H5Tvlen.c @@ -100,8 +100,6 @@ H5T_init_vlen_interface(void) * Programmer: Quincey Koziol * Thursday, May 20, 1999 * - * Modifications: - * *------------------------------------------------------------------------- */ hid_t @@ -144,8 +142,6 @@ done: * Programmer: Quincey Koziol * Tuesday, November 20, 2001 * - * Modifications: - * *------------------------------------------------------------------------- */ H5T_t * @@ -315,11 +311,6 @@ done: * Programmer: Quincey Koziol * Wednesday, June 2, 1999 * - * Modifications: Neil Fortner - * Friday, August 22, 2008 - * Changed function to be tolerant of an hvl_t that is not aligned - * properly in _vl. - * *------------------------------------------------------------------------- */ static ssize_t @@ -357,11 +348,6 @@ H5T_vlen_seq_mem_getlen(const void *_vl) * Programmer: Quincey Koziol * Saturday, June 12, 2004 * - * Modifications: Neil Fortner - * Friday, August 22, 2008 - * Changed function to be tolerant of an hvl_t that is not aligned - * properly in _vl. - * *------------------------------------------------------------------------- */ static void * @@ -399,11 +385,6 @@ H5T_vlen_seq_mem_getptr(void *_vl) * Programmer: Quincey Koziol * Saturday, November 8, 2003 * - * Modifications: Neil Fortner - * Friday, August 22, 2008 - * Changed function to be tolerant of an hvl_t that is not aligned - * properly in _vl. - * *------------------------------------------------------------------------- */ /* ARGSUSED */ @@ -442,11 +423,6 @@ H5T_vlen_seq_mem_isnull(const H5F_t UNUSED *f, void *_vl) * Programmer: Quincey Koziol * Wednesday, June 2, 1999 * - * Modifications: Neil Fortner - * Friday, August 22, 2008 - * Changed function to be tolerant of an hvl_t that is not aligned - * properly in _vl. - * *------------------------------------------------------------------------- */ /* ARGSUSED */ @@ -489,8 +465,6 @@ H5T_vlen_seq_mem_read(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_vl, void *bu * Programmer: Quincey Koziol * Wednesday, June 2, 1999 * - * Modifications: - * *------------------------------------------------------------------------- */ /* ARGSUSED */ @@ -548,8 +522,6 @@ done: * Programmer: Quincey Koziol * Saturday, November 8, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ /* ARGSUSED */ @@ -584,11 +556,6 @@ H5T_vlen_seq_mem_setnull(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_vl, void * Programmer: Quincey Koziol * Wednesday, June 2, 1999 * - * Modifications: Neil Fortner - * Friday, August 22, 2008 - * Changed function to be tolerant of a char * that is not aligned - * properly in _vl. - * *------------------------------------------------------------------------- */ static ssize_t @@ -624,12 +591,6 @@ H5T_vlen_str_mem_getlen(const void *_vl) * Programmer: Quincey Koziol * Saturday, June 12, 2004 * - * Modifications: Neil Fortner - * Friday, August 22, 2008 - * Changed function to be tolerant of a char * that is not aligned - * properly in _vl. - * Added assertion on _vl. - * *------------------------------------------------------------------------- */ static void * @@ -665,11 +626,6 @@ H5T_vlen_str_mem_getptr(void *_vl) * Programmer: Quincey Koziol * Saturday, November 8, 2003 * - * Modifications: Neil Fortner - * Friday, August 22, 2008 - * Changed function to be tolerant of a char * that is not aligned - * properly in _vl. - * *------------------------------------------------------------------------- */ /* ARGSUSED */ @@ -702,11 +658,6 @@ H5T_vlen_str_mem_isnull(const H5F_t UNUSED *f, void *_vl) * Programmer: Quincey Koziol * Wednesday, June 2, 1999 * - * Modifications: Neil Fortner - * Friday, August 22, 2008 - * Changed function to be tolerant of a char * that is not aligned - * properly in _vl. - * *------------------------------------------------------------------------- */ /* ARGSUSED */ @@ -748,8 +699,6 @@ H5T_vlen_str_mem_read(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_vl, void *bu * Programmer: Quincey Koziol * Wednesday, June 2, 1999 * - * Modifications: - * *------------------------------------------------------------------------- */ /* ARGSUSED */ @@ -797,8 +746,6 @@ done: * Programmer: Quincey Koziol * Saturday, November 8, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ /* ARGSUSED */ @@ -826,8 +773,6 @@ H5T_vlen_str_mem_setnull(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_vl, void * Programmer: Quincey Koziol * Wednesday, June 2, 1999 * - * Modifications: - * *------------------------------------------------------------------------- */ static ssize_t @@ -857,8 +802,6 @@ H5T_vlen_disk_getlen(const void *_vl) * Programmer: Quincey Koziol * Saturday, June 12, 2004 * - * Modifications: - * *------------------------------------------------------------------------- */ /* ARGSUSED */ @@ -884,8 +827,6 @@ H5T_vlen_disk_getptr(void UNUSED *vl) * Programmer: Quincey Koziol * Saturday, November 8, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ static htri_t @@ -919,8 +860,6 @@ H5T_vlen_disk_isnull(const H5F_t *f, void *_vl) * Programmer: Quincey Koziol * Wednesday, June 2, 1999 * - * Modifications: - * *------------------------------------------------------------------------- */ /* ARGSUSED */ @@ -967,29 +906,24 @@ done: * Programmer: Quincey Koziol * Wednesday, June 2, 1999 * - * Modifications: - * - * Raymond Lu - * Thursday, June 26, 2002 - * Free heap objects storing old data. - * *------------------------------------------------------------------------- */ /* ARGSUSED */ static herr_t -H5T_vlen_disk_write(H5F_t *f, hid_t dxpl_id, const H5T_vlen_alloc_info_t UNUSED *vl_alloc_info, void *_vl, void *buf, void *_bg, size_t seq_len, size_t base_size) +H5T_vlen_disk_write(H5F_t *f, hid_t dxpl_id, const H5T_vlen_alloc_info_t UNUSED *vl_alloc_info, + void *_vl, void *buf, void *_bg, size_t seq_len, size_t base_size) { - uint8_t *vl=(uint8_t *)_vl; /*Pointer to the user's hvl_t information*/ - uint8_t *bg=(uint8_t *)_bg; /*Pointer to the old data hvl_t */ + uint8_t *vl = (uint8_t *)_vl; /*Pointer to the user's hvl_t information*/ + uint8_t *bg = (uint8_t *)_bg; /*Pointer to the old data hvl_t */ H5HG_t hobjid; /* New VL sequence's heap ID */ size_t len; /* Size of new sequence on disk (in bytes) */ - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5T_vlen_disk_write) /* check parameters */ HDassert(vl); - HDassert(seq_len==0 || buf); + HDassert(seq_len == 0 || buf); HDassert(f); /* Free heap object for old data. */ @@ -1004,9 +938,9 @@ H5T_vlen_disk_write(H5F_t *f, hid_t dxpl_id, const H5T_vlen_alloc_info_t UNUSED INT32DECODE(bg, bg_hobjid.idx); /* Free heap object for old data */ - if(bg_hobjid.addr>0) { + if(bg_hobjid.addr > 0) { /* Free heap object */ - if(H5HG_remove(f, dxpl_id, &bg_hobjid)<0) + if(H5HG_remove(f, dxpl_id, &bg_hobjid) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "Unable to remove heap object") } /* end if */ } /* end if */ @@ -1015,13 +949,13 @@ H5T_vlen_disk_write(H5F_t *f, hid_t dxpl_id, const H5T_vlen_alloc_info_t UNUSED UINT32ENCODE(vl, seq_len); /* Write the VL information to disk (allocates space also) */ - len=(seq_len*base_size); - if(H5HG_insert(f,dxpl_id,len,buf,&hobjid)<0) + len = (seq_len*base_size); + if(H5HG_insert(f, dxpl_id, len, buf, &hobjid) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "Unable to write VL information") /* Encode the heap information */ - H5F_addr_encode(f,&vl,hobjid.addr); - INT32ENCODE(vl,hobjid.idx); + H5F_addr_encode(f, &vl, hobjid.addr); + INT32ENCODE(vl, hobjid.idx); done: FUNC_LEAVE_NOAPI(ret_value) @@ -1038,17 +972,15 @@ done: * Programmer: Quincey Koziol * Saturday, November 8, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t H5T_vlen_disk_setnull(H5F_t *f, hid_t dxpl_id, void *_vl, void *_bg) { - uint8_t *vl=(uint8_t *)_vl; /*Pointer to the user's hvl_t information*/ - uint8_t *bg=(uint8_t *)_bg; /*Pointer to the old data hvl_t */ - uint32_t seq_len=0; /* Sequence length */ - herr_t ret_value=SUCCEED; /* Return value */ + uint8_t *vl = (uint8_t *)_vl; /*Pointer to the user's hvl_t information*/ + uint8_t *bg = (uint8_t *)_bg; /*Pointer to the old data hvl_t */ + uint32_t seq_len = 0; /* Sequence length */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5T_vlen_disk_setnull) @@ -1057,7 +989,7 @@ H5T_vlen_disk_setnull(H5F_t *f, hid_t dxpl_id, void *_vl, void *_bg) HDassert(vl); /* Free heap object for old data. */ - if(bg!=NULL) { + if(bg != NULL) { H5HG_t bg_hobjid; /* "Background" VL info sequence's ID info */ /* Skip the length of the sequence and heap object ID from background data. */ @@ -1068,9 +1000,9 @@ H5T_vlen_disk_setnull(H5F_t *f, hid_t dxpl_id, void *_vl, void *_bg) INT32DECODE(bg, bg_hobjid.idx); /* Free heap object for old data */ - if(bg_hobjid.addr>0) { + if(bg_hobjid.addr > 0) { /* Free heap object */ - if(H5HG_remove(f, dxpl_id, &bg_hobjid)<0) + if(H5HG_remove(f, dxpl_id, &bg_hobjid) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "Unable to remove heap object") } /* end if */ } /* end if */ @@ -1079,8 +1011,8 @@ H5T_vlen_disk_setnull(H5F_t *f, hid_t dxpl_id, void *_vl, void *_bg) UINT32ENCODE(vl, seq_len); /* Encode the "nil" heap pointer information */ - H5F_addr_encode(f,&vl,(haddr_t)0); - INT32ENCODE(vl,0); + H5F_addr_encode(f, &vl, (haddr_t)0); + INT32ENCODE(vl, 0); done: FUNC_LEAVE_NOAPI(ret_value) @@ -1111,8 +1043,8 @@ done: static herr_t H5T_vlen_reclaim_recurse(void *elem, const H5T_t *dt, H5MM_free_t free_func, void *free_info) { - unsigned i; /* local index variable */ - herr_t ret_value = SUCCEED; + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5T_vlen_reclaim_recurse) @@ -1127,9 +1059,9 @@ H5T_vlen_reclaim_recurse(void *elem, const H5T_t *dt, H5MM_free_t free_func, voi void *off; /* offset of field */ /* Calculate the offset member and recurse on it */ - for(i=0; i<dt->shared->u.array.nelem; i++) { - off=((uint8_t *)elem)+i*(dt->shared->parent->shared->size); - if(H5T_vlen_reclaim_recurse(off,dt->shared->parent,free_func,free_info)<0) + for(u = 0; u < dt->shared->u.array.nelem; u++) { + off = ((uint8_t *)elem) + u * (dt->shared->parent->shared->size); + if(H5T_vlen_reclaim_recurse(off, dt->shared->parent, free_func, free_info) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "Unable to free array element") } /* end for */ } /* end if */ @@ -1137,14 +1069,14 @@ H5T_vlen_reclaim_recurse(void *elem, const H5T_t *dt, H5MM_free_t free_func, voi case H5T_COMPOUND: /* Check each field and recurse on VL, compound, enum or array ones */ - for (i=0; i<dt->shared->u.compnd.nmembs; i++) { + for(u = 0; u < dt->shared->u.compnd.nmembs; u++) { /* Recurse if it's VL, compound, enum or array */ - if(H5T_IS_COMPLEX(dt->shared->u.compnd.memb[i].type->shared->type)) { + if(H5T_IS_COMPLEX(dt->shared->u.compnd.memb[u].type->shared->type)) { void *off; /* offset of field */ /* Calculate the offset member and recurse on it */ - off=((uint8_t *)elem)+dt->shared->u.compnd.memb[i].offset; - if(H5T_vlen_reclaim_recurse(off,dt->shared->u.compnd.memb[i].type,free_func,free_info)<0) + off = ((uint8_t *)elem) + dt->shared->u.compnd.memb[u].offset; + if(H5T_vlen_reclaim_recurse(off, dt->shared->u.compnd.memb[u].type, free_func, free_info) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "Unable to free compound field") } /* end if */ } /* end for */ @@ -1152,8 +1084,8 @@ H5T_vlen_reclaim_recurse(void *elem, const H5T_t *dt, H5MM_free_t free_func, voi case H5T_VLEN: /* Recurse on the VL information if it's VL, compound, enum or array, then free VL sequence */ - if(dt->shared->u.vlen.type==H5T_VLEN_SEQUENCE) { - hvl_t *vl=(hvl_t *)elem; /* Temp. ptr to the vl info */ + if(dt->shared->u.vlen.type == H5T_VLEN_SEQUENCE) { + hvl_t *vl = (hvl_t *)elem; /* Temp. ptr to the vl info */ /* Check if there is anything actually in this sequence */ if(vl->len!=0) { @@ -1162,24 +1094,24 @@ H5T_vlen_reclaim_recurse(void *elem, const H5T_t *dt, H5MM_free_t free_func, voi void *off; /* offset of field */ /* Calculate the offset of each array element and recurse on it */ - while(vl->len>0) { - off=((uint8_t *)vl->p)+(vl->len-1)*dt->shared->parent->shared->size; - if(H5T_vlen_reclaim_recurse(off,dt->shared->parent,free_func,free_info)<0) + while(vl->len > 0) { + off = ((uint8_t *)vl->p) + (vl->len - 1) * dt->shared->parent->shared->size; + if(H5T_vlen_reclaim_recurse(off, dt->shared->parent, free_func, free_info) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "Unable to free VL element") vl->len--; } /* end while */ } /* end if */ /* Free the VL sequence */ - if(free_func!=NULL) - (*free_func)(vl->p,free_info); + if(free_func != NULL) + (*free_func)(vl->p, free_info); else H5MM_xfree(vl->p); } /* end if */ - } else if(dt->shared->u.vlen.type==H5T_VLEN_STRING) { + } else if(dt->shared->u.vlen.type == H5T_VLEN_STRING) { /* Free the VL string */ - if(free_func!=NULL) - (*free_func)(*(char **)elem,free_info); + if(free_func != NULL) + (*free_func)(*(char **)elem, free_info); else H5MM_xfree(*(char **)elem); } else { @@ -1226,7 +1158,7 @@ H5T_vlen_reclaim(void *elem, hid_t type_id, unsigned UNUSED ndim, const hsize_t { H5T_vlen_alloc_info_t *vl_alloc_info = (H5T_vlen_alloc_info_t *)op_data; /* VL allocation info from iterator */ H5T_t *dt; - herr_t ret_value; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5T_vlen_reclaim, FAIL) @@ -1235,11 +1167,12 @@ H5T_vlen_reclaim(void *elem, hid_t type_id, unsigned UNUSED ndim, const hsize_t HDassert(H5I_DATATYPE == H5I_get_type(type_id)); /* Check args */ - if (NULL==(dt=H5I_object_verify(type_id,H5I_DATATYPE))) + if(NULL == (dt = H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Pull the free function and free info pointer out of the op_data and call the recurse datatype free function */ - ret_value=H5T_vlen_reclaim_recurse(elem,dt,vl_alloc_info->free_func,vl_alloc_info->free_info); + if(H5T_vlen_reclaim_recurse(elem, dt, vl_alloc_info->free_func, vl_alloc_info->free_info) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "can't reclaim vlen elements") done: FUNC_LEAVE_NOAPI(ret_value) @@ -1289,13 +1222,13 @@ H5T_vlen_get_alloc_info(hid_t dxpl_id, H5T_vlen_alloc_info_t **vl_alloc_info) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list") /* Get the allocation functions & information */ - if (H5P_get(plist,H5D_XFER_VLEN_ALLOC_NAME,&(*vl_alloc_info)->alloc_func)<0) + if (H5P_get(plist,H5D_XFER_VLEN_ALLOC_NAME,&(*vl_alloc_info)->alloc_func) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value") - if (H5P_get(plist,H5D_XFER_VLEN_ALLOC_INFO_NAME,&(*vl_alloc_info)->alloc_info)<0) + if (H5P_get(plist,H5D_XFER_VLEN_ALLOC_INFO_NAME,&(*vl_alloc_info)->alloc_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value") - if (H5P_get(plist,H5D_XFER_VLEN_FREE_NAME,&(*vl_alloc_info)->free_func)<0) + if (H5P_get(plist,H5D_XFER_VLEN_FREE_NAME,&(*vl_alloc_info)->free_func) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value") - if (H5P_get(plist,H5D_XFER_VLEN_FREE_INFO_NAME,&(*vl_alloc_info)->free_info)<0) + if (H5P_get(plist,H5D_XFER_VLEN_FREE_INFO_NAME,&(*vl_alloc_info)->free_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value") } /* end else */ @@ -1318,8 +1251,6 @@ done: * Programmer: Mike McGreevy * May 11, 2010 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -1335,12 +1266,14 @@ H5T_vlen_reclaim_elmt(void *elem, H5T_t *dt, hid_t dxpl_id) FUNC_ENTER_NOAPI(H5T_vlen_reclaim_elmt, FAIL) /* Get VL allocation info */ - if (H5T_vlen_get_alloc_info(dxpl_id, &vl_alloc_info) < 0) + if(H5T_vlen_get_alloc_info(dxpl_id, &vl_alloc_info) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to retrieve VL allocation info") /* Recurse on buffer to free dynamic fields */ - ret_value = H5T_vlen_reclaim_recurse(elem,dt,vl_alloc_info->free_func,vl_alloc_info->free_info); + if(H5T_vlen_reclaim_recurse(elem, dt, vl_alloc_info->free_func, vl_alloc_info->free_info) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "can't reclaim vlen elements") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5T_vlen_reclaim_elmt */ + diff --git a/src/H5Zdeflate.c b/src/H5Zdeflate.c index 63e7b9a..598aa97 100644 --- a/src/H5Zdeflate.c +++ b/src/H5Zdeflate.c @@ -101,9 +101,9 @@ H5Z_filter_deflate (unsigned flags, size_t cd_nelmts, /* Set the uncompression parameters */ HDmemset(&z_strm, 0, sizeof(z_strm)); - z_strm.next_in = *buf; + z_strm.next_in = (Bytef *)*buf; H5_ASSIGN_OVERFLOW(z_strm.avail_in,nbytes,size_t,unsigned); - z_strm.next_out = outbuf; + z_strm.next_out = (Bytef *)outbuf; H5_ASSIGN_OVERFLOW(z_strm.avail_out,nalloc,size_t,unsigned); /* Initialize the uncompression routines */ @@ -155,7 +155,7 @@ H5Z_filter_deflate (unsigned flags, size_t cd_nelmts, /* Finish uncompressing the stream */ (void)inflateEnd(&z_strm); - } + } /* end if */ else { /* * Output; compress but fail if the result would be larger than the @@ -172,19 +172,20 @@ H5Z_filter_deflate (unsigned flags, size_t cd_nelmts, H5_ASSIGN_OVERFLOW(aggression,cd_values[0],unsigned,int); /* Allocate output (compressed) buffer */ - if (NULL==(z_dst=outbuf=H5MM_malloc(z_dst_nbytes))) + if(NULL == (outbuf = H5MM_malloc(z_dst_nbytes))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "unable to allocate deflate destination buffer") + z_dst = (Bytef *)outbuf; /* Perform compression from the source to the destination buffer */ - status = compress2 (z_dst, &z_dst_nbytes, z_src, z_src_nbytes, aggression); + status = compress2(z_dst, &z_dst_nbytes, z_src, z_src_nbytes, aggression); /* Check for various zlib errors */ - if (Z_BUF_ERROR==status) + if(Z_BUF_ERROR == status) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, 0, "overflow") - else if (Z_MEM_ERROR==status) - HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, 0, "deflate memory error") - else if (Z_OK!=status) - HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, 0, "other deflate error") + else if(Z_MEM_ERROR == status) + HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, 0, "deflate memory error") + else if(Z_OK != status) + HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, 0, "other deflate error") /* Successfully uncompressed the buffer */ else { /* Free the input buffer */ @@ -195,8 +196,8 @@ H5Z_filter_deflate (unsigned flags, size_t cd_nelmts, outbuf = NULL; *buf_size = nbytes; ret_value = z_dst_nbytes; - } - } + } /* end else */ + } /* end else */ done: if(outbuf) diff --git a/src/H5Zscaleoffset.c b/src/H5Zscaleoffset.c index 4bfc8b1..eb3c6e6 100644 --- a/src/H5Zscaleoffset.c +++ b/src/H5Zscaleoffset.c @@ -806,6 +806,11 @@ H5Z_set_local_scaleoffset(hid_t dcpl_id, hid_t type_id, hid_t space_id) if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") +#ifdef H5_CLEAR_MEMORY + /* Initialize the parameters to a known state */ + HDmemset(cd_values, 0, sizeof(cd_values)); +#endif /* H5_CLEAR_MEMORY */ + /* Get the filter's current parameters */ if(H5P_get_filter_by_id(dcpl_plist, H5Z_FILTER_SCALEOFFSET, &flags, &cd_nelmts, cd_values, (size_t)0, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get scaleoffset parameters") @@ -1182,6 +1187,14 @@ H5Z_filter_scaleoffset(unsigned flags, size_t cd_nelmts, const unsigned cd_value for(i = 0; i < sizeof(unsigned long long); i++) ((unsigned char *)outbuf)[5+i] = (unsigned char)((minval & ((unsigned long long)0xff << i*8)) >> i*8); +#ifdef H5_CLEAR_MEMORY + /* Zero out remaining, unused bytes */ + /* (Looks like an error in the original determination of how many + * bytes would be needed for parameters. - QAK, 2010/08/19) + */ + HDmemset(outbuf + 13, 0, (size_t)8); +#endif /* H5_CLEAR_MEMORY */ + /* special case: minbits equal to full precision */ if(minbits == p.size * 8) { HDmemcpy(outbuf + buf_offset, *buf, nbytes); diff --git a/test/cmpd_dset.c b/test/cmpd_dset.c index d565e82..08890a8 100644 --- a/test/cmpd_dset.c +++ b/test/cmpd_dset.c @@ -1811,18 +1811,18 @@ test_pack_ooo(void) TESTING("random member insertion with empty compound subtype"); /* Create inner compound type. It will be empty for the first run */ - if((sub_cmpd = H5Tcreate(H5T_COMPOUND, 4)) < 0) PACK_OOO_ERROR + if((sub_cmpd = H5Tcreate(H5T_COMPOUND, (size_t)4)) < 0) PACK_OOO_ERROR /* Create main compound type, with extra space at the end */ - if((cmpd = H5Tcreate(H5T_COMPOUND, (4 * PACK_NMEMBS) + extra_space)) < 0) PACK_OOO_ERROR + if((cmpd = H5Tcreate(H5T_COMPOUND, (size_t)((4 * PACK_NMEMBS) + extra_space))) < 0) PACK_OOO_ERROR /* Insert the compound members in the random order previously generated */ for(i=0; i<PACK_NMEMBS; i++) { sprintf(name, "%05d", i); if(i == sub_cmpd_order) { - if(H5Tinsert(cmpd, name, 4 * order[i], sub_cmpd) < 0) PACK_OOO_ERROR + if(H5Tinsert(cmpd, name, (size_t)(4 * order[i]), sub_cmpd) < 0) PACK_OOO_ERROR } else - if(H5Tinsert(cmpd, name, 4 * order[i], H5T_STD_I32BE) < 0) PACK_OOO_ERROR + if(H5Tinsert(cmpd, name, (size_t)(4 * order[i]), H5T_STD_I32BE) < 0) PACK_OOO_ERROR } /* end for */ /* Verify that the compound is not packed */ @@ -1837,18 +1837,18 @@ test_pack_ooo(void) TESTING("random member insertion with full compound subtype"); /* Complete the inner compound type */ - if(H5Tinsert(sub_cmpd, "int", 0, H5T_STD_I32LE) < 0) PACK_OOO_ERROR + if(H5Tinsert(sub_cmpd, "int", (size_t)0, H5T_STD_I32LE) < 0) PACK_OOO_ERROR /* Recreate main compound type */ - if((cmpd = H5Tcreate(H5T_COMPOUND, (4 * PACK_NMEMBS) + extra_space)) < 0) PACK_OOO_ERROR + if((cmpd = H5Tcreate(H5T_COMPOUND, (size_t)((4 * PACK_NMEMBS) + extra_space))) < 0) PACK_OOO_ERROR /* Insert the compound members in the random order previously generated */ for(i=0; i<PACK_NMEMBS; i++) { sprintf(name, "%05d", i); if(i == sub_cmpd_order) { - if(H5Tinsert(cmpd, name, 4 * order[i], sub_cmpd) < 0) PACK_OOO_ERROR + if(H5Tinsert(cmpd, name, (size_t)(4 * order[i]), sub_cmpd) < 0) PACK_OOO_ERROR } else - if(H5Tinsert(cmpd, name, 4 * order[i], H5T_STD_I32BE) < 0) PACK_OOO_ERROR + if(H5Tinsert(cmpd, name, (size_t)(4 * order[i]), H5T_STD_I32BE) < 0) PACK_OOO_ERROR } /* end for */ /* Verify that the compound is not packed */ @@ -1864,18 +1864,18 @@ test_pack_ooo(void) TESTING("reverse member insertion with empty compound subtype"); /* Create inner compound type. It will be empty for the first run */ - if((sub_cmpd = H5Tcreate(H5T_COMPOUND, 4)) < 0) PACK_OOO_ERROR + if((sub_cmpd = H5Tcreate(H5T_COMPOUND, (size_t)4)) < 0) PACK_OOO_ERROR /* Create main compound type, with extra space at the end */ - if((cmpd = H5Tcreate(H5T_COMPOUND, (4 * PACK_NMEMBS) + extra_space)) < 0) PACK_OOO_ERROR + if((cmpd = H5Tcreate(H5T_COMPOUND, (size_t)((4 * PACK_NMEMBS) + extra_space))) < 0) PACK_OOO_ERROR /* Insert the compound members in reverse order, with compound last */ for(i=0; i<PACK_NMEMBS; i++) { sprintf(name, "%05d", i); if(i == PACK_NMEMBS - 1) { - if(H5Tinsert(cmpd, name, 4 * (PACK_NMEMBS - i - 1), sub_cmpd) < 0) PACK_OOO_ERROR + if(H5Tinsert(cmpd, name, (size_t)(4 * (PACK_NMEMBS - i - 1)), sub_cmpd) < 0) PACK_OOO_ERROR } else - if(H5Tinsert(cmpd, name, 4 * (PACK_NMEMBS - i - 1), H5T_STD_I32BE) < 0) PACK_OOO_ERROR + if(H5Tinsert(cmpd, name, (size_t)(4 * (PACK_NMEMBS - i - 1)), H5T_STD_I32BE) < 0) PACK_OOO_ERROR } /* end for */ /* Verify that the compound is not packed */ @@ -1890,18 +1890,18 @@ test_pack_ooo(void) TESTING("reverse member insertion with full compound subtype"); /* Complete the inner compound type */ - if(H5Tinsert(sub_cmpd, "int", 0, H5T_STD_I32LE) < 0) PACK_OOO_ERROR + if(H5Tinsert(sub_cmpd, "int", (size_t)0, H5T_STD_I32LE) < 0) PACK_OOO_ERROR /* Recreate main compound type */ - if((cmpd = H5Tcreate(H5T_COMPOUND, (4 * PACK_NMEMBS) + extra_space)) < 0) PACK_OOO_ERROR + if((cmpd = H5Tcreate(H5T_COMPOUND, (size_t)((4 * PACK_NMEMBS) + extra_space))) < 0) PACK_OOO_ERROR /* Insert the compound members in reverse order, with compound last */ for(i=0; i<PACK_NMEMBS; i++) { sprintf(name, "%05d", i); if(i == PACK_NMEMBS - 1) { - if(H5Tinsert(cmpd, name, 4 * (PACK_NMEMBS - i - 1), sub_cmpd) < 0) PACK_OOO_ERROR + if(H5Tinsert(cmpd, name, (size_t)(4 * (PACK_NMEMBS - i - 1)), sub_cmpd) < 0) PACK_OOO_ERROR } else - if(H5Tinsert(cmpd, name, 4 * (PACK_NMEMBS - i - 1), H5T_STD_I32BE) < 0) PACK_OOO_ERROR + if(H5Tinsert(cmpd, name, (size_t)(4 * (PACK_NMEMBS - i - 1)), H5T_STD_I32BE) < 0) PACK_OOO_ERROR } /* end for */ /* Verify that the compound is packed */ @@ -1917,18 +1917,18 @@ test_pack_ooo(void) TESTING("forward member insertion with empty compound subtype"); /* Create inner compound type. It will be empty for the first run */ - if((sub_cmpd = H5Tcreate(H5T_COMPOUND, 4)) < 0) PACK_OOO_ERROR + if((sub_cmpd = H5Tcreate(H5T_COMPOUND, (size_t)4)) < 0) PACK_OOO_ERROR /* Create main compound type, with extra space at the end */ - if((cmpd = H5Tcreate(H5T_COMPOUND, (4 * PACK_NMEMBS) + extra_space)) < 0) PACK_OOO_ERROR + if((cmpd = H5Tcreate(H5T_COMPOUND, (size_t)((4 * PACK_NMEMBS) + extra_space))) < 0) PACK_OOO_ERROR /* Insert the compound members in forward order, with compound first */ for(i=0; i<PACK_NMEMBS; i++) { sprintf(name, "%05d", i); if(i == 0) { - if(H5Tinsert(cmpd, name, 4 * i, sub_cmpd) < 0) PACK_OOO_ERROR + if(H5Tinsert(cmpd, name, (size_t)(4 * i), sub_cmpd) < 0) PACK_OOO_ERROR } else - if(H5Tinsert(cmpd, name, 4 * i, H5T_STD_I32BE) < 0) PACK_OOO_ERROR + if(H5Tinsert(cmpd, name, (size_t)(4 * i), H5T_STD_I32BE) < 0) PACK_OOO_ERROR } /* end for */ /* Verify that the compound is not packed */ @@ -1943,18 +1943,18 @@ test_pack_ooo(void) TESTING("forward member insertion with full compound subtype"); /* Complete the inner compound type */ - if(H5Tinsert(sub_cmpd, "int", 0, H5T_STD_I32LE) < 0) PACK_OOO_ERROR + if(H5Tinsert(sub_cmpd, "int", (size_t)0, H5T_STD_I32LE) < 0) PACK_OOO_ERROR /* Recreate main compound type */ - if((cmpd = H5Tcreate(H5T_COMPOUND, (4 * PACK_NMEMBS) + extra_space)) < 0) PACK_OOO_ERROR + if((cmpd = H5Tcreate(H5T_COMPOUND, (size_t)((4 * PACK_NMEMBS) + extra_space))) < 0) PACK_OOO_ERROR /* Insert the compound members in forward order */ for(i=0; i<PACK_NMEMBS; i++) { sprintf(name, "%05d", i); if(i == 0) { - if(H5Tinsert(cmpd, name, 4 * i, sub_cmpd) < 0) PACK_OOO_ERROR + if(H5Tinsert(cmpd, name, (size_t)(4 * i), sub_cmpd) < 0) PACK_OOO_ERROR } else - if(H5Tinsert(cmpd, name, 4 * i, H5T_STD_I32BE) < 0) PACK_OOO_ERROR + if(H5Tinsert(cmpd, name, (size_t)(4 * i), H5T_STD_I32BE) < 0) PACK_OOO_ERROR } /* end for */ /* Verify that the compound is packed */ @@ -2010,11 +2010,11 @@ test_ooo_order(char *filename) TEST_ERROR /* Create the compound */ - if((dtype = H5Tcreate(H5T_COMPOUND, 20)) < 0) TEST_ERROR - if(H5Tinsert(dtype, "A", 8, H5T_STD_I32LE) < 0) TEST_ERROR - if(H5Tinsert(dtype, "B", 12, H5T_STD_I32LE) < 0) TEST_ERROR - if(H5Tinsert(dtype, "C", 0, H5T_STD_I32LE) < 0) TEST_ERROR - if(H5Tinsert(dtype, "D", 16, H5T_STD_I32LE) < 0) TEST_ERROR + if((dtype = H5Tcreate(H5T_COMPOUND, (size_t)20)) < 0) TEST_ERROR + if(H5Tinsert(dtype, "A", (size_t)8, H5T_STD_I32LE) < 0) TEST_ERROR + if(H5Tinsert(dtype, "B", (size_t)12, H5T_STD_I32LE) < 0) TEST_ERROR + if(H5Tinsert(dtype, "C", (size_t)0, H5T_STD_I32LE) < 0) TEST_ERROR + if(H5Tinsert(dtype, "D", (size_t)16, H5T_STD_I32LE) < 0) TEST_ERROR /* Verify that the compound is not packed */ if(NULL == (dt = (H5T_t *) H5I_object_verify(dtype, H5I_DATATYPE))) @@ -2065,7 +2065,7 @@ test_ooo_order(char *filename) if(H5Tget_member_offset(dtype, 3) != 16) TEST_ERROR /* Insert the last member */ - if(H5Tinsert(dtype, "E", 4, H5T_STD_I32LE) < 0) TEST_ERROR + if(H5Tinsert(dtype, "E", (size_t)4, H5T_STD_I32LE) < 0) TEST_ERROR /* Verify that the compound is packed */ if(NULL == (dt = (H5T_t *) H5I_object_verify(dtype, H5I_DATATYPE))) @@ -2112,7 +2112,7 @@ test_ooo_order(char *filename) if(H5Tget_member_offset(dtype, 4) != 4) TEST_ERROR /* Expand the type, and verify that it became unpacked */ - if(H5Tset_size(dtype, 21) < 0) TEST_ERROR + if(H5Tset_size(dtype, (size_t)21) < 0) TEST_ERROR if(NULL == (dt = (H5T_t *) H5I_object_verify(dtype, H5I_DATATYPE))) TEST_ERROR if(dt->shared->u.compnd.packed) TEST_ERROR @@ -2123,7 +2123,7 @@ test_ooo_order(char *filename) if(H5Tget_member_offset(dtype, 4) != 4) TEST_ERROR /* Shrink the type, and verify that it became packed */ - if(H5Tset_size(dtype, 20) < 0) TEST_ERROR + if(H5Tset_size(dtype, (size_t)20) < 0) TEST_ERROR if(NULL == (dt = (H5T_t *) H5I_object_verify(dtype, H5I_DATATYPE))) TEST_ERROR if(!dt->shared->u.compnd.packed) TEST_ERROR diff --git a/test/dsets.c b/test/dsets.c index 30291df..8eed894 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -67,21 +67,27 @@ const char *FILENAME[] = { #define DSET_CONV_BUF_NAME "conv_buf" #define DSET_TCONV_NAME "tconv" #define DSET_DEFLATE_NAME "deflate" +#ifdef H5_HAVE_FILTER_SZIP #define DSET_SZIP_NAME "szip" +#endif /* H5_HAVE_FILTER_SZIP */ #define DSET_SHUFFLE_NAME "shuffle" #define DSET_FLETCHER32_NAME "fletcher32" #define DSET_FLETCHER32_NAME_2 "fletcher32_2" #define DSET_FLETCHER32_NAME_3 "fletcher32_3" #define DSET_SHUF_DEF_FLET_NAME "shuffle+deflate+fletcher32" #define DSET_SHUF_DEF_FLET_NAME_2 "shuffle+deflate+fletcher32_2" +#if defined H5_HAVE_FILTER_SZIP && defined H5_HAVE_FILTER_SHUFFLE && defined H5_HAVE_FILTER_FLETCHER32 #define DSET_SHUF_SZIP_FLET_NAME "shuffle+szip+fletcher32" #define DSET_SHUF_SZIP_FLET_NAME_2 "shuffle+szip+fletcher32_2" +#endif /* defined H5_HAVE_FILTER_SZIP && defined H5_HAVE_FILTER_SHUFFLE && defined H5_HAVE_FILTER_FLETCHER32 */ #define DSET_BOGUS_NAME "bogus" #define DSET_MISSING_NAME "missing" #define DSET_CAN_APPLY_NAME "can_apply" #define DSET_CAN_APPLY_NAME2 "can_apply2" +#ifdef H5_HAVE_FILTER_SZIP #define DSET_CAN_APPLY_SZIP_NAME "can_apply_szip" +#endif /* H5_HAVE_FILTER_SZIP */ #define DSET_SET_LOCAL_NAME "set_local" #define DSET_SET_LOCAL_NAME_2 "set_local_2" #define DSET_ONEBYTE_SHUF_NAME "onebyte_shuffle" @@ -1279,7 +1285,7 @@ filter_bogus2(unsigned int flags, size_t cd_nelmts, */ static size_t filter_bogus3(unsigned int UNUSED flags, size_t UNUSED cd_nelmts, - const unsigned int UNUSED *cd_values, size_t nbytes, + const unsigned int UNUSED *cd_values, size_t UNUSED nbytes, size_t UNUSED *buf_size, void UNUSED **buf) { return 0; @@ -2380,7 +2386,7 @@ test_missing_filter(hid_t file) } /* end if */ /* Query the dataset's size on disk */ - if((dset_size=H5Dget_storage_size(dsid))==0) { + if(0 == (dset_size = H5Dget_storage_size(dsid))) { H5_FAILED(); printf(" Line %d: Error querying dataset size, dset_size=%lu\n",__LINE__,(unsigned long)dset_size); goto error; @@ -2388,7 +2394,7 @@ test_missing_filter(hid_t file) /* Verify that the size indicates data is uncompressed */ /* (i.e. the deflation filter we asked for was silently ignored) */ - if((H5Tget_size(H5T_NATIVE_INT)*DSET_DIM1*DSET_DIM2)!=dset_size) { + if((H5Tget_size(H5T_NATIVE_INT) * DSET_DIM1 * DSET_DIM2) != dset_size) { H5_FAILED(); printf(" Line %d: Incorrect dataset size: %lu\n",__LINE__,(unsigned long)dset_size); goto error; @@ -3763,6 +3769,7 @@ test_nbit_compound_3(hid_t file) /* Initialize data */ for(i = 0; i < (size_t)size[0]; i++) { + HDmemset(&orig_data[i], 0, sizeof(orig_data[i])); orig_data[i].i = HDrandom() % (long)HDpow(2.0, 17.0 - 1.0); HDstrcpy(orig_data[i].str, "fixed-length C string"); orig_data[i].vl_str = HDstrdup("variable-length C string"); @@ -5839,7 +5846,7 @@ test_copy_dcpl(hid_t file, hid_t fapl) * until the data is written to it. */ if(H5Pset_layout(dcpl, H5D_CONTIGUOUS) < 0) TEST_ERROR if(H5Premove_filter(dcpl, H5Z_FILTER_FLETCHER32) < 0) TEST_ERROR - if(H5Pset_external(dcpl, COPY_DCPL_EXTFILE_NAME, 0, 500*4096*sizeof(int)) < 0) TEST_ERROR + if(H5Pset_external(dcpl, COPY_DCPL_EXTFILE_NAME, (off_t)0, (hsize_t)(500 * 4096 * sizeof(int))) < 0) TEST_ERROR /* Create second dataset of contiguous layout with external storage */ if((dsid2 = H5Dcreate2(file, DSET_COPY_DCPL_NAME_2, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, @@ -5977,7 +5984,7 @@ test_filter_delete(hid_t file) /* try to get the info for the deflate filter */ H5E_BEGIN_TRY { - ret=H5Pget_filter_by_id2(dcpl1,H5Z_FILTER_DEFLATE,&flags,NULL,NULL,0,NULL,NULL); + ret = H5Pget_filter_by_id2(dcpl1, H5Z_FILTER_DEFLATE, &flags, NULL, NULL, (size_t)0, NULL, NULL); } H5E_END_TRY; if(ret >=0) { H5_FAILED(); @@ -6437,7 +6444,7 @@ test_random_chunks(hid_t fapl) if((m = H5Screate_simple(1, msize, NULL)) < 0) TEST_ERROR; /* Select the random points for writing */ - if(H5Sselect_elements(s, H5S_SELECT_SET, NPOINTS, (const hsize_t *)coord) < 0) TEST_ERROR; + if(H5Sselect_elements(s, H5S_SELECT_SET, (size_t)NPOINTS, (const hsize_t *)coord) < 0) TEST_ERROR; /* Write into dataset */ if(H5Dwrite(d, H5T_NATIVE_INT, m, s, H5P_DEFAULT, wbuf) < 0) TEST_ERROR; @@ -6462,7 +6469,7 @@ test_random_chunks(hid_t fapl) if((m = H5Screate_simple(1, msize, NULL)) < 0) TEST_ERROR; /* Select the random points for reading */ - if(H5Sselect_elements (s, H5S_SELECT_SET, NPOINTS, (const hsize_t *)coord) < 0) TEST_ERROR; + if(H5Sselect_elements (s, H5S_SELECT_SET, (size_t)NPOINTS, (const hsize_t *)coord) < 0) TEST_ERROR; /* Read from dataset */ if(H5Dread(d, H5T_NATIVE_INT, m, s, H5P_DEFAULT, rbuf) < 0) TEST_ERROR; @@ -6527,7 +6534,7 @@ test_random_chunks(hid_t fapl) if((m = H5Screate_simple(1, msize, NULL)) < 0) TEST_ERROR; /* Select the random points for writing */ - if(H5Sselect_elements(s, H5S_SELECT_SET, NPOINTS, (const hsize_t *)coord) < 0) TEST_ERROR; + if(H5Sselect_elements(s, H5S_SELECT_SET, (size_t)NPOINTS, (const hsize_t *)coord) < 0) TEST_ERROR; /* Write into dataset */ if(H5Dwrite(d, H5T_NATIVE_INT, m, s, H5P_DEFAULT, wbuf) < 0) TEST_ERROR; @@ -6552,7 +6559,7 @@ test_random_chunks(hid_t fapl) if((m = H5Screate_simple(1, msize, NULL)) < 0) TEST_ERROR; /* Select the random points for reading */ - if(H5Sselect_elements (s, H5S_SELECT_SET, NPOINTS, (const hsize_t *)coord) < 0) TEST_ERROR; + if(H5Sselect_elements (s, H5S_SELECT_SET, (size_t)NPOINTS, (const hsize_t *)coord) < 0) TEST_ERROR; /* Read from dataset */ if(H5Dread(d, H5T_NATIVE_INT, m, s, H5P_DEFAULT, rbuf) < 0) TEST_ERROR; @@ -6958,7 +6965,7 @@ test_chunk_cache(hid_t fapl) FAIL_PUTS_ERROR(" Cache values from default dapl do not match those from fapl.") /* Set a lapl property on dapl1 (to verify inheritance) */ - if (H5Pset_nlinks(dapl1, 134) < 0) FAIL_STACK_ERROR + if (H5Pset_nlinks(dapl1, (size_t)134) < 0) FAIL_STACK_ERROR if (H5Pget_nlinks(dapl1, &nlinks) < 0) FAIL_STACK_ERROR if (nlinks != 134) FAIL_PUTS_ERROR(" nlinks parameter not set properly on dapl.") diff --git a/test/dt_arith.c b/test/dt_arith.c index 2e23f25..5357f52 100644 --- a/test/dt_arith.c +++ b/test/dt_arith.c @@ -290,8 +290,8 @@ static int without_hardware_g = 0; HDmemset(BUF, 0, NELMTS*MAX(SRC_SIZE, DST_SIZE)); \ HDmemset(SAVED, 0, NELMTS*MAX(SRC_SIZE, DST_SIZE)); \ \ - tmp1 = (unsigned char*)calloc(1, SRC_SIZE); \ - tmp2 = (unsigned char*)calloc(1, SRC_SIZE); \ + tmp1 = (unsigned char*)calloc((size_t)1, (size_t)SRC_SIZE); \ + tmp2 = (unsigned char*)calloc((size_t)1, (size_t)SRC_SIZE); \ \ buf_p = BUF; \ saved_p = SAVED; \ @@ -300,9 +300,9 @@ static int without_hardware_g = 0; *00000111,..., until 11111111.*/ \ memset(tmp1, 0, SRC_SIZE); \ memset(tmp2, 0, SRC_SIZE); \ - H5T_bit_set (tmp2, SRC_PREC-1, 1, TRUE); /*the negative value*/ \ + H5T_bit_set (tmp2, SRC_PREC-1, (size_t)1, TRUE); /*the negative value*/ \ for(n=0; n<SRC_MANT_DIG-1; n++) { \ - H5T_bit_set (tmp1, n, 1, TRUE); /*turn on 1 bit each time*/ \ + H5T_bit_set (tmp1, n, (size_t)1, TRUE); /*turn on 1 bit each time*/ \ CHANGE_ORDER(tmp1, SRC_ORDR, SRC_SIZE); /*change order for big endian*/ \ memcpy(buf_p, tmp1, SRC_SIZE); \ memcpy(saved_p, tmp1, SRC_SIZE); \ @@ -311,7 +311,7 @@ static int without_hardware_g = 0; saved_p += SRC_SIZE; \ \ /*negative values*/ \ - H5T_bit_set (tmp2, n, 1, TRUE); \ + H5T_bit_set (tmp2, n, (size_t)1, TRUE); \ CHANGE_ORDER(tmp2, SRC_ORDR, SRC_SIZE); \ memcpy(buf_p, tmp2, SRC_SIZE); \ memcpy(saved_p, tmp2, SRC_SIZE); \ @@ -347,7 +347,7 @@ static int without_hardware_g = 0; buf_p = BUF; \ \ /* +0 */ \ - H5T_bit_set(value, 0, SRC_PREC, FALSE); \ + H5T_bit_set(value, (size_t)0, SRC_PREC, FALSE); \ memcpy(buf_p, value, SRC_SIZE*sizeof(unsigned char)); \ buf_p += SRC_SIZE; \ \ @@ -355,36 +355,36 @@ static int without_hardware_g = 0; if(n==1) { \ memset(value, 0, SRC_SIZE*sizeof(unsigned char)); \ /* -0 */ \ - H5T_bit_set(value, SRC_PREC-1, 1, TRUE); \ + H5T_bit_set(value, (size_t)(SRC_PREC - 1), (size_t)1, TRUE); \ CHANGE_ORDER(value, SRC_ORDR, SRC_SIZE);/*change order for big endian*/ \ - memcpy(buf_p, value, SRC_SIZE*sizeof(unsigned char)); \ + HDmemcpy(buf_p, value, SRC_SIZE*sizeof(unsigned char)); \ CHANGE_ORDER(value, SRC_ORDR, SRC_SIZE);/*change back the order for bit operation*/ \ buf_p += SRC_SIZE; \ } \ \ /* +/-infinity */ \ - H5T_bit_set(value, SRC_MANT_DIG-1, SRC_PREC-SRC_MANT_DIG, TRUE); \ + H5T_bit_set(value, (size_t)(SRC_MANT_DIG - 1), SRC_PREC-SRC_MANT_DIG, TRUE); \ CHANGE_ORDER(value, SRC_ORDR, SRC_SIZE); /*change order for big endian*/ \ - memcpy(buf_p, value, SRC_SIZE*sizeof(unsigned char)); \ + HDmemcpy(buf_p, value, SRC_SIZE*sizeof(unsigned char)); \ CHANGE_ORDER(value, SRC_ORDR, SRC_SIZE); /*change back the order for bit operation*/ \ buf_p += SRC_SIZE; \ \ /* +/-SNaN */ \ - H5T_bit_set(value, 0, 1, TRUE); \ + H5T_bit_set(value, (size_t)0, (size_t)1, TRUE); \ CHANGE_ORDER(value, SRC_ORDR, SRC_SIZE); /*change order for big endian*/ \ - memcpy(buf_p, value, SRC_SIZE*sizeof(unsigned char)); \ + HDmemcpy(buf_p, value, SRC_SIZE * sizeof(unsigned char)); \ CHANGE_ORDER(value, SRC_ORDR, SRC_SIZE); /*change back the order for bit operation*/ \ buf_p += SRC_SIZE; \ \ /* +/-QNaN */ \ - H5T_bit_set(value, SRC_MANT_DIG-2, 1, TRUE); \ + H5T_bit_set(value, (size_t)(SRC_MANT_DIG - 2), (size_t)1, TRUE); \ CHANGE_ORDER(value, SRC_ORDR, SRC_SIZE); /*change order for big endian*/ \ - memcpy(buf_p, value, SRC_SIZE*sizeof(unsigned char)); \ + HDmemcpy(buf_p, value, SRC_SIZE*sizeof(unsigned char)); \ CHANGE_ORDER(value, SRC_ORDR, SRC_SIZE); /*change back the order for bit operation*/ \ buf_p += SRC_SIZE; \ } \ \ - memcpy(SAVED, BUF, NELMTS*MAX(SRC_SIZE, DST_SIZE)); \ + HDmemcpy(SAVED, BUF, NELMTS*MAX(SRC_SIZE, DST_SIZE)); \ free(value); \ } @@ -565,7 +565,7 @@ generates_sigfpe(void) HDfflush(stdout); HDfflush(stderr); - if ((pid=fork())<0) { + if ((pid=fork()) < 0) { HDperror("fork"); HDexit(1); } else if (0==pid) { @@ -735,7 +735,7 @@ static int test_particular_fp_integer(void) TESTING("hard particular floating number -> integer conversions"); - if((dxpl_id = H5Pcreate(H5P_DATASET_XFER))<0) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) { H5_FAILED(); printf("Can't create data transfer property list\n"); goto error; @@ -745,22 +745,22 @@ static int test_particular_fp_integer(void) endian = H5Tget_order(H5T_NATIVE_DOUBLE); src_size1 = H5Tget_size(H5T_NATIVE_DOUBLE); dst_size1 = H5Tget_size(H5T_NATIVE_SCHAR); - buf1 = (unsigned char*)calloc(1, MAX(src_size1, dst_size1)); - saved_buf1 = (unsigned char*)calloc(1, MAX(src_size1, dst_size1)); + buf1 = (unsigned char*)calloc((size_t)1, (size_t)MAX(src_size1, dst_size1)); + saved_buf1 = (unsigned char*)calloc((size_t)1, (size_t)MAX(src_size1, dst_size1)); memcpy(buf1, &src_d, src_size1); memcpy(saved_buf1, &src_d, src_size1); /* Register exception handling function and signal the destination is "signed char". */ flag = 1; - if(H5Pset_type_conv_cb(dxpl_id, expt_handle, &flag)<0) { + if(H5Pset_type_conv_cb(dxpl_id, expt_handle, &flag) < 0) { H5_FAILED(); printf("Can't register conversion callback\n"); goto error; } /* Do conversion */ - if(H5Tconvert(H5T_NATIVE_DOUBLE, H5T_NATIVE_SCHAR, 1, buf1, NULL, dxpl_id)<0) { + if(H5Tconvert(H5T_NATIVE_DOUBLE, H5T_NATIVE_SCHAR, (size_t)1, buf1, NULL, dxpl_id) < 0) { H5_FAILED(); printf("Can't convert data\n"); goto error; @@ -795,16 +795,16 @@ static int test_particular_fp_integer(void) /* Test conversion from float (the value is INT_MAX) to int. */ src_size2 = H5Tget_size(H5T_NATIVE_FLOAT); dst_size2 = H5Tget_size(H5T_NATIVE_INT); - buf2 = (unsigned char*)calloc(1, MAX(src_size2, dst_size2)); - saved_buf2 = (unsigned char*)calloc(1, MAX(src_size2, dst_size2)); - memcpy(buf2, &src_f, src_size2); - memcpy(saved_buf2, &src_f, src_size2); + buf2 = (unsigned char*)calloc((size_t)1, (size_t)MAX(src_size2, dst_size2)); + saved_buf2 = (unsigned char*)calloc((size_t)1, (size_t)MAX(src_size2, dst_size2)); + HDmemcpy(buf2, &src_f, src_size2); + HDmemcpy(saved_buf2, &src_f, src_size2); /* signal exception handling function that the destination is "int". */ flag = 0; /* Do conversion */ - if(H5Tconvert(H5T_NATIVE_FLOAT, H5T_NATIVE_INT, 1, buf2, NULL, dxpl_id)<0) { + if(H5Tconvert(H5T_NATIVE_FLOAT, H5T_NATIVE_INT, (size_t)1, buf2, NULL, dxpl_id) < 0) { H5_FAILED(); printf("Can't convert data\n"); goto error; @@ -839,7 +839,7 @@ static int test_particular_fp_integer(void) if(fails_this_test) goto error; - if(H5Pclose(dxpl_id)<0) { + if(H5Pclose(dxpl_id) < 0) { H5_FAILED(); printf("Can't close property list\n"); goto error; @@ -913,25 +913,25 @@ test_derived_flt(void) /* Create File */ h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof filename); - if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT))<0) { + if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { H5_FAILED(); printf("Can't create file\n"); goto error; } - if((dxpl_id = H5Pcreate(H5P_DATASET_XFER))<0) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) { H5_FAILED(); printf("Can't create data transfer property list\n"); goto error; } - if((tid1 = H5Tcopy(H5T_IEEE_F64LE))<0) { + if((tid1 = H5Tcopy(H5T_IEEE_F64LE)) < 0) { H5_FAILED(); printf("Can't copy data type\n"); goto error; } - if((tid2 = H5Tcopy(H5T_IEEE_F32LE))<0) { + if((tid2 = H5Tcopy(H5T_IEEE_F32LE)) < 0) { H5_FAILED(); printf("Can't copy data type\n"); goto error; @@ -955,28 +955,28 @@ test_derived_flt(void) * holes among the significant bits. Exponent bias usually is set * 2^(n-1)-1, where n is the exponent size. *-----------------------------------------------------------------------*/ - if(H5Tset_fields(tid1, 44, 34, 10, 3, 31)<0) { + if(H5Tset_fields(tid1, (size_t)44, (size_t)34, (size_t)10, (size_t)3, (size_t)31) < 0) { H5_FAILED(); printf("Can't set fields\n"); goto error; } - if(H5Tset_offset(tid1, 3)<0) { + if(H5Tset_offset(tid1, (size_t)3) < 0) { H5_FAILED(); printf("Can't set offset\n"); goto error; } - if(H5Tset_precision(tid1, 42)<0) { + if(H5Tset_precision(tid1, (size_t)42) < 0) { H5_FAILED(); printf("Can't set precision 1\n"); goto error; } - if(H5Tset_size(tid1, 7)<0) { + if(H5Tset_size(tid1, (size_t)7) < 0) { H5_FAILED(); printf("Can't set size\n"); goto error; } - if(H5Tset_ebias(tid1, 511) < 0) { + if(H5Tset_ebias(tid1, (size_t)511) < 0) { H5_FAILED(); printf("Can't set exponent bias\n"); goto error; @@ -1038,24 +1038,24 @@ test_derived_flt(void) */ src_size = H5Tget_size(H5T_NATIVE_INT); endian = H5Tget_order(H5T_NATIVE_INT); - buf = (unsigned char*)malloc(nelmts*(MAX(src_size, size))); - saved_buf = (unsigned char*)malloc(nelmts*src_size); - HDmemset(buf, 0, nelmts*MAX(src_size, size)); - HDmemset(saved_buf, 0, nelmts*src_size); - aligned = (int*)calloc(1, src_size); + buf = (unsigned char*)malloc(nelmts * (MAX(src_size, size))); + saved_buf = (unsigned char*)malloc(nelmts * src_size); + HDmemset(buf, 0, nelmts * MAX(src_size, size)); + HDmemset(saved_buf, 0, nelmts * src_size); + aligned = (int*)calloc((size_t)1, src_size); - for(i=0; i<nelmts*src_size; i++) + for(i = 0; i < nelmts * src_size; i++) buf[i] = saved_buf[i] = HDrand(); /* Convert data from native integer to derived floating-point type. * The mantissa is big enough to retain the integer's precision. */ - if(H5Tconvert(H5T_NATIVE_INT, tid1, nelmts, buf, NULL, dxpl_id)<0) { + if(H5Tconvert(H5T_NATIVE_INT, tid1, nelmts, buf, NULL, dxpl_id) < 0) { H5_FAILED(); printf("Can't convert data\n"); goto error; } /* Convert data from the derived floating-point type back to native integer. */ - if(H5Tconvert(tid1, H5T_NATIVE_INT, nelmts, buf, NULL, dxpl_id)<0) { + if(H5Tconvert(tid1, H5T_NATIVE_INT, nelmts, buf, NULL, dxpl_id) < 0) { H5_FAILED(); printf("Can't convert data\n"); goto error; @@ -1115,27 +1115,27 @@ test_derived_flt(void) * 2 1 0 * SEEEEEEE MMMMMMMM MMMMMMMM *--------------------------------------------------------------------------*/ - if(H5Tset_fields(tid2, 23, 16, 7, 0, 16)<0) { + if(H5Tset_fields(tid2, (size_t)23, (size_t)16, (size_t)7, (size_t)0, (size_t)16) < 0) { H5_FAILED(); printf("Can't set fields\n"); goto error; } - if(H5Tset_offset(tid2, 0)<0) { + if(H5Tset_offset(tid2, (size_t)0) < 0) { H5_FAILED(); printf("Can't set offset\n"); goto error; } - if(H5Tset_precision(tid2, 24)<0) { + if(H5Tset_precision(tid2, (size_t)24) < 0) { H5_FAILED(); printf("Can't set precision 2\n"); goto error; } - if(H5Tset_size(tid2, 3)<0) { + if(H5Tset_size(tid2, (size_t)3) < 0) { H5_FAILED(); printf("Can't set size\n"); goto error; } - if(H5Tset_ebias(tid2, 63) < 0) { + if(H5Tset_ebias(tid2, (size_t)63) < 0) { H5_FAILED(); printf("Can't set size\n"); goto error; @@ -1209,13 +1209,13 @@ test_derived_flt(void) /* Convert data from the 2nd to the 1st derived floating-point type. * The mantissa and exponent of the 2nd type are big enough to retain * the precision and exponent power. */ - if(H5Tconvert(tid2, tid1, nelmts, buf, NULL, dxpl_id)<0) { + if(H5Tconvert(tid2, tid1, nelmts, buf, NULL, dxpl_id) < 0) { H5_FAILED(); printf("Can't convert data\n"); goto error; } /* Convert data from the 1st back to the 2nd derived floating-point type. */ - if(H5Tconvert(tid1, tid2, nelmts, buf, NULL, dxpl_id)<0) { + if(H5Tconvert(tid1, tid2, nelmts, buf, NULL, dxpl_id) < 0) { H5_FAILED(); printf("Can't convert data\n"); goto error; @@ -1265,25 +1265,25 @@ test_derived_flt(void) if (buf) free(buf); if (saved_buf) free(saved_buf); - if(H5Tclose(tid1)<0) { + if(H5Tclose(tid1) < 0) { H5_FAILED(); printf("Can't close datatype\n"); goto error; } - if(H5Tclose(tid2)<0) { + if(H5Tclose(tid2) < 0) { H5_FAILED(); printf("Can't close datatype\n"); goto error; } - if(H5Pclose(dxpl_id)<0) { + if(H5Pclose(dxpl_id) < 0) { H5_FAILED(); printf("Can't close property list\n"); goto error; } - if(H5Fclose(file)<0) { + if(H5Fclose(file) < 0) { H5_FAILED(); printf("Can't close file\n"); goto error; @@ -1345,25 +1345,25 @@ test_derived_integer(void) /* Create File */ h5_fixname(FILENAME[1], H5P_DEFAULT, filename, sizeof filename); - if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT))<0) { + if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { H5_FAILED(); printf("Can't create file\n"); goto error; } - if((dxpl_id = H5Pcreate(H5P_DATASET_XFER))<0) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) { H5_FAILED(); printf("Can't create data transfer property list\n"); goto error; } - if((tid1 = H5Tcopy(H5T_STD_I32LE))<0) { + if((tid1 = H5Tcopy(H5T_STD_I32LE)) < 0) { H5_FAILED(); printf("Can't copy data type\n"); goto error; } - if((tid2 = H5Tcopy(H5T_STD_U64LE))<0) { + if((tid2 = H5Tcopy(H5T_STD_U64LE)) < 0) { H5_FAILED(); printf("Can't copy data type\n"); goto error; @@ -1381,19 +1381,19 @@ test_derived_integer(void) * of a new integer type, H5Tset_precision, H5Tset_offset, H5Tset_size, * H5Tset_order, H5Tset_pad, H5Tset_sign. *--------------------------------------------------------------------------*/ - if(H5Tset_offset(tid1,0)<0) { + if(H5Tset_offset(tid1, (size_t)0) < 0) { H5_FAILED(); printf("Can't set offset\n"); goto error; } - if(H5Tset_size(tid1, 3)<0) { + if(H5Tset_size(tid1, (size_t)3) < 0) { H5_FAILED(); printf("Can't set size\n"); goto error; } - if(H5Tset_precision(tid1, 24) < 0) { + if(H5Tset_precision(tid1, (size_t)24) < 0) { H5_FAILED(); printf("Can't set precision\n"); goto error; @@ -1448,13 +1448,13 @@ test_derived_integer(void) * 7 6 5 4 3 2 1 0 * ??????SI IIIIIIII IIIIIIII IIIIIIII IIIIIIII IIIIIIII IIIIII?? ???????? *--------------------------------------------------------------------------*/ - if(H5Tset_precision(tid2,48)<0) { + if(H5Tset_precision(tid2, (size_t)48) < 0) { H5_FAILED(); printf("Can't set precision\n"); goto error; } - if(H5Tset_offset(tid2, 10) < 0) { + if(H5Tset_offset(tid2, (size_t)10) < 0) { H5_FAILED(); printf("Can't set offset\n"); goto error; @@ -1519,13 +1519,13 @@ test_derived_integer(void) /* Convert data from the 1st to the 2nd derived integer type. * The precision of the 2nd type are big enough to retain * the 1st type's precision. */ - if(H5Tconvert(tid1, tid2, nelmts, buf, NULL, dxpl_id)<0) { + if(H5Tconvert(tid1, tid2, nelmts, buf, NULL, dxpl_id) < 0) { H5_FAILED(); printf("Can't convert data\n"); goto error; } /* Convert data from the 2nd back to the 1st derived integer type. */ - if(H5Tconvert(tid2, tid1, nelmts, buf, NULL, dxpl_id)<0) { + if(H5Tconvert(tid2, tid1, nelmts, buf, NULL, dxpl_id) < 0) { H5_FAILED(); printf("Can't convert data\n"); goto error; @@ -1564,30 +1564,33 @@ test_derived_integer(void) } } - if(H5Tclose(tid1)<0) { + if(H5Tclose(tid1) < 0) { H5_FAILED(); printf("Can't close datatype\n"); goto error; } - if(H5Tclose(tid2)<0) { + if(H5Tclose(tid2) < 0) { H5_FAILED(); printf("Can't close datatype\n"); goto error; } - if(H5Pclose(dxpl_id)<0) { + if(H5Pclose(dxpl_id) < 0) { H5_FAILED(); printf("Can't close property list\n"); goto error; } - if(H5Fclose(file)<0) { + if(H5Fclose(file) < 0) { H5_FAILED(); printf("Can't close file\n"); goto error; } /* end if */ + free(buf); + free(saved_buf); + PASSED(); reset_hdf5(); /*print statistics*/ @@ -1761,7 +1764,7 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) dst_nbits = H5Tget_precision(dst); /* not 8*dst_size, esp on J90 - QAK */ src_sign = H5Tget_sign(src); dst_sign = H5Tget_sign(dst); - aligned = HDcalloc(1, sizeof(long long)); + aligned = HDcalloc((size_t)1, sizeof(long long)); /* Allocate and initialize the source buffer through macro INIT_INTEGER. The BUF * will be used for the conversion while the SAVED buffer will be @@ -1791,7 +1794,7 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) goto error; /* Perform the conversion */ - if (H5Tconvert(src, dst, nelmts, buf, NULL, H5P_DEFAULT)<0) + if (H5Tconvert(src, dst, nelmts, buf, NULL, H5P_DEFAULT) < 0) goto error; /* Check the results from the library against hardware */ @@ -1839,6 +1842,10 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) HDmemcpy(aligned, saved+j*sizeof(unsigned long long), sizeof(unsigned long long)); hw_char = (signed char)(*((unsigned long long*)aligned)); break; + case FLT_FLOAT: + case FLT_DOUBLE: + case FLT_LDOUBLE: + case OTHER: default: break; } @@ -1885,6 +1892,10 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) HDmemcpy(aligned, saved+j*sizeof(unsigned long long), sizeof(unsigned long long)); hw_uchar = (unsigned char)(*((unsigned long long*)aligned)); break; + case FLT_FLOAT: + case FLT_DOUBLE: + case FLT_LDOUBLE: + case OTHER: default: break; } @@ -1932,6 +1943,10 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) hw_short = (short)(*((unsigned long long*)aligned)); break; + case FLT_FLOAT: + case FLT_DOUBLE: + case FLT_LDOUBLE: + case OTHER: default: break; } @@ -1978,6 +1993,10 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) HDmemcpy(aligned, saved+j*sizeof(unsigned long long), sizeof(unsigned long long)); hw_ushort = (unsigned short)(*((unsigned long long*)aligned)); break; + case FLT_FLOAT: + case FLT_DOUBLE: + case FLT_LDOUBLE: + case OTHER: default: break; } @@ -2024,6 +2043,10 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) HDmemcpy(aligned, saved+j*sizeof(unsigned long long), sizeof(unsigned long long)); hw_int = (int)(*((unsigned long long*)aligned)); break; + case FLT_FLOAT: + case FLT_DOUBLE: + case FLT_LDOUBLE: + case OTHER: default: break; } @@ -2070,6 +2093,10 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) HDmemcpy(aligned, saved+j*sizeof(unsigned long long), sizeof(unsigned long long)); hw_uint = (unsigned int)(*((unsigned long long*)aligned)); break; + case FLT_FLOAT: + case FLT_DOUBLE: + case FLT_LDOUBLE: + case OTHER: default: break; } @@ -2116,6 +2143,10 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) HDmemcpy(aligned, saved+j*sizeof(unsigned long long), sizeof(unsigned long long)); hw_long = (long int)(*((unsigned long long*)aligned)); break; + case FLT_FLOAT: + case FLT_DOUBLE: + case FLT_LDOUBLE: + case OTHER: default: break; } @@ -2162,6 +2193,10 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) HDmemcpy(aligned, saved+j*sizeof(unsigned long long), sizeof(unsigned long long)); hw_ulong = (unsigned long)(*((unsigned long long*)aligned)); break; + case FLT_FLOAT: + case FLT_DOUBLE: + case FLT_LDOUBLE: + case OTHER: default: break; } @@ -2208,6 +2243,10 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) HDmemcpy(aligned, saved+j*sizeof(unsigned long long), sizeof(unsigned long long)); hw_llong = (long long)(*((unsigned long long*)aligned)); break; + case FLT_FLOAT: + case FLT_DOUBLE: + case FLT_LDOUBLE: + case OTHER: default: break; } @@ -2254,6 +2293,10 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) HDmemcpy(aligned, saved+j*sizeof(unsigned long long), sizeof(unsigned long long)); hw_ullong = (unsigned long long)(*((unsigned long long*)aligned)); break; + case FLT_FLOAT: + case FLT_DOUBLE: + case FLT_LDOUBLE: + case OTHER: default: break; } @@ -2288,7 +2331,7 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) */ if (H5T_SGN_2==src_sign && H5T_SGN_2==dst_sign) { if (src_nbits>dst_nbits) { - if(0==H5T_bit_get_d(src_bits, src_nbits-1, 1) && + if(0==H5T_bit_get_d(src_bits, src_nbits-1, (size_t)1) && H5T_bit_find(src_bits, dst_nbits-1, (src_nbits-dst_nbits), H5T_BIT_MSB, 1)>=0) { /* @@ -2296,49 +2339,49 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) * the destination. The destination should be set to the * maximum possible value: 0x7f...f */ - if (0==H5T_bit_get_d(dst_bits, dst_nbits-1, 1) && - H5T_bit_find(dst_bits, 0, dst_nbits-1, H5T_BIT_LSB, 0)<0) + if (0==H5T_bit_get_d(dst_bits, dst_nbits-1, (size_t)1) && + H5T_bit_find(dst_bits, (size_t)0, dst_nbits-1, H5T_BIT_LSB, 0) < 0) continue; /*no error*/ - } else if (1==H5T_bit_get_d(src_bits, src_nbits-1, 1) && - H5T_bit_find(src_bits, 0, src_nbits-1, H5T_BIT_MSB, + } else if (1==H5T_bit_get_d(src_bits, src_nbits-1, (size_t)1) && + H5T_bit_find(src_bits, (size_t)0, src_nbits-1, H5T_BIT_MSB, 0)+1>=(ssize_t)dst_nbits) { /* * Source is negative but the magnitude is too large for * the destination. The destination should be set to the * smallest possible value: 0x80...0 */ - if (1==H5T_bit_get_d(dst_bits, dst_nbits-1, 1) && - H5T_bit_find(dst_bits, 0, dst_nbits-1, H5T_BIT_LSB, 1)<0) + if (1==H5T_bit_get_d(dst_bits, dst_nbits-1, (size_t)1) && + H5T_bit_find(dst_bits, (size_t)0, dst_nbits-1, H5T_BIT_LSB, 1) < 0) continue; /*no error*/ } } else if(src_nbits<dst_nbits) { /* Source is smaller than the destination */ - if(0==H5T_bit_get_d(src_bits, src_nbits-1, 1)) { + if(0==H5T_bit_get_d(src_bits, src_nbits-1, (size_t)1)) { /* * Source is positive, so the excess bits in the * destination should be set to 0's. */ - if (0==H5T_bit_get_d(dst_bits, src_nbits-1, 1) && - H5T_bit_find(dst_bits, src_nbits, dst_nbits-src_nbits, H5T_BIT_LSB, 1)<0) + if (0==H5T_bit_get_d(dst_bits, src_nbits-1, (size_t)1) && + H5T_bit_find(dst_bits, src_nbits, dst_nbits-src_nbits, H5T_BIT_LSB, 1) < 0) continue; /*no error*/ } else { /* * Source is negative, so the excess bits in the * destination should be set to 1's. */ - if (1==H5T_bit_get_d(dst_bits, src_nbits-1, 1) && - H5T_bit_find(dst_bits, src_nbits, dst_nbits-src_nbits, H5T_BIT_LSB, 0)<0) + if (1==H5T_bit_get_d(dst_bits, src_nbits-1, (size_t)1) && + H5T_bit_find(dst_bits, src_nbits, dst_nbits-src_nbits, H5T_BIT_LSB, 0) < 0) continue; /*no error*/ } } } else if (H5T_SGN_2==src_sign && H5T_SGN_NONE==dst_sign) { - if (H5T_bit_get_d(src_bits, src_nbits-1, 1)) { + if (H5T_bit_get_d(src_bits, src_nbits-1, (size_t)1)) { /* * The source is negative so the result should be zero. * The source is negative if the most significant bit is * set. The destination is zero if all bits are zero. */ - if (H5T_bit_find(dst_bits, 0, dst_nbits, H5T_BIT_LSB, 1)<0) + if (H5T_bit_find(dst_bits, (size_t)0, dst_nbits, H5T_BIT_LSB, 1) < 0) continue; /*no error*/ } else if (src_nbits>dst_nbits && H5T_bit_find(src_bits, dst_nbits-1, @@ -2348,7 +2391,7 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) * the destination. The destination should be the * largest possible value: 0xff...f */ - if (H5T_bit_find(dst_bits, 0, dst_nbits, H5T_BIT_LSB, 0)<0) + if (H5T_bit_find(dst_bits, (size_t)0, dst_nbits, H5T_BIT_LSB, 0) < 0) continue; /*no error*/ } } else if (H5T_SGN_NONE==src_sign && H5T_SGN_2==dst_sign) { @@ -2360,8 +2403,8 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) * the destination can handle. The destination should be * set to the largest possible positive value: 0x7f...f */ - if (0==H5T_bit_get_d(dst_bits, dst_nbits-1, 1) && - H5T_bit_find(dst_bits, 0, dst_nbits-1, H5T_BIT_LSB, 0)<0) + if (0==H5T_bit_get_d(dst_bits, dst_nbits-1, (size_t)1) && + H5T_bit_find(dst_bits, (size_t)0, dst_nbits-1, H5T_BIT_LSB, 0) < 0) continue; /*no error*/ } } else { @@ -2373,7 +2416,7 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) * the unsigned destination. The destination should be * set to the largest possible value: 0xff...f */ - if (H5T_bit_find(dst_bits, 0, dst_nbits, H5T_BIT_LSB, 0)<0) + if (H5T_bit_find(dst_bits, (size_t)0, dst_nbits, H5T_BIT_LSB, 0) < 0) continue; /*no error*/ } } @@ -2428,6 +2471,10 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) HDmemcpy(aligned, saved+j*sizeof(unsigned long long), sizeof(unsigned long long)); HDfprintf(stdout," %29"H5_PRINTF_LL_WIDTH"u\n", *((unsigned long long*)aligned)); break; + case FLT_FLOAT: + case FLT_DOUBLE: + case FLT_LDOUBLE: + case OTHER: default: break; } @@ -2477,6 +2524,10 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) HDmemcpy(aligned, buf+j*sizeof(long long), sizeof(unsigned long long)); HDfprintf(stdout," %29"H5_PRINTF_LL_WIDTH"u\n", *((unsigned long long*)aligned)); break; + case FLT_FLOAT: + case FLT_DOUBLE: + case FLT_LDOUBLE: + case OTHER: default: break; } @@ -2516,6 +2567,10 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) case INT_ULLONG: HDfprintf(stdout," %29"H5_PRINTF_LL_WIDTH"u\n", *((unsigned long long*)hw)); break; + case FLT_FLOAT: + case FLT_DOUBLE: + case FLT_LDOUBLE: + case OTHER: default: break; } @@ -2589,7 +2644,7 @@ test_conv_int_2(void) * Conversion. If overlap calculations aren't right then an * assertion will fail in H5T_conv_i_i() */ - H5Tconvert(src_type, dst_type, 100, buf, NULL, H5P_DEFAULT); + H5Tconvert(src_type, dst_type, (size_t)100, buf, NULL, H5P_DEFAULT); H5Tclose(src_type); H5Tclose(dst_type); } @@ -2707,7 +2762,7 @@ my_isinf(int endian, unsigned char *val, size_t size, int retval = 0; size_t i; - bits = (unsigned char*)calloc(1, size); + bits = (unsigned char*)calloc((size_t)1, size); #ifdef H5_VMS if(H5T_ORDER_VAX==endian) { @@ -2812,7 +2867,7 @@ test_conv_flt_1 (const char *name, int run_test, hid_t src, hid_t dst) */ HDfflush(stdout); HDfflush(stderr); - if ((child_pid=fork())<0) { + if ((child_pid=fork()) < 0) { HDperror("fork"); return 1; } else if (child_pid>0) { @@ -2925,7 +2980,7 @@ test_conv_flt_1 (const char *name, int run_test, hid_t src, hid_t dst) dendian = H5Tget_order(dst); /* Allocate buffers */ - aligned = HDcalloc(1, MAX(sizeof(long double), sizeof(double))); + aligned = HDcalloc((size_t)1, MAX(sizeof(long double), sizeof(double))); /* Allocate and initialize the source buffer through macro INIT_FP_NORM or INIT_FP_SPECIAL. * The BUF will be used for the conversion while the SAVED buffer will be used for @@ -3017,7 +3072,7 @@ test_conv_flt_1 (const char *name, int run_test, hid_t src, hid_t dst) } /* Perform the conversion in software */ - if (H5Tconvert(src, dst, nelmts, buf, NULL, H5P_DEFAULT)<0) + if (H5Tconvert(src, dst, nelmts, buf, NULL, H5P_DEFAULT) < 0) goto error; /* Check the software results against the hardware */ @@ -3647,7 +3702,7 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) dst_size = H5Tget_size(dst); src_nbits = H5Tget_precision(src); /* not 8*src_size, esp on J90 - QAK */ dst_nbits = H5Tget_precision(dst); /* not 8*dst_size, esp on J90 - QAK */ - aligned = HDcalloc(1, MAX(sizeof(long double), sizeof(long long))); + aligned = HDcalloc((size_t)1, MAX(sizeof(long double), sizeof(long long))); #ifdef SHOW_OVERFLOWS noverflows_g = 0; #endif @@ -3664,19 +3719,19 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) * conversion exception happens. We only test (unsigned) int - float * and float - (unsigned) int conversions, which should cover more cases. */ - if((dxpl_id = H5Pcreate(H5P_DATASET_XFER))<0) + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) goto error; if((src_type == INT_INT && dst_type == FLT_FLOAT) || (src_type == INT_UINT && dst_type == FLT_FLOAT) || (src_type == FLT_FLOAT && dst_type == INT_UINT) || (src_type == FLT_FLOAT && dst_type == INT_INT)) { - if(H5Pset_type_conv_cb(dxpl_id, except_func, &fill_value)<0) + if(H5Pset_type_conv_cb(dxpl_id, except_func, &fill_value) < 0) goto error; else except_set = TRUE; - if(H5Pget_type_conv_cb(dxpl_id, &op, &user_data)<0) + if(H5Pget_type_conv_cb(dxpl_id, &op, &user_data) < 0) goto error; if(op != except_func || *(int*)user_data != fill_value) @@ -3743,7 +3798,7 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) goto error; /* Perform the conversion */ - if (H5Tconvert(src, dst, nelmts, buf, NULL, dxpl_id)<0) + if(H5Tconvert(src, dst, nelmts, buf, NULL, dxpl_id) < 0) goto error; /* Check the results from the library against hardware */ @@ -3801,6 +3856,10 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) hw_float = (float)(*((unsigned long long*)aligned)); break; #endif /* H5_ULLONG_TO_FP_CAST_WORKS */ + case FLT_FLOAT: + case FLT_DOUBLE: + case FLT_LDOUBLE: + case OTHER: default: break; } @@ -3849,6 +3908,10 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) hw_double = (double)(*((unsigned long long*)aligned)); break; #endif /* H5_ULLONG_TO_FP_CAST_WORKS */ + case FLT_FLOAT: + case FLT_DOUBLE: + case FLT_LDOUBLE: + case OTHER: default: break; } @@ -3898,6 +3961,10 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) hw_ldouble = (long double)(*((unsigned long long*)aligned)); break; #endif /* H5_ULLONG_TO_FP_CAST_WORKS */ + case FLT_FLOAT: + case FLT_DOUBLE: + case FLT_LDOUBLE: + case OTHER: default: break; } @@ -3919,6 +3986,17 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) hw_schar = (signed char)(*((long double*)aligned)); break; #endif + case INT_SCHAR: + case INT_UCHAR: + case INT_SHORT: + case INT_USHORT: + case INT_INT: + case INT_UINT: + case INT_LONG: + case INT_ULONG: + case INT_LLONG: + case INT_ULLONG: + case OTHER: default: break; } @@ -3939,6 +4017,17 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) hw_uchar = (unsigned char)(*((long double*)aligned)); break; #endif + case INT_SCHAR: + case INT_UCHAR: + case INT_SHORT: + case INT_USHORT: + case INT_INT: + case INT_UINT: + case INT_LONG: + case INT_ULONG: + case INT_LLONG: + case INT_ULLONG: + case OTHER: default: break; } @@ -3959,6 +4048,17 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) hw_short = (short)(*((long double*)aligned)); break; #endif + case INT_SCHAR: + case INT_UCHAR: + case INT_SHORT: + case INT_USHORT: + case INT_INT: + case INT_UINT: + case INT_LONG: + case INT_ULONG: + case INT_LLONG: + case INT_ULLONG: + case OTHER: default: break; } @@ -3979,6 +4079,17 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) hw_ushort = (unsigned short)(*((long double*)aligned)); break; #endif + case INT_SCHAR: + case INT_UCHAR: + case INT_SHORT: + case INT_USHORT: + case INT_INT: + case INT_UINT: + case INT_LONG: + case INT_ULONG: + case INT_LLONG: + case INT_ULLONG: + case OTHER: default: break; } @@ -3999,6 +4110,17 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) hw_int = (int)(*((long double*)aligned)); break; #endif + case INT_SCHAR: + case INT_UCHAR: + case INT_SHORT: + case INT_USHORT: + case INT_INT: + case INT_UINT: + case INT_LONG: + case INT_ULONG: + case INT_LLONG: + case INT_ULLONG: + case OTHER: default: break; } @@ -4019,6 +4141,17 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) hw_uint = (unsigned int)(*((long double*)aligned)); break; #endif + case INT_SCHAR: + case INT_UCHAR: + case INT_SHORT: + case INT_USHORT: + case INT_INT: + case INT_UINT: + case INT_LONG: + case INT_ULONG: + case INT_LLONG: + case INT_ULLONG: + case OTHER: default: break; } @@ -4039,6 +4172,17 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) hw_long = (long)(*((long double*)aligned)); break; #endif + case INT_SCHAR: + case INT_UCHAR: + case INT_SHORT: + case INT_USHORT: + case INT_INT: + case INT_UINT: + case INT_LONG: + case INT_ULONG: + case INT_LLONG: + case INT_ULLONG: + case OTHER: default: break; } @@ -4059,6 +4203,17 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) hw_ulong = (unsigned long)(*((long double*)aligned)); break; #endif + case INT_SCHAR: + case INT_UCHAR: + case INT_SHORT: + case INT_USHORT: + case INT_INT: + case INT_UINT: + case INT_LONG: + case INT_ULONG: + case INT_LLONG: + case INT_ULLONG: + case OTHER: default: break; } @@ -4079,6 +4234,17 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) hw_llong = (long long)(*((long double*)aligned)); break; #endif + case INT_SCHAR: + case INT_UCHAR: + case INT_SHORT: + case INT_USHORT: + case INT_INT: + case INT_UINT: + case INT_LONG: + case INT_ULONG: + case INT_LLONG: + case INT_ULLONG: + case OTHER: default: break; } @@ -4099,6 +4265,17 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) hw_ullong = (unsigned long long)(*((long double*)aligned)); break; #endif + case INT_SCHAR: + case INT_UCHAR: + case INT_SHORT: + case INT_USHORT: + case INT_INT: + case INT_UINT: + case INT_LONG: + case INT_ULONG: + case INT_LLONG: + case INT_ULLONG: + case OTHER: default: break; } @@ -4165,7 +4342,7 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) ) && (INT_SCHAR==dst_type || INT_SHORT==dst_type || INT_INT==dst_type || INT_LONG==dst_type || INT_LLONG==dst_type)) { - if(0==H5T_bit_get_d(src_bits, src_nbits-1, 1) && + if(0==H5T_bit_get_d(src_bits, src_nbits-1, (size_t)1) && overflows(src_bits, src, dst_nbits-1)) { /* * Source is positive and the magnitude is too large for @@ -4173,15 +4350,15 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) * maximum possible value: 0x7f...f */ if(!except_set) { - if (0==H5T_bit_get_d(dst_bits, dst_nbits-1, 1) && - H5T_bit_find(dst_bits, 0, dst_nbits-1, H5T_BIT_LSB, 0)<0) + if (0==H5T_bit_get_d(dst_bits, dst_nbits-1, (size_t)1) && + H5T_bit_find(dst_bits, (size_t)0, dst_nbits-1, H5T_BIT_LSB, 0) < 0) continue; /*no error*/ } else { /* fill_value is small so we know only the 1st byte is set */ if (dst_bits[0] == fill_value) continue; /*no error*/ } - } else if (1==H5T_bit_get_d(src_bits, src_nbits-1, 1) && + } else if (1==H5T_bit_get_d(src_bits, src_nbits-1, (size_t)1) && overflows(src_bits, src, dst_nbits-1)) { /* * Source is negative but the magnitude is too large for @@ -4189,8 +4366,8 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) * smallest possible value: 0x80...0 */ if(!except_set) { - if (1==H5T_bit_get_d(dst_bits, dst_nbits-1, 1) && - H5T_bit_find(dst_bits, 0, dst_nbits-1, H5T_BIT_LSB, 1)<0) + if (1==H5T_bit_get_d(dst_bits, dst_nbits-1, (size_t)1) && + H5T_bit_find(dst_bits, (size_t)0, dst_nbits-1, H5T_BIT_LSB, 1) < 0) continue; /*no error*/ } else { if (dst_bits[0] == fill_value) @@ -4206,14 +4383,14 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) ) && (INT_UCHAR==dst_type || INT_USHORT==dst_type || INT_UINT==dst_type || INT_ULONG==dst_type || INT_ULLONG==dst_type)) { - if (H5T_bit_get_d(src_bits, src_nbits-1, 1)) { + if (H5T_bit_get_d(src_bits, src_nbits-1, (size_t)1)) { /* * The source is negative so the result should be zero. * The source is negative if the most significant bit is * set. The destination is zero if all bits are zero. */ if(!except_set) { - if (H5T_bit_find(dst_bits, 0, dst_nbits, H5T_BIT_LSB, 1)<0) + if (H5T_bit_find(dst_bits, (size_t)0, dst_nbits, H5T_BIT_LSB, 1) < 0) continue; /*no error*/ } else { if (dst_bits[0] == fill_value) @@ -4226,7 +4403,7 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) * largest possible value: 0xff...f */ if(!except_set) { - if (H5T_bit_find(dst_bits, 0, dst_nbits, H5T_BIT_LSB, 0)<0) + if (H5T_bit_find(dst_bits, (size_t)0, dst_nbits, H5T_BIT_LSB, 0) < 0) continue; /*no error*/ } else { if (dst_bits[0] == fill_value) @@ -4558,8 +4735,8 @@ overflows(unsigned char *origin_bits, hid_t src_id, size_t dst_num_bits) ssize_t indx; unsigned char bits[32], mant_bits[32]; - HDmemset(bits, 0, 32); - HDmemset(mant_bits, 0, 32); + HDmemset(bits, 0, (size_t)32); + HDmemset(mant_bits, 0, (size_t)32); /* * Sometimes, type size isn't equal to the precision like Linux's "long @@ -4574,14 +4751,14 @@ overflows(unsigned char *origin_bits, hid_t src_id, size_t dst_num_bits) HDmemcpy(bits, origin_bits, src_prec/8+1); /*Check for special cases: +Inf, -Inf*/ - if (H5T_bit_find (bits, mpos, mant_digits, H5T_BIT_LSB, TRUE)<0) { - if (H5T_bit_find (bits, epos, expt_digits, H5T_BIT_LSB, FALSE)<0) { + if (H5T_bit_find (bits, mpos, mant_digits, H5T_BIT_LSB, TRUE) < 0) { + if (H5T_bit_find (bits, epos, expt_digits, H5T_BIT_LSB, FALSE) < 0) { ret_value=TRUE; goto done; } } else if (H5T_NORM_NONE==norm && H5T_bit_find (bits, mpos, mant_digits-1, - H5T_BIT_LSB, TRUE)<0 && H5T_bit_find (bits, epos, expt_digits, - H5T_BIT_LSB, FALSE)<0) { + H5T_BIT_LSB, TRUE) < 0 && H5T_bit_find (bits, epos, expt_digits, + H5T_BIT_LSB, FALSE) < 0) { /*This is a special case for the source of no implied mantissa bit. *If the exponent bits are all 1s and only the 1st bit of mantissa *is set to 1. It's infinity. The Intel-Linux "long double" is this case.*/ @@ -4598,19 +4775,19 @@ overflows(unsigned char *origin_bits, hid_t src_id, size_t dst_num_bits) } /* get significand */ - H5T_bit_copy (mant_bits, 0, bits, 0, mant_digits); + H5T_bit_copy (mant_bits, (size_t)0, bits, (size_t)0, mant_digits); /* restore implicit bit if normalization is implied*/ if(norm == H5T_NORM_IMPLIED) { - H5T_bit_inc(mant_bits, mant_digits, 1); + H5T_bit_inc(mant_bits, mant_digits, (size_t)1); mant_digits++; } /* shift significand */ - H5T_bit_shift (mant_bits, (ssize_t)(expt-expt_digits), 0, 32*8); + H5T_bit_shift (mant_bits, (ssize_t)(expt-expt_digits), (size_t)0, (size_t)(32 * 8)); - indx = H5T_bit_find(mant_bits, 0, 32*8, H5T_BIT_MSB, 1); + indx = H5T_bit_find(mant_bits, (size_t)0, (size_t)(32 * 8), H5T_BIT_MSB, 1); if((size_t)indx>=dst_num_bits) ret_value=TRUE; diff --git a/test/dtypes.c b/test/dtypes.c index 088030c..bb6f5e4 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -2322,6 +2322,7 @@ test_compound_13(void) TESTING("compound datatypes of boundary size with latest format"); /* Create some phony data. */ + HDmemset(&data_out, 0, sizeof(data_out)); for(u = 0; u < COMPOUND13_ARRAY_SIZE + 1; u++) data_out.x[u] = u; data_out.y = 99.99; @@ -5302,7 +5303,7 @@ test_encode(void) goto error; } /* end if */ - if(vlstr_buf_size>0) + if(vlstr_buf_size > 0) vlstr_buf = (unsigned char*)HDcalloc((size_t)1, vlstr_buf_size); if(H5Tencode(tid3, vlstr_buf, &vlstr_buf_size) < 0) { @@ -5317,6 +5318,7 @@ test_encode(void) printf("Can't decode VL string type\n"); goto error; } /* end if */ + free(vlstr_buf); /* Verify that the datatype was copied exactly */ if(H5Tequal(decoded_tid3, tid3)<=0) { diff --git a/test/fillval.c b/test/fillval.c index 8584816..697fe5f 100644 --- a/test/fillval.c +++ b/test/fillval.c @@ -1142,6 +1142,7 @@ test_rdwr(hid_t fapl, const char *base_name, H5D_layout_t layout) /* case for H5D_FILL_TIME_ALLOC as fill write time and fill value is user-defined * as compound type */ if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) goto error; + HDmemset(&fill_ctype, 0, sizeof(fill_ctype)); fill_ctype.y = 4444.4444; if(H5Pset_fill_value(dcpl, ctype_id, &fill_ctype) < 0) goto error; nerrors += test_rdwr_cases(file, dcpl, "dset11", &fill_ctype, H5D_FILL_TIME_ALLOC, @@ -1194,6 +1195,7 @@ test_rdwr(hid_t fapl, const char *base_name, H5D_layout_t layout) /* case for H5D_FILL_TIME_ALLOC as fill write time and fill value is user-defined * as compound type */ if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) goto error; + HDmemset(&fill_ctype, 0, sizeof(fill_ctype)); fill_ctype.y = 4444.4444; if(H5Pset_fill_value(dcpl, ctype_id, &fill_ctype) < 0) goto error; nerrors += test_rdwr_cases(file, dcpl, "dset12", &fill_ctype, H5D_FILL_TIME_ALLOC, diff --git a/test/gheap.c b/test/gheap.c index b2c9090..2829e34 100644 --- a/test/gheap.c +++ b/test/gheap.c @@ -75,24 +75,24 @@ const char *FILENAME[] = { static int test_1 (hid_t fapl) { - hid_t file=-1; - H5F_t *f=NULL; + hid_t file = -1; + H5F_t *f = NULL; H5HG_t obj[1024]; uint8_t out[1024]; uint8_t in[1024]; int i; size_t size; herr_t status; - int nerrors=0; + int nerrors = 0; char filename[1024]; TESTING("monotonically increasing lengths"); /* Open a clean file */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) goto error; - if (NULL==(f=H5I_object(file))) { + if(NULL == (f = (H5F_t *)H5I_object(file))) { H5_FAILED(); puts(" Unable to create file"); goto error; @@ -103,16 +103,16 @@ test_1 (hid_t fapl) * a clean file, the addresses allocated for the collections should also * be monotonically increasing. */ - for (i=0; i<1024; i++) { - size = i+1; - memset (out, 'A'+i%26, size); + for(i = 0; i < 1024; i++) { + size = i + 1; + HDmemset(out, 'A' + i % 26, size); H5Eclear2(H5E_DEFAULT); - status = H5HG_insert (f, H5P_DATASET_XFER_DEFAULT, size, out, obj+i); - if (status<0) { + status = H5HG_insert(f, H5P_DATASET_XFER_DEFAULT, size, out, obj + i); + if(status < 0) { H5_FAILED(); puts(" Unable to insert object into global heap"); nerrors++; - } else if (i && H5F_addr_gt (obj[i-1].addr, obj[i].addr)) { + } else if(i && H5F_addr_gt(obj[i - 1].addr, obj[i].addr)) { H5_FAILED(); puts(" Collection addresses are not monotonically increasing"); nerrors++; @@ -122,27 +122,28 @@ test_1 (hid_t fapl) /* * Now try to read each object back. */ - for (i=0; i<1024; i++) { - size = i+1; - memset (out, 'A'+i%26, size); + for(i = 0; i < 1024; i++) { + size = i + 1; + HDmemset(out, 'A' + i % 26, size); H5Eclear2(H5E_DEFAULT); - if (NULL==H5HG_read (f, H5P_DATASET_XFER_DEFAULT, obj+i, in, NULL)) { + if(NULL == H5HG_read(f, H5P_DATASET_XFER_DEFAULT, obj + i, in, NULL)) { H5_FAILED(); puts(" Unable to read object"); nerrors++; - } else if (memcmp (in, out, size)) { + } else if(HDmemcmp(in, out, size)) { H5_FAILED(); puts(" Value read doesn't match value written"); nerrors++; } } - if (H5Fclose(file)<0) goto error; - if (nerrors) goto error; + if(H5Fclose(file) < 0) goto error; + if(nerrors) goto error; + PASSED(); return 0; - error: +error: H5E_BEGIN_TRY { H5Fclose(file); } H5E_END_TRY; @@ -170,23 +171,23 @@ test_1 (hid_t fapl) static int test_2 (hid_t fapl) { - hid_t file=-1; - H5F_t *f=NULL; + hid_t file = -1; + H5F_t *f = NULL; H5HG_t obj[1024]; uint8_t out[1024]; uint8_t in[1024]; int i; size_t size; - int nerrors=0; + int nerrors = 0; char filename[1024]; TESTING("monotonically decreasing lengths"); /* Open a clean file */ h5_fixname(FILENAME[1], fapl, filename, sizeof filename); - if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) goto error; - if (NULL==(f=H5I_object(file))) { + if(NULL == (f = (H5F_t *)H5I_object(file))) { H5_FAILED(); puts(" Unable to create file"); goto error; @@ -257,23 +258,23 @@ test_2 (hid_t fapl) static int test_3 (hid_t fapl) { - hid_t file=-1; - H5F_t *f=NULL; + hid_t file = -1; + H5F_t *f = NULL; H5HG_t obj[1024]; uint8_t out[1024]; int i; size_t size; herr_t status; - int nerrors=0; + int nerrors = 0; char filename[1024]; TESTING("complete object removal"); /* Open a clean file */ h5_fixname(FILENAME[2], fapl, filename, sizeof filename); - if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) goto error; - if (NULL==(f=H5I_object(file))) { + if(NULL == (f = (H5F_t *)H5I_object(file))) { H5_FAILED(); puts(" Unable to create file"); goto error; @@ -336,23 +337,23 @@ test_3 (hid_t fapl) static int test_4 (hid_t fapl) { - hid_t file=-1; - H5F_t *f=NULL; + hid_t file = -1; + H5F_t *f = NULL; H5HG_t obj[1024]; uint8_t out[1024]; int i; size_t size; herr_t status; - int nerrors=0; + int nerrors = 0; char filename[1024]; TESTING("partial object removal"); /* Open a clean file */ h5_fixname(FILENAME[3], fapl, filename, sizeof filename); - if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) goto error; - if (NULL==(f=H5I_object(file))) { + if(NULL == (f = (H5F_t *)H5I_object(file))) { H5_FAILED(); puts(" Unable to create file"); goto error; diff --git a/test/hyperslab.c b/test/hyperslab.c index e216b95..fdeaffd 100644 --- a/test/hyperslab.c +++ b/test/hyperslab.c @@ -125,7 +125,7 @@ print_ref(size_t nx, size_t ny, size_t nz) { uint8_t *array; - if(NULL != (array = HDmalloc(nx * ny * nz))) { + if(NULL != (array = (uint8_t *)HDmalloc(nx * ny * nz))) { printf("Reference array:\n"); init_full(array, nx, ny, nz); print_array(array, nx, ny, nz); @@ -190,7 +190,7 @@ test_fill(size_t nx, size_t ny, size_t nz, fflush(stdout); /* Allocate array */ - if(NULL == (dst = HDcalloc((size_t)1, nx * ny * nz))) + if(NULL == (dst = (uint8_t *)HDcalloc((size_t)1, nx * ny * nz))) TEST_ERROR init_full(dst, nx, ny, nz); @@ -387,9 +387,9 @@ test_copy(int mode, /* * Allocate arrays */ - if(NULL == (src = HDcalloc((size_t)1, nx * ny * nz))) + if(NULL == (src = (uint8_t *)HDcalloc((size_t)1, nx * ny * nz))) TEST_ERROR - if(NULL == (dst = HDcalloc((size_t)1, nx * ny * nz))) + if(NULL == (dst = (uint8_t *)HDcalloc((size_t)1, nx * ny * nz))) TEST_ERROR init_full(src, nx, ny, nz); @@ -602,9 +602,9 @@ test_multifill(size_t nx) fflush(stdout); /* Initialize the source and destination */ - if(NULL == (src = HDmalloc(nx * sizeof(*src)))) + if(NULL == (src = (struct a_struct *)HDmalloc(nx * sizeof(*src)))) TEST_ERROR - if(NULL == (dst = HDmalloc(nx * sizeof(*dst)))) + if(NULL == (dst = (struct a_struct *)HDmalloc(nx * sizeof(*dst)))) TEST_ERROR for(i = 0; i < nx; i++) { @@ -717,9 +717,9 @@ test_endian(size_t nx) fflush(stdout); /* Initialize arrays */ - if(NULL == (src = HDmalloc(nx * 4))) + if(NULL == (src = (uint8_t *)HDmalloc(nx * 4))) TEST_ERROR - if(NULL == (dst = HDcalloc(nx , (size_t)4))) + if(NULL == (dst = (uint8_t *)HDcalloc(nx , (size_t)4))) TEST_ERROR init_full(src, nx, (size_t)4,(size_t)1); @@ -805,9 +805,9 @@ test_transpose(size_t nx, size_t ny) fflush(stdout); /* Initialize */ - if(NULL == (src = HDmalloc(nx * ny * sizeof(*src)))) + if(NULL == (src = (int *)HDmalloc(nx * ny * sizeof(*src)))) TEST_ERROR - if(NULL == (dst = HDcalloc(nx * ny, sizeof(*dst)))) + if(NULL == (dst = (int *)HDcalloc(nx * ny, sizeof(*dst)))) TEST_ERROR for(i = 0; i < nx; i++) @@ -911,11 +911,11 @@ test_sub_super(size_t nx, size_t ny) fflush(stdout); /* Initialize */ - if(NULL == (full = HDmalloc(4 * nx * ny))) + if(NULL == (full = (uint8_t *)HDmalloc(4 * nx * ny))) TEST_ERROR - if(NULL == (half = HDcalloc((size_t)1, nx * ny))) + if(NULL == (half = (uint8_t *)HDcalloc((size_t)1, nx * ny))) TEST_ERROR - if(NULL == (twice = HDcalloc((size_t)4, nx * ny))) + if(NULL == (twice = (uint8_t *)HDcalloc((size_t)4, nx * ny))) TEST_ERROR init_full(full, 2 * nx, 2 * ny, (size_t)1); @@ -1063,7 +1063,7 @@ test_array_fill(size_t lo, size_t hi) TESTING(s); /* Initialize */ - if(NULL == (dst = HDcalloc(sizeof(int),ARRAY_FILL_SIZE * hi))) + if(NULL == (dst = (int *)HDcalloc(sizeof(int),ARRAY_FILL_SIZE * hi))) TEST_ERROR /* Setup */ @@ -1128,7 +1128,7 @@ test_array_offset_n_calc(size_t n, size_t x, size_t y, size_t z) TESTING(s); /* Initialize */ - if(NULL == (a = HDmalloc(sizeof(hsize_t) * x * y *z))) + if(NULL == (a = (hsize_t *)HDmalloc(sizeof(hsize_t) * x * y *z))) TEST_ERROR dims[0] = z; diff --git a/test/objcopy.c b/test/objcopy.c index 7f971b4..f4fee13 100755 --- a/test/objcopy.c +++ b/test/objcopy.c @@ -803,7 +803,7 @@ compare_std_attributes(hid_t oid, hid_t oid2, hid_t pid) /* Check the attributes are equal */ for(i = 0; i < (unsigned)oinfo1.num_attrs; i++) { if((aid = H5Aopen_by_idx(oid, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)i, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Aget_name(aid, ATTR_NAME_LEN, attr_name) < 0) TEST_ERROR + if(H5Aget_name(aid, (size_t)ATTR_NAME_LEN, attr_name) < 0) TEST_ERROR if((aid2 = H5Aopen(oid2, attr_name, H5P_DEFAULT)) < 0) TEST_ERROR @@ -988,8 +988,7 @@ compare_data(hid_t parent1, hid_t parent2, hid_t pid, hid_t tid, size_t nelmts, } /* Check for types of objects handled */ - switch(obj1_type) - { + switch(obj1_type) { case H5O_TYPE_DATASET: if(compare_datasets(obj1_id, obj2_id, pid, NULL) != TRUE) TEST_ERROR break; @@ -1002,6 +1001,8 @@ compare_data(hid_t parent1, hid_t parent2, hid_t pid, hid_t tid, size_t nelmts, if(H5Tequal(obj1_id, obj2_id) != TRUE) TEST_ERROR break; + case H5O_TYPE_UNKNOWN: + case H5O_TYPE_NTYPES: default: TEST_ERROR } /* end switch */ @@ -1045,8 +1046,7 @@ compare_data(hid_t parent1, hid_t parent2, hid_t pid, hid_t tid, size_t nelmts, } /* Check for types of objects handled */ - switch(obj1_type) - { + switch(obj1_type) { case H5O_TYPE_DATASET: if(compare_datasets(obj1_id, obj2_id, pid, NULL) != TRUE) TEST_ERROR break; @@ -1059,6 +1059,8 @@ compare_data(hid_t parent1, hid_t parent2, hid_t pid, hid_t tid, size_t nelmts, if(H5Tequal(obj1_id, obj2_id) != TRUE) TEST_ERROR break; + case H5O_TYPE_UNKNOWN: + case H5O_TYPE_NTYPES: default: TEST_ERROR } /* end switch */ @@ -1188,8 +1190,8 @@ compare_datasets(hid_t did, hid_t did2, hid_t pid, const void *wbuf) /* Ensure that all external file information is the same */ for(x=0; x < (unsigned) ext_count; ++x) { - if(H5Pget_external(dcpl, x, NAME_BUF_SIZE, name1, &offset1, &size1) < 0) TEST_ERROR - if(H5Pget_external(dcpl2, x, NAME_BUF_SIZE, name2, &offset2, &size2) < 0) TEST_ERROR + if(H5Pget_external(dcpl, x, (size_t)NAME_BUF_SIZE, name1, &offset1, &size1) < 0) TEST_ERROR + if(H5Pget_external(dcpl2, x, (size_t)NAME_BUF_SIZE, name2, &offset2, &size2) < 0) TEST_ERROR if(offset1 != offset2) TEST_ERROR if(size1 != size2) TEST_ERROR @@ -1413,6 +1415,8 @@ compare_groups(hid_t gid, hid_t gid2, hid_t pid, int depth, unsigned copy_flags) if(H5Tequal(oid, oid2) != TRUE) TEST_ERROR break; + case H5O_TYPE_UNKNOWN: + case H5O_TYPE_NTYPES: default: HDassert(0 && "Unknown type of object"); break; @@ -2112,10 +2116,13 @@ test_copy_dataset_compound(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) TESTING("H5Ocopy(): compound dataset"); - for (i=0; i<DIM_SIZE_1; i++) { +#ifdef H5_CLEAR_MEMORY + HDmemset(buf, 0, sizeof(buf)); +#endif /* H5_CLEAR_MEMORY */ + for(i = 0; i < DIM_SIZE_1; i++) { buf[i].a = i; - buf[i].d = 1./(i+1); - } + buf[i].d = 1. / (i + 1); + } /* end for */ /* Initialize the filenames */ h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); @@ -2134,7 +2141,7 @@ test_copy_dataset_compound(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) if((sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR /* create datatype */ - if((tid = H5Tcreate (H5T_COMPOUND, sizeof(comp_t))) < 0) TEST_ERROR + if((tid = H5Tcreate(H5T_COMPOUND, sizeof(comp_t))) < 0) TEST_ERROR if(H5Tinsert(tid, "int_name", HOFFSET(comp_t, a), H5T_NATIVE_INT) < 0) TEST_ERROR if(H5Tinsert(tid, "double_name", HOFFSET(comp_t, d), H5T_NATIVE_DOUBLE) < 0) TEST_ERROR @@ -8287,7 +8294,7 @@ main(void) /* Create an FCPL with sharing enabled */ if((fcpl_shared = H5Pcreate(H5P_FILE_CREATE)) < 0) TEST_ERROR if(H5Pset_shared_mesg_nindexes(fcpl_shared, 1) < 0) TEST_ERROR - if(H5Pset_shared_mesg_index(fcpl_shared, 0, H5O_SHMESG_ALL_FLAG, (size_t) 10) < 0) TEST_ERROR + if(H5Pset_shared_mesg_index(fcpl_shared, 0, H5O_SHMESG_ALL_FLAG, 10) < 0) TEST_ERROR /* Obtain the default attribute storage phase change values */ if((ocpl = H5Pcreate(H5P_OBJECT_CREATE)) < 0) TEST_ERROR @@ -8422,7 +8429,7 @@ main(void) nerrors += test_copy_same_file_named_datatype(fcpl_src, my_fapl); nerrors += test_copy_old_layout(fcpl_dst, my_fapl); nerrors += test_copy_null_ref(fcpl_src, fcpl_dst, my_fapl); - } + } /* TODO: not implemented nerrors += test_copy_mount(my_fapl); diff --git a/test/pool.c b/test/pool.c index 9b2e8b9..916d45e 100644 --- a/test/pool.c +++ b/test/pool.c @@ -649,11 +649,11 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time); TEST_ERROR /* Allocate space for the block sizes */ - if(NULL == (blk_size = HDmalloc(sizeof(size_t) * MPOOL_NUM_RANDOM))) + if(NULL == (blk_size = (size_t *)HDmalloc(sizeof(size_t) * MPOOL_NUM_RANDOM))) TEST_ERROR /* Allocate space for the block pointers */ - if(NULL == (spc = HDmalloc(sizeof(void *) * MPOOL_NUM_RANDOM))) + if(NULL == (spc = (void **)HDmalloc(sizeof(void *) * MPOOL_NUM_RANDOM))) TEST_ERROR /* Initialize the block sizes with random values */ diff --git a/test/stab.c b/test/stab.c index cab0b1b..e8ffec3 100644 --- a/test/stab.c +++ b/test/stab.c @@ -53,7 +53,6 @@ const char *FILENAME[] = { /* Definitions for 'read_old' test */ #define READ_OLD_NGROUPS 100 -#define READ_OLD_BUFSIZE 1024 /* The group_old.h5 is generated from gen_old_fill.c in HDF5 'test' directory * for version 1.6. To get this data file, simply compile gen_old_group.c with @@ -79,7 +78,6 @@ const char *FILENAME[] = { /* Definitions for 'corrupt_stab_msg' test */ #define CORRUPT_STAB_FILE "corrupt_stab_msg.h5" #define CORRUPT_STAB_TMP_FILE "corrupt_stab_msg_tmp.h5" -#define CORRUPT_STAB_COPY_BUF_SIZE 4096 #define CORRUPT_STAB_DSET "DS1" diff --git a/test/tattr.c b/test/tattr.c index bec6743..baf30cc 100644 --- a/test/tattr.c +++ b/test/tattr.c @@ -9802,6 +9802,7 @@ test_attr_bug3(hid_t fcpl, hid_t fapl) dims2[2] = {3, 3}; /* Dimensions */ int wdata1[2][2]; unsigned wdata2[3][3]; /* Write buffers */ + unsigned u, v; /* Local index variables */ herr_t ret; /* Generic return status */ /* Output message about test being performed */ @@ -9849,11 +9850,18 @@ test_attr_bug3(hid_t fcpl, hid_t fapl) aid2 = H5Aopen(did, "attr", H5P_DEFAULT); CHECK(aid2, FAIL, "H5Aopen"); - /* Write data to the attributes (the data is uninitialized, we only care - * that H5Awrite succeeds for now) */ - ret = H5Awrite(aid1, H5T_NATIVE_INT, wdata1[0]); + /* Initialize the write buffers */ + for(u = 0; u < dims1[0]; u++) + for(v = 0; v < dims1[1]; v++) + wdata1[u][v] = (int)((u * dims1[1]) + v); + for(u = 0; u < dims2[0]; u++) + for(v = 0; v < dims2[1]; v++) + wdata2[u][v] = (int)((u * dims2[1]) + v); + + /* Write data to the attributes */ + ret = H5Awrite(aid1, H5T_NATIVE_INT, wdata1); CHECK(ret, FAIL, "H5Awrite"); - ret = H5Awrite(aid2, H5T_NATIVE_UINT, wdata2[0]); + ret = H5Awrite(aid2, H5T_NATIVE_UINT, wdata2); CHECK(ret, FAIL, "H5Awrite"); /* Close attributes */ diff --git a/test/th5s.c b/test/th5s.c index a57cd80..5ff811b 100644 --- a/test/th5s.c +++ b/test/th5s.c @@ -894,6 +894,10 @@ test_h5s_compound_scalar_write(void) ret = H5Dclose(dataset); CHECK(ret, FAIL, "H5Dclose"); + /* Close compound datatype */ + ret = H5Tclose(tid1); + CHECK(ret, FAIL, "H5Tclose"); + /* Close scalar dataspace */ ret = H5Sclose(sid1); CHECK(ret, FAIL, "H5Sclose"); diff --git a/test/tsohm.c b/test/tsohm.c index 8782a6d..62154b1 100644 --- a/test/tsohm.c +++ b/test/tsohm.c @@ -74,6 +74,7 @@ typedef struct dtype1_struct { int i8; float f1; } dtype1_struct; + #define DTYPE2_SIZE 1024 const char *DSETNAME[] = { "dataset0", "dataset1", @@ -167,7 +168,9 @@ static hid_t make_dtype_1(void); static hid_t make_dtype_2(void); static hid_t close_reopen_file(hid_t file, const char* filename, hid_t fapl_id); static void test_sohm_attrs(void); +#ifdef NOT_NOW static void size2_dump_struct(const char *name, size2_helper_struct *sizes); +#endif /* NOT_NOW */ static void size2_verify(void); static void test_sohm_delete(void); static void test_sohm_delete_revert(void); @@ -280,11 +283,10 @@ static void test_sohm_fcpl(void) /* Set up index values */ ret = H5Pset_shared_mesg_nindexes(fcpl_id, TEST_NUM_INDEXES); CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); - for(x=0; x<TEST_NUM_INDEXES; ++x) - { + for(x = 0; x < TEST_NUM_INDEXES; ++x) { ret = H5Pset_shared_mesg_index(fcpl_id, x, test_type_flags[x], test_minsizes[x]); CHECK_I(ret, "H5Pset_shared_mesg_index"); - } + } /* end for */ ret = H5Pset_shared_mesg_phase_change(fcpl_id, TEST_L2B, TEST_B2L); CHECK_I(ret, "H5Pset_shared_mesg_phase_change"); @@ -419,8 +421,6 @@ static void test_sohm_fcpl(void) * Programmer: James Laird * Saturday, August 26, 2006 * - * Modifications: - * *------------------------------------------------------------------------- */ static hid_t @@ -429,23 +429,23 @@ make_dtype_1(void) hid_t dtype1_id = -1; hid_t str_id = -1; - /* Create compound datatype. */ - if((dtype1_id = H5Tcreate( H5T_COMPOUND, sizeof(struct dtype1_struct))) < 0) TEST_ERROR + /* Create compound datatype. */ + if((dtype1_id = H5Tcreate(H5T_COMPOUND, sizeof(struct dtype1_struct))) < 0) TEST_ERROR - if(H5Tinsert(dtype1_id,"i1",HOFFSET(struct dtype1_struct,i1),H5T_NATIVE_INT) < 0) TEST_ERROR + if(H5Tinsert(dtype1_id, "i1", HOFFSET(dtype1_struct, i1), H5T_NATIVE_INT) < 0) TEST_ERROR str_id = H5Tcopy(H5T_C_S1); - if(H5Tset_size(str_id,(size_t) 10) < 0) TEST_ERROR - - if(H5Tinsert(dtype1_id,"vl_string",HOFFSET(dtype1_struct,str),str_id) < 0) TEST_ERROR - if(H5Tinsert(dtype1_id,"i2",HOFFSET(struct dtype1_struct,i2),H5T_NATIVE_INT) < 0) TEST_ERROR - if(H5Tinsert(dtype1_id,"i3",HOFFSET(struct dtype1_struct,i3),H5T_NATIVE_INT) < 0) TEST_ERROR - if(H5Tinsert(dtype1_id,"i4",HOFFSET(struct dtype1_struct,i4),H5T_NATIVE_INT) < 0) TEST_ERROR - if(H5Tinsert(dtype1_id,"i5",HOFFSET(struct dtype1_struct,i5),H5T_NATIVE_INT) < 0) TEST_ERROR - if(H5Tinsert(dtype1_id,"i6",HOFFSET(struct dtype1_struct,i6),H5T_NATIVE_INT) < 0) TEST_ERROR - if(H5Tinsert(dtype1_id,"i7",HOFFSET(struct dtype1_struct,i7),H5T_NATIVE_INT) < 0) TEST_ERROR - if(H5Tinsert(dtype1_id,"i8",HOFFSET(struct dtype1_struct,i8),H5T_NATIVE_INT) < 0) TEST_ERROR - if(H5Tinsert(dtype1_id,"f1",HOFFSET(struct dtype1_struct,f1),H5T_NATIVE_FLOAT) < 0) TEST_ERROR + if(H5Tset_size(str_id, (size_t)10) < 0) TEST_ERROR + + if(H5Tinsert(dtype1_id, "string", HOFFSET(dtype1_struct, str), str_id) < 0) TEST_ERROR + if(H5Tinsert(dtype1_id, "i2", HOFFSET(dtype1_struct, i2), H5T_NATIVE_INT) < 0) TEST_ERROR + if(H5Tinsert(dtype1_id, "i3", HOFFSET(dtype1_struct, i3), H5T_NATIVE_INT) < 0) TEST_ERROR + if(H5Tinsert(dtype1_id, "i4", HOFFSET(dtype1_struct, i4), H5T_NATIVE_INT) < 0) TEST_ERROR + if(H5Tinsert(dtype1_id, "i5", HOFFSET(dtype1_struct, i5), H5T_NATIVE_INT) < 0) TEST_ERROR + if(H5Tinsert(dtype1_id, "i6", HOFFSET(dtype1_struct, i6), H5T_NATIVE_INT) < 0) TEST_ERROR + if(H5Tinsert(dtype1_id, "i7", HOFFSET(dtype1_struct, i7), H5T_NATIVE_INT) < 0) TEST_ERROR + if(H5Tinsert(dtype1_id, "i8", HOFFSET(dtype1_struct, i8), H5T_NATIVE_INT) < 0) TEST_ERROR + if(H5Tinsert(dtype1_id, "f1", HOFFSET(dtype1_struct, f1), H5T_NATIVE_FLOAT) < 0) TEST_ERROR if(H5Tclose(str_id) < 0) TEST_ERROR @@ -488,15 +488,13 @@ make_dtype_2(void) /* Create an int with a strange precision */ if((int_id = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR - if(H5Tset_precision(int_id, 24) < 0) TEST_ERROR + if(H5Tset_precision(int_id, (size_t)24) < 0) TEST_ERROR /* Create an enumeration using that int */ if((enum_id = H5Tenum_create(int_id)) < 0) TEST_ERROR - for(x=0; x<ENUM_NUM_MEMBS; x++) - { + for(x = 0; x < ENUM_NUM_MEMBS; x++) if(H5Tenum_insert(enum_id, ENUM_NAME[x], &ENUM_VAL[x]) < 0) TEST_ERROR - } /* Create arrays of arrays of arrays of enums */ if((dtype2_id = H5Tarray_create2(enum_id, 3, dims)) < 0) TEST_ERROR @@ -572,14 +570,12 @@ error: * Programmer: James Laird * Monday, April 10, 2006 * - * Modifications: - * *------------------------------------------------------------------------- */ static hid_t size1_helper(hid_t file, const char* filename, hid_t fapl_id, int test_file_closing) { - dtype1_struct wdata = {11, "string", 22, 33, 44, 55, 66, 77, 88, 0.0}; + dtype1_struct wdata; dtype1_struct rdata; hid_t dtype1_id = -1; hid_t space_id = -1; @@ -593,23 +589,36 @@ size1_helper(hid_t file, const char* filename, hid_t fapl_id, int test_file_clos if(GetTestExpress() > 1) test_file_closing = 0; + /* Intialize wdata */ + HDmemset(&wdata, 0, sizeof(wdata)); + wdata.i1 = 11; + HDstrcpy(wdata.str, "string"); + wdata.i2 = 22; + wdata.i3 = 33; + wdata.i4 = 44; + wdata.i5 = 55; + wdata.i6 = 66; + wdata.i7 = 77; + wdata.i8 = 88; + wdata.f1 = 0.0; + /* Intialize rdata */ - strcpy(rdata.str, "\0"); + HDmemset(&rdata, 0, sizeof(rdata)); if((dtype1_id = make_dtype_1()) < 0) TEST_ERROR /* Create the dataspace and dataset */ dim1[0] = 1; - if((space_id=H5Screate_simple(1,dim1,NULL)) < 0) TEST_ERROR + if((space_id = H5Screate_simple(1, dim1, NULL)) < 0) TEST_ERROR - if((dset_id = H5Dcreate2(file,DSETNAME[0],dtype1_id,space_id,H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if((dset_id = H5Dcreate2(file, DSETNAME[0], dtype1_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Test writing and reading */ - if(H5Dwrite(dset_id,dtype1_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,&wdata) < 0) FAIL_STACK_ERROR + if(H5Dwrite(dset_id, dtype1_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata) < 0) FAIL_STACK_ERROR - if(H5Dread(dset_id,dtype1_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,&rdata) < 0) FAIL_STACK_ERROR + if(H5Dread(dset_id, dtype1_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata) < 0) FAIL_STACK_ERROR - if(rdata.i1!=wdata.i1 || rdata.i2!=wdata.i2 || HDstrcmp(rdata.str, wdata.str)) { + if(rdata.i1 != wdata.i1 || rdata.i2 != wdata.i2 || HDstrcmp(rdata.str, wdata.str)) { H5_FAILED(); AT(); printf("incorrect read data\n"); goto error; @@ -617,26 +626,23 @@ size1_helper(hid_t file, const char* filename, hid_t fapl_id, int test_file_clos if(H5Dclose(dset_id) < 0) FAIL_STACK_ERROR /* Close and re-open the file if requested*/ - if(test_file_closing) { + if(test_file_closing) if((file = close_reopen_file(file, filename, fapl_id)) < 0) TEST_ERROR - } /* Create more datasets with the same datatype */ - if((dset_id = H5Dcreate2(file,DSETNAME[1],dtype1_id,space_id,H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if((dset_id = H5Dcreate2(file, DSETNAME[1], dtype1_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR if(H5Dclose(dset_id) < 0) FAIL_STACK_ERROR /* Close and re-open the file if requested*/ - if(test_file_closing) { + if(test_file_closing) if((file = close_reopen_file(file, filename, fapl_id)) < 0) TEST_ERROR - } - if((dset_id = H5Dcreate2(file,DSETNAME[2],dtype1_id,space_id,H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if((dset_id = H5Dcreate2(file, DSETNAME[2], dtype1_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR if(H5Dclose(dset_id) < 0) TEST_ERROR /* Close and re-open the file if requested*/ - if(test_file_closing) { + if(test_file_closing) if((file = close_reopen_file(file, filename, fapl_id)) < 0) TEST_ERROR - } if((dset_id = H5Dcreate2(file,DSETNAME[3],dtype1_id,space_id,H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -654,10 +660,8 @@ size1_helper(hid_t file, const char* filename, hid_t fapl_id, int test_file_clos if((dset_id = H5Dopen2(file, DSETNAME[0], H5P_DEFAULT)) < 0) TEST_ERROR if((dtype1_id = H5Dget_type(dset_id)) < 0) TEST_ERROR - rdata.i1 = rdata.i2 = 0; - HDstrcpy(rdata.str, "\0"); - /* Read data back again */ + HDmemset(&rdata, 0, sizeof(rdata)); if(H5Dread(dset_id, dtype1_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata) < 0) { H5_FAILED(); AT(); printf("Can't read data\n"); @@ -689,9 +693,8 @@ size1_helper(hid_t file, const char* filename, hid_t fapl_id, int test_file_clos if((dset_id = H5Dopen2(file, DSETNAME[3], H5P_DEFAULT)) < 0) TEST_ERROR if((dtype1_id = H5Dget_type(dset_id)) < 0) TEST_ERROR - rdata.i1 = rdata.i2 = 0; - /* Read data back again */ + HDmemset(&rdata, 0, sizeof(rdata)); if(H5Dread(dset_id, dtype1_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata) < 0) { H5_FAILED(); AT(); printf("Can't read data\n"); @@ -1016,12 +1019,11 @@ static void sohm_attr_helper(hid_t fcpl_id) CHECK_I(ret, "H5Fflush"); /* Verify */ - memset(rdata, 0, sizeof(rdata)); + HDmemset(rdata, 0, sizeof(rdata)); ret = H5Aread(attr_id, H5T_NATIVE_INT, rdata); CHECK_I(ret, "H5Aread"); - for(x=0; x<(size_t)dims; ++x) { + for(x = 0; x < (size_t)dims; ++x) VERIFY(rdata[x], wdata[x], "H5Aread"); - } /* Cleanup */ ret = H5Aclose(attr_id); @@ -1055,12 +1057,11 @@ static void sohm_attr_helper(hid_t fcpl_id) CHECK_I(ret, "H5Fflush"); /* Verify */ - memset(rdata, 0, sizeof(rdata)); + HDmemset(rdata, 0, sizeof(rdata)); ret = H5Aread(attr_id, H5T_NATIVE_INT, rdata); CHECK_I(ret, "H5Aread"); - for(x=0; x<(size_t)dims; ++x) { + for(x = 0; x < (size_t)dims; ++x) VERIFY(rdata[x], wdata[x], "H5Aread"); - } /* Cleanup */ ret = H5Aclose(attr_id); @@ -1092,13 +1093,12 @@ static void sohm_attr_helper(hid_t fcpl_id) CHECK_I(ret, "H5Fflush"); /* Verify the data with another ID handle */ - memset(rdata, 0, sizeof(rdata)); + HDmemset(rdata, 0, sizeof(rdata)); ret = H5Aread(attr_id2, H5T_NATIVE_INT, rdata); CHECK_I(ret, "H5Aread"); - for(x=0; x<(size_t)dims; ++x) { + for(x = 0; x < (size_t)dims; ++x) VERIFY(rdata[x], wdata[x], "H5Aread"); - } /* Cleanup */ ret = H5Aclose(attr_id); @@ -1249,23 +1249,23 @@ static void size2_verify_plist1(hid_t plist) /* Hardcoded to correspond to dcpl1_id created in size2_helper */ /* Check filters */ cd_nelmts = 1; - filter = H5Pget_filter2(plist, 0, NULL, &cd_nelmts, &cd_value, NAME_BUF_SIZE, name, NULL); + filter = H5Pget_filter2(plist, 0, NULL, &cd_nelmts, &cd_value, (size_t)NAME_BUF_SIZE, name, NULL); CHECK_I(filter, "H5Pget_filter2"); VERIFY(filter, H5Z_FILTER_SHUFFLE, "H5Pget_filter2"); cd_nelmts = 1; - filter = H5Pget_filter2(plist, 1, NULL, &cd_nelmts, &cd_value, NAME_BUF_SIZE, name, NULL); + filter = H5Pget_filter2(plist, 1, NULL, &cd_nelmts, &cd_value, (size_t)NAME_BUF_SIZE, name, NULL); CHECK_I(filter, "H5Pget_filter2"); VERIFY(filter, H5Z_FILTER_DEFLATE, "H5Pget_filter2"); VERIFY(cd_value, 1, "H5Pget_filter2"); cd_nelmts = 1; - filter = H5Pget_filter2(plist, 2, NULL, &cd_nelmts, &cd_value, NAME_BUF_SIZE, name, NULL); + filter = H5Pget_filter2(plist, 2, NULL, &cd_nelmts, &cd_value, (size_t)NAME_BUF_SIZE, name, NULL); CHECK_I(filter, "H5Pget_filter2"); VERIFY(filter, H5Z_FILTER_SHUFFLE, "H5Pget_filter2"); cd_nelmts = 1; - filter = H5Pget_filter2(plist, 3, NULL, &cd_nelmts, &cd_value, NAME_BUF_SIZE, name, NULL); + filter = H5Pget_filter2(plist, 3, NULL, &cd_nelmts, &cd_value, (size_t)NAME_BUF_SIZE, name, NULL); CHECK_I(filter, "H5Pget_filter2"); VERIFY(filter, H5Z_FILTER_FLETCHER32, "H5Pget_filter2"); @@ -1273,7 +1273,7 @@ static void size2_verify_plist1(hid_t plist) /* Check fill value */ dtype1_id=make_dtype_1(); CHECK_I(dtype1_id, "make_dtype_1"); - memset(&fill1_correct, '1', sizeof(fill1_correct)); + HDmemset(&fill1_correct, '1', sizeof(fill1_correct)); ret = H5Pget_fill_value(plist, dtype1_id, &fill1); CHECK_I(ret, "H5Pget_fill_value"); @@ -1308,48 +1308,49 @@ static void size2_verify_plist2(hid_t plist) /* Hardcoded to correspond to dcpl1_id created in size2_helper */ /* Check filters */ cd_nelmts = 1; - filter = H5Pget_filter2(plist, 0, NULL, &cd_nelmts, &cd_value, NAME_BUF_SIZE, name, NULL); + filter = H5Pget_filter2(plist, 0, NULL, &cd_nelmts, &cd_value, (size_t)NAME_BUF_SIZE, name, NULL); CHECK_I(filter, "H5Pget_filter2"); VERIFY(filter, H5Z_FILTER_DEFLATE, "H5Pget_filter2"); VERIFY(cd_value, 1, "H5Pget_filter2"); cd_nelmts = 1; - filter = H5Pget_filter2(plist, 1, NULL, &cd_nelmts, &cd_value, NAME_BUF_SIZE, name, NULL); + filter = H5Pget_filter2(plist, 1, NULL, &cd_nelmts, &cd_value, (size_t)NAME_BUF_SIZE, name, NULL); CHECK_I(filter, "H5Pget_filter2"); VERIFY(filter, H5Z_FILTER_DEFLATE, "H5Pget_filter2"); VERIFY(cd_value, 2, "H5Pget_filter2"); cd_nelmts = 1; - filter = H5Pget_filter2(plist, 2, NULL, &cd_nelmts, &cd_value, NAME_BUF_SIZE, name, NULL); + filter = H5Pget_filter2(plist, 2, NULL, &cd_nelmts, &cd_value, (size_t)NAME_BUF_SIZE, name, NULL); CHECK_I(filter, "H5Pget_filter2"); VERIFY(filter, H5Z_FILTER_DEFLATE, "H5Pget_filter2"); VERIFY(cd_value, 2, "H5Pget_filter2"); cd_nelmts = 1; - filter = H5Pget_filter2(plist, 3, NULL, &cd_nelmts, &cd_value, NAME_BUF_SIZE, name, NULL); + filter = H5Pget_filter2(plist, 3, NULL, &cd_nelmts, &cd_value, (size_t)NAME_BUF_SIZE, name, NULL); CHECK_I(filter, "H5Pget_filter2"); VERIFY(filter, H5Z_FILTER_DEFLATE, "H5Pget_filter2"); VERIFY(cd_value, 1, "H5Pget_filter2"); cd_nelmts = 1; - filter = H5Pget_filter2(plist, 4, NULL, &cd_nelmts, &cd_value, NAME_BUF_SIZE, name, NULL); + filter = H5Pget_filter2(plist, 4, NULL, &cd_nelmts, &cd_value, (size_t)NAME_BUF_SIZE, name, NULL); CHECK_I(filter, "H5Pget_filter2"); VERIFY(filter, H5Z_FILTER_DEFLATE, "H5Pget_filter2"); VERIFY(cd_value, 5, "H5Pget_filter2"); /* Check fill value */ - dtype2_id=make_dtype_2(); + dtype2_id = make_dtype_2(); CHECK_I(dtype2_id, "make_dtype_2"); - memset(&fill2_correct, '2', DTYPE2_SIZE); + HDmemset(&fill2_correct, '2', (size_t)DTYPE2_SIZE); ret = H5Pget_fill_value(plist, dtype2_id, &fill2); CHECK_I(ret, "H5Pget_fill_value"); - ret = memcmp(&fill2, &fill2_correct, DTYPE2_SIZE); + ret = HDmemcmp(&fill2, &fill2_correct, (size_t)DTYPE2_SIZE); VERIFY(ret, 0, memcmp); } +#ifdef NOT_NOW /*------------------------------------------------------------------------- * Function: size2_dump_struct @@ -1378,6 +1379,7 @@ size2_dump_struct(const char *name, size2_helper_struct *sizes) printf(" attributes: %llu \tdelta: %llu\n", (unsigned long long)sizes->attrs1, (unsigned long long)(sizes->attrs1 - sizes->interleaved)); printf(" attributes 2: %llu \tdelta: %llu\n", (unsigned long long)sizes->attrs2, (unsigned long long)(sizes->attrs2 - sizes->attrs1)); } +#endif /* NOT_NOW */ /*------------------------------------------------------------------------- @@ -1466,7 +1468,7 @@ size2_helper(hid_t fcpl_id, int test_file_closing, size2_helper_struct *ret_size * We'll set them in the DCPL. */ HDmemset(&fill1, '1', sizeof(dtype1_struct)); - HDmemset(&fill2, '2', DTYPE2_SIZE); + HDmemset(&fill2, '2', (size_t)DTYPE2_SIZE); dcpl1_id = H5Pcreate(H5P_DATASET_CREATE); CHECK_I(dcpl1_id, "H5Pcreate"); @@ -1509,8 +1511,8 @@ size2_helper(hid_t fcpl_id, int test_file_closing, size2_helper_struct *ret_size size2_verify_plist2(dcpl2_id); /* Set up attribute data */ - HDmemset(attr_string1, 0, NAME_BUF_SIZE); - HDmemset(attr_string2, 0, NAME_BUF_SIZE); + HDmemset(attr_string1, 0, (size_t)NAME_BUF_SIZE); + HDmemset(attr_string2, 0, (size_t)NAME_BUF_SIZE); HDstrcpy(attr_string1, LONG_STRING); HDstrcpy(attr_string2, LONG_STRING); attr_string2[1] = '1'; /* The second string starts "01 index..." */ @@ -1518,7 +1520,7 @@ size2_helper(hid_t fcpl_id, int test_file_closing, size2_helper_struct *ret_size /* Set up attribute metadata */ attr_type_id = H5Tcopy(H5T_C_S1); CHECK_I(attr_type_id, "H5Tcopy"); - ret = H5Tset_size(attr_type_id ,NAME_BUF_SIZE); + ret = H5Tset_size(attr_type_id, (size_t)NAME_BUF_SIZE); CHECK_I(ret, "H5Tset_size"); attr_space_id = H5Screate_simple(1, dims, dims); CHECK_I(attr_space_id, "H5Screate_simple"); @@ -1669,10 +1671,9 @@ size2_helper(hid_t fcpl_id, int test_file_closing, size2_helper_struct *ret_size group_id = H5Gopen2(file_id, "group", H5P_DEFAULT); CHECK_I(group_id, "H5Gopen2"); - strcpy(attr_name, "00 index"); + HDstrcpy(attr_name, "00 index"); - for(x=0; x<NUM_ATTRIBUTES; ++x) - { + for(x = 0; x < NUM_ATTRIBUTES; ++x) { /* Create a unique name and value for each attribute */ attr_string1[0] = attr_name[0] = (x / 10) + '0'; attr_string1[1] = attr_name[1] = (x % 10) + '0'; @@ -1917,7 +1918,7 @@ static void size2_verify(void) /* Create attribute data type */ attr_type_id = H5Tcopy(H5T_C_S1); CHECK_I(attr_type_id, "H5Tcopy"); - ret = H5Tset_size(attr_type_id ,NAME_BUF_SIZE); + ret = H5Tset_size(attr_type_id, (size_t)NAME_BUF_SIZE); CHECK_I(ret, "H5Tset_size"); /* Read attributes on both groups and verify that they are correct */ @@ -1926,8 +1927,8 @@ static void size2_verify(void) group2_id = H5Gopen2(file_id, "interleaved group", H5P_DEFAULT); CHECK_I(group2_id, "H5Gopen2"); - HDmemset(attr_string, 0, NAME_BUF_SIZE); - HDmemset(attr_correct_string, 0, NAME_BUF_SIZE); + HDmemset(attr_string, 0, (size_t)NAME_BUF_SIZE); + HDmemset(attr_correct_string, 0, (size_t)NAME_BUF_SIZE); HDstrcpy(attr_correct_string, LONG_STRING); HDstrcpy(attr_name, "00 index"); @@ -2785,11 +2786,12 @@ static void test_sohm_delete(void) { hid_t fcpl_id; - /* We'll use dataspaces, filter pipelines, and attributes for this - * test. Create a number of distinct messages of each type. + /* We'll use dataspaces and filter pipelines for this test. + * Create a number of distinct messages of each type. */ hid_t dspace_id[DELETE_NUM_MESGS] = {0}; hid_t dcpl_id[DELETE_NUM_MESGS] = {0}; + unsigned u; int x; hsize_t dims[] = DELETE_DIMS; herr_t ret; @@ -2797,10 +2799,10 @@ test_sohm_delete(void) /* Create a number of different dataspaces. * For simplicity, each dataspace has only one element. */ - for(x=0; x<DELETE_NUM_MESGS; ++x) { - dspace_id[x] = H5Screate_simple(x + 1, dims, dims); - CHECK_I(dspace_id[x], "H5Screate_simple"); - } + for(u = 0; u < DELETE_NUM_MESGS; ++u) { + dspace_id[u] = H5Screate_simple((int)(u + 1), dims, dims); + CHECK_I(dspace_id[u], "H5Screate_simple"); + } /* end for */ /* Create a number of different filter pipelines. */ dcpl_id[0] = H5Pcreate(H5P_DATASET_CREATE); @@ -2811,21 +2813,21 @@ test_sohm_delete(void) ret = H5Pset_shuffle(dcpl_id[0]); CHECK_I(ret, "H5Pset_shuffle"); - for(x=1; x<DELETE_NUM_MESGS; x+=2) { - dcpl_id[x] = H5Pcopy(dcpl_id[x-1]); - CHECK_I(dcpl_id[x], "H5Pcopy"); - ret = H5Pset_chunk(dcpl_id[x], x+1, dims); + for(u = 1; u < DELETE_NUM_MESGS; u += 2) { + dcpl_id[u] = H5Pcopy(dcpl_id[u - 1]); + CHECK_I(dcpl_id[u], "H5Pcopy"); + ret = H5Pset_chunk(dcpl_id[u], (int)(u + 1), dims); CHECK_I(ret, "H5Pset_chunk"); - ret = H5Pset_deflate(dcpl_id[x], 1); + ret = H5Pset_deflate(dcpl_id[u], 1); CHECK_I(ret, "H5Pset_deflate"); - dcpl_id[x+1] = H5Pcopy(dcpl_id[x]); - CHECK_I(dcpl_id[x+1], "H5Pcopy"); - ret = H5Pset_chunk(dcpl_id[x+1], x+2, dims); + dcpl_id[u + 1] = H5Pcopy(dcpl_id[u]); + CHECK_I(dcpl_id[u + 1], "H5Pcopy"); + ret = H5Pset_chunk(dcpl_id[u + 1], (int)(u + 2), dims); CHECK_I(ret, "H5Pset_chunk"); - ret = H5Pset_shuffle(dcpl_id[x+1]); + ret = H5Pset_shuffle(dcpl_id[u + 1]); CHECK_I(ret, "H5Pset_shuffle"); - } + } /* end for */ /* Create an fcpl where all messages are shared in the same index */ fcpl_id = H5Pcreate(H5P_FILE_CREATE); @@ -2889,22 +2891,22 @@ test_sohm_delete(void) */ ret = H5Pset_shared_mesg_nindexes(fcpl_id, 1); CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); - for(x=DELETE_MIN_MESG_SIZE; x<=DELETE_MAX_MESG_SIZE; x += 10) { - ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_ALL_FLAG, (size_t) x); + for(u = DELETE_MIN_MESG_SIZE; u <= DELETE_MAX_MESG_SIZE; u += 10) { + ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_ALL_FLAG, u); CHECK_I(ret, "H5Pset_shared_mesg_phase_change"); delete_helper(fcpl_id, dspace_id, dcpl_id); - } + } /* end for */ /* Cleanup */ ret = H5Pclose(fcpl_id); CHECK_I(ret, "H5Pclose"); - for(x=DELETE_NUM_MESGS - 1; x>=0; --x) { + for(x = DELETE_NUM_MESGS - 1; x >= 0; --x) { ret = H5Sclose(dspace_id[x]); CHECK_I(ret, "H5Sclose"); ret = H5Pclose(dcpl_id[x]); CHECK_I(ret, "H5Pclose"); - } + } /* end for */ } /* end test_sohm_delete() */ |