diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2012-08-08 23:01:20 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2012-08-08 23:01:20 (GMT) |
commit | 88a94bbe7ffa3c0bb7779d1b16989b385d9eadd2 (patch) | |
tree | be52b18015cf8df4af976ab5cfdc912748783b22 | |
parent | 79b2eb993e29cf0382db07b322fa3ca5cb00fc65 (diff) | |
download | hdf5-88a94bbe7ffa3c0bb7779d1b16989b385d9eadd2.zip hdf5-88a94bbe7ffa3c0bb7779d1b16989b385d9eadd2.tar.gz hdf5-88a94bbe7ffa3c0bb7779d1b16989b385d9eadd2.tar.bz2 |
[svn-r22646] Description:
Changes resulting from Klocwork static analysis tool, from Mark Miller
@ LLNL (miller86@llnl.gov).
Tested on:
Mac OS X/64 10.7.4 (amazon) w/debug, C++ & FORTRAN, using gcc 4.7.x
(too minor to require h5committest)
-rw-r--r-- | hl/test/test_image.c | 7 | ||||
-rw-r--r-- | src/H5Dchunk.c | 4 | ||||
-rw-r--r-- | src/H5Doh.c | 2 | ||||
-rw-r--r-- | src/H5Eint.c | 10 | ||||
-rw-r--r-- | src/H5FDcore.c | 10 | ||||
-rw-r--r-- | src/H5FDmpi.c | 19 | ||||
-rw-r--r-- | src/H5HFsection.c | 12 | ||||
-rw-r--r-- | src/H5HG.c | 2 | ||||
-rw-r--r-- | src/H5MF.c | 4 | ||||
-rw-r--r-- | src/H5Ocopy.c | 5 | ||||
-rw-r--r-- | src/H5Otest.c | 2 | ||||
-rw-r--r-- | src/H5Pfapl.c | 47 | ||||
-rw-r--r-- | src/H5Shyper.c | 2 | ||||
-rw-r--r-- | src/H5Spoint.c | 2 | ||||
-rw-r--r-- | src/H5Sselect.c | 2 | ||||
-rw-r--r-- | src/H5Tarray.c | 3 | ||||
-rw-r--r-- | src/H5trace.c | 1 | ||||
-rw-r--r-- | test/accum.c | 18 | ||||
-rw-r--r-- | test/cache.c | 4 | ||||
-rw-r--r-- | test/cache_common.c | 2 | ||||
-rw-r--r-- | test/cache_tagging.c | 8 | ||||
-rw-r--r-- | test/dsets.c | 14 | ||||
-rw-r--r-- | test/dt_arith.c | 6 | ||||
-rw-r--r-- | test/dtypes.c | 35 | ||||
-rw-r--r-- | test/file_image.c | 26 | ||||
-rw-r--r-- | test/freespace.c | 2 | ||||
-rw-r--r-- | test/h5test.c | 4 | ||||
-rw-r--r-- | test/ntypes.c | 1 | ||||
-rw-r--r-- | test/objcopy.c | 2 | ||||
-rw-r--r-- | test/tunicode.c | 2 | ||||
-rw-r--r-- | tools/h5repack/h5repack_copy.c | 2 | ||||
-rw-r--r-- | tools/h5repack/h5repack_opttable.c | 2 | ||||
-rw-r--r-- | tools/misc/talign.c | 15 |
33 files changed, 168 insertions, 109 deletions
diff --git a/hl/test/test_image.c b/hl/test/test_image.c index 3914a9f..4cef1b4 100644 --- a/hl/test/test_image.c +++ b/hl/test/test_image.c @@ -513,6 +513,7 @@ static int test_generate(void) FILE *f; const char *data_file = H5_get_srcdir_filename(DATA_FILE4); int i; + int retval = FAIL; /* create a file using default properties */ if ((fid=H5Fcreate(FILE3,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0) @@ -674,15 +675,17 @@ static int test_generate(void) if (H5Fclose(fid)<0) goto out; - return 0; + /* Indicate success */ + retval = 0; /* error zone, gracefully close */ out: + HDfree(data); H5E_BEGIN_TRY { H5Fclose(fid); } H5E_END_TRY; H5_FAILED(); - return FAIL; + return retval; } diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 93e8869..7a06477 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -3798,7 +3798,9 @@ H5D__chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim) /* * Determine the chunks which need to be filled or removed */ - for(op_dim=0; op_dim<space_ndims; op_dim++) { + HDmemset(min_mod_chunk_off, 0, sizeof(min_mod_chunk_off)); + HDmemset(max_mod_chunk_off, 0, sizeof(max_mod_chunk_off)); + for(op_dim = 0; op_dim < space_ndims; op_dim++) { /* Calculate the largest offset of chunks that might need to be * modified in this dimension */ max_mod_chunk_off[op_dim] = chunk_dim[op_dim] * ((old_dim[op_dim] - 1) diff --git a/src/H5Doh.c b/src/H5Doh.c index 37b0f52..abf76d0 100644 --- a/src/H5Doh.c +++ b/src/H5Doh.c @@ -446,7 +446,7 @@ done: static herr_t H5O__dset_flush(H5G_loc_t *obj_loc, hid_t dxpl_id) { - H5D_t *dset; /* Dataset opened */ + H5D_t *dset = NULL; /* Dataset opened */ H5O_type_t obj_type; /* Type of object at location */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Eint.c b/src/H5Eint.c index 594a69a..76eaaf5 100644 --- a/src/H5Eint.c +++ b/src/H5Eint.c @@ -264,7 +264,10 @@ H5E_walk1_cb(int n, H5E_error1_t *err_desc, void *client_data) if(cls_ptr->lib_vers) eprint->cls.lib_vers = cls_ptr->lib_vers; - fprintf(stream, "%s-DIAG: Error detected in %s (%s) ", cls_ptr->cls_name, cls_ptr->lib_name, cls_ptr->lib_vers); + fprintf(stream, "%s-DIAG: Error detected in %s (%s) ", + (cls_ptr->cls_name ? cls_ptr->cls_name : "(null)"), + (cls_ptr->lib_name ? cls_ptr->lib_name : "(null)"), + (cls_ptr->lib_vers ? cls_ptr->lib_vers : "(null)")); /* try show the process or thread id in multiple processes cases*/ #ifdef H5_HAVE_PARALLEL @@ -387,7 +390,10 @@ H5E_walk2_cb(unsigned n, const H5E_error2_t *err_desc, void *client_data) if(cls_ptr->lib_vers) eprint->cls.lib_vers = cls_ptr->lib_vers; - fprintf(stream, "%s-DIAG: Error detected in %s (%s) ", cls_ptr->cls_name, cls_ptr->lib_name, cls_ptr->lib_vers); + fprintf(stream, "%s-DIAG: Error detected in %s (%s) ", + (cls_ptr->cls_name ? cls_ptr->cls_name : "(null)"), + (cls_ptr->lib_name ? cls_ptr->lib_name : "(null)"), + (cls_ptr->lib_vers ? cls_ptr->lib_vers : "(null)")); /* try show the process or thread id in multiple processes cases*/ #ifdef H5_HAVE_PARALLEL diff --git a/src/H5FDcore.c b/src/H5FDcore.c index 1fef36c..5b73866 100644 --- a/src/H5FDcore.c +++ b/src/H5FDcore.c @@ -427,8 +427,9 @@ H5FD_core_open(const char *name, unsigned flags, hid_t fapl_id, HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "maxaddr overflow") HDassert(H5P_DEFAULT != fapl_id); if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") - fa = (H5FD_core_fapl_t *)H5P_get_driver_info(plist); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") + if(NULL == (fa = (H5FD_core_fapl_t *)H5P_get_driver_info(plist))) + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info") /* Build the open flags */ o_flags = (H5F_ACC_RDWR & flags) ? O_RDWR : O_RDONLY; @@ -443,6 +444,7 @@ H5FD_core_open(const char *name, unsigned flags, hid_t fapl_id, /* If the file image exists and this is an open, make sure the file doesn't exist */ HDassert(((file_image_info.buffer != NULL) && (file_image_info.size > 0)) || ((file_image_info.buffer == NULL) && (file_image_info.size == 0))); + HDmemset(&sb, 0, sizeof(sb)); if((file_image_info.buffer != NULL) && !(H5F_ACC_CREAT & flags)) { if(HDopen(name, o_flags, 0666) >= 0) HGOTO_ERROR(H5E_FILE, H5E_FILEEXISTS, NULL, "file already exists") @@ -462,7 +464,7 @@ H5FD_core_open(const char *name, unsigned flags, hid_t fapl_id, * store is off is when the backing_store flag is off and H5F_ACC_CREAT is * on. */ else if(fa->backing_store || !(H5F_ACC_CREAT & flags)) { - if(fa && (fd = HDopen(name, o_flags, 0666)) < 0) + if((fd = HDopen(name, o_flags, 0666)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file") if(HDfstat(fd, &sb) < 0) HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, NULL, "unable to fstat file") @@ -479,7 +481,7 @@ H5FD_core_open(const char *name, unsigned flags, hid_t fapl_id, * default value. But if the file access property list was zero then use * the default value instead. */ - file->increment = (fa && fa->increment>0) ? fa->increment : H5FD_CORE_INCREMENT; + file->increment = (fa->increment>0) ? fa->increment : H5FD_CORE_INCREMENT; /* If save data in backing store. */ file->backing_store = fa->backing_store; diff --git a/src/H5FDmpi.c b/src/H5FDmpi.c index 01c28e6..866a2cf 100644 --- a/src/H5FDmpi.c +++ b/src/H5FDmpi.c @@ -56,12 +56,15 @@ char H5FD_mpi_native_g[] = "native"; int H5FD_mpi_get_rank(const H5FD_t *file) { - const H5FD_class_mpi_t *cls=(const H5FD_class_mpi_t *)(file->cls); + const H5FD_class_mpi_t *cls; + int ret_value; FUNC_ENTER_NOAPI(FAIL) - assert(file && cls); + assert(file); + cls = (const H5FD_class_mpi_t *)(file->cls); + assert(cls); assert(cls->get_rank); /* All MPI drivers must implement this */ /* Dispatch to driver */ @@ -92,12 +95,14 @@ done: int H5FD_mpi_get_size(const H5FD_t *file) { - const H5FD_class_mpi_t *cls=(const H5FD_class_mpi_t *)(file->cls); + const H5FD_class_mpi_t *cls; int ret_value; FUNC_ENTER_NOAPI(FAIL) - assert(file && cls); + assert(file); + cls = (const H5FD_class_mpi_t *)(file->cls); + assert(cls); assert(cls->get_size); /* All MPI drivers must implement this */ /* Dispatch to driver */ @@ -128,12 +133,14 @@ done: MPI_Comm H5FD_mpi_get_comm(const H5FD_t *file) { - const H5FD_class_mpi_t *cls=(const H5FD_class_mpi_t *)(file->cls); + const H5FD_class_mpi_t *cls; MPI_Comm ret_value; FUNC_ENTER_NOAPI(MPI_COMM_NULL) - assert(file && cls); + assert(file); + cls = (const H5FD_class_mpi_t *)(file->cls); + assert(cls); assert(cls->get_comm); /* All MPI drivers must implement this */ /* Dispatch to driver */ diff --git a/src/H5HFsection.c b/src/H5HFsection.c index e9ea7e0..72ea100 100644 --- a/src/H5HFsection.c +++ b/src/H5HFsection.c @@ -2398,7 +2398,10 @@ H5HF_sect_indirect_init_rows(H5HF_hdr_t *hdr, hid_t dxpl_id, HDassert(sect->u.indirect.span_size > 0); /* Reset reference count for indirect section */ + /* (Also reset the direct & indirect row pointers */ sect->u.indirect.rc = 0; + sect->u.indirect.dir_rows = NULL; + sect->u.indirect.indir_ents = NULL; /* Set up direct block information, if necessary */ if(start_row < hdr->man_dtable.max_direct_rows) { @@ -2424,7 +2427,6 @@ H5HF_sect_indirect_init_rows(H5HF_hdr_t *hdr, hid_t dxpl_id, /* No rows of direct blocks covered, reset direct row information */ dir_nrows = 0; sect->u.indirect.dir_nrows = 0; - sect->u.indirect.dir_rows = NULL; } /* end else */ /* Set up indirect block information, if necessary */ @@ -2459,7 +2461,6 @@ H5HF_sect_indirect_init_rows(H5HF_hdr_t *hdr, hid_t dxpl_id, else { /* No indirect block entries covered, reset indirect row information */ sect->u.indirect.indir_nents = 0; - sect->u.indirect.indir_ents = NULL; } /* end else */ /* Set up initial row information */ @@ -2598,6 +2599,13 @@ H5HF_sect_indirect_init_rows(H5HF_hdr_t *hdr, hid_t dxpl_id, (sect->u.indirect.indir_nents + sect->u.indirect.dir_nrows)); done: + if(ret_value < 0) { + if(sect->u.indirect.indir_ents) + H5MM_xfree(sect->u.indirect.indir_ents); + if(sect->u.indirect.dir_rows) + H5MM_xfree(sect->u.indirect.dir_rows); + } /* end if */ + FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_sect_indirect_init_rows() */ @@ -136,7 +136,7 @@ H5HG_create(H5F_t *f, hid_t dxpl_id, size_t size) { H5HG_heap_t *heap = NULL; uint8_t *p = NULL; - haddr_t addr; + haddr_t addr = HADDR_UNDEF; size_t n; haddr_t ret_value = HADDR_UNDEF; /* Return value */ @@ -245,6 +245,7 @@ H5MF_alloc_open(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type) */ HDassert(f); HDassert(f->shared); + HDassert(type != H5FD_MEM_NOLIST); HDassert(H5F_addr_defined(f->shared->fs_addr[type])); HDassert(f->shared->fs_state[type] == H5F_FS_STATE_CLOSED); @@ -292,6 +293,7 @@ H5MF_alloc_create(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type) */ HDassert(f); HDassert(f->shared); + HDassert(type != H5FD_MEM_NOLIST); HDassert(!H5F_addr_defined(f->shared->fs_addr[type])); HDassert(f->shared->fs_state[type] == H5F_FS_STATE_CLOSED); @@ -342,6 +344,7 @@ H5MF_alloc_start(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type) */ HDassert(f); HDassert(f->shared); + HDassert(type != H5FD_MEM_NOLIST); /* Check if the free space manager exists already */ if(H5F_addr_defined(f->shared->fs_addr[type])) { @@ -384,6 +387,7 @@ H5MF_alloc_close(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type) */ HDassert(f); HDassert(f->shared); + HDassert(type != H5FD_MEM_NOLIST); HDassert(f->shared->fs_man[type]); HDassert(f->shared->fs_state[type] != H5F_FS_STATE_CLOSED); diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c index 1d1aa90..ceb6563 100644 --- a/src/H5Ocopy.c +++ b/src/H5Ocopy.c @@ -1066,11 +1066,15 @@ H5O_copy_header(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */, FUNC_ENTER_NOAPI_NOINIT + /* Sanity check */ HDassert(oloc_src); HDassert(oloc_src->file); HDassert(H5F_addr_defined(oloc_src->addr)); HDassert(oloc_dst->file); + /* Intialize copy info before errors can be thrown */ + HDmemset(&cpy_info, 0, sizeof(H5O_copy_t)); + /* Get the copy property list */ if(NULL == (ocpy_plist = (H5P_genplist_t *)H5I_object(ocpypl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") @@ -1088,7 +1092,6 @@ H5O_copy_header(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */, HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get callback info") /* Convert copy flags into copy struct */ - HDmemset(&cpy_info, 0, sizeof(H5O_copy_t)); if((cpy_option & H5O_COPY_SHALLOW_HIERARCHY_FLAG) > 0) { cpy_info.copy_shallow = TRUE; cpy_info.max_depth = 1; diff --git a/src/H5Otest.c b/src/H5Otest.c index 705f716..d1627ef 100644 --- a/src/H5Otest.c +++ b/src/H5Otest.c @@ -516,7 +516,7 @@ H5O_expunge_chunks_test(const H5O_loc_t *loc, hid_t dxpl_id) /* Safety check */ nchunks = oh->nchunks; - HDassert(nchunks < NELMTS(chk_addr)); + HDassert(0 < nchunks && nchunks < NELMTS(chk_addr)); /* Iterate over all the chunks, saving the chunk addresses */ for(u = 0; u < oh->nchunks; u++) diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index f2af61b..9b5d1b0 100644 --- a/src/H5Pfapl.c +++ b/src/H5Pfapl.c @@ -2494,12 +2494,13 @@ done: herr_t H5P_file_image_info_copy(const char UNUSED *name, size_t UNUSED size, void *value) { - H5FD_file_image_info_t *info; /* Image info struct */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT if(value) { + H5FD_file_image_info_t *info; /* Image info struct */ + info = (H5FD_file_image_info_t *)value; /* verify file image field consistancy */ @@ -2533,16 +2534,17 @@ H5P_file_image_info_copy(const char UNUSED *name, size_t UNUSED size, void *valu else HDmemcpy(info->buffer, old_buffer, info->size); } /* end if */ - } /* end if */ - /* Copy udata if it exists */ - if(info->callbacks.udata) { - void *old_udata = info->callbacks.udata; + /* Copy udata if it exists */ + if(info->callbacks.udata) { + void *old_udata = info->callbacks.udata; + + if(NULL == info->callbacks.udata_copy) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "udata_copy not defined") - if(NULL == info->callbacks.udata_copy) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "udata_copy not defined") + info->callbacks.udata = info->callbacks.udata_copy(old_udata); + } /* end if */ - info->callbacks.udata = info->callbacks.udata_copy(old_udata); } /* end if */ done: @@ -2567,32 +2569,33 @@ done: herr_t H5P_file_image_info_close(const char UNUSED *name, size_t UNUSED size, void *value) { - H5FD_file_image_info_t info; /* Image info struct */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT if(value) { - info = *(H5FD_file_image_info_t *)value; + H5FD_file_image_info_t *info; /* Image info struct */ + + info = (H5FD_file_image_info_t *)value; - if(info.buffer != NULL && info.size > 0) { + if(info->buffer != NULL && info->size > 0) { /* Free buffer */ - if(info.callbacks.image_free) { - if(info.callbacks.image_free(info.buffer, H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE, - info.callbacks.udata) < 0) + if(info->callbacks.image_free) { + if(info->callbacks.image_free(info->buffer, H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE, + info->callbacks.udata) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "image_free callback failed") } /* end if */ else - H5MM_xfree(info.buffer); + H5MM_xfree(info->buffer); } /* end if */ - } /* end if */ - /* Free udata if it exists */ - if(info.callbacks.udata) { - if(NULL == info.callbacks.udata_free) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "udata_free not defined") - if(info.callbacks.udata_free(info.callbacks.udata) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "udata_free callback failed") + /* Free udata if it exists */ + if(info->callbacks.udata) { + if(NULL == info->callbacks.udata_free) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "udata_free not defined") + if(info->callbacks.udata_free(info->callbacks.udata) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "udata_free callback failed") + } /* end if */ } /* end if */ done: diff --git a/src/H5Shyper.c b/src/H5Shyper.c index d9b306d..d88ac35 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -2784,7 +2784,7 @@ H5S_hyper_offset(const H5S_t *space, hsize_t *offset) FUNC_ENTER_NOAPI(FAIL) - HDassert(space); + HDassert(space && space->extent.rank>0); HDassert(offset); /* Start at linear offset 0 */ diff --git a/src/H5Spoint.c b/src/H5Spoint.c index 817b2f2..b758a92 100644 --- a/src/H5Spoint.c +++ b/src/H5Spoint.c @@ -643,7 +643,7 @@ H5S_point_copy(H5S_t *dst, const H5S_t *src, hbool_t UNUSED share_selection) } /* end while */ done: - if(ret_value < 0) { + if(ret_value < 0 && dst->select.sel_info.pnt_lst) { /* Traverse the (incomplete?) dst list, freeing all memory */ curr = dst->select.sel_info.pnt_lst->head; while(curr) { diff --git a/src/H5Sselect.c b/src/H5Sselect.c index 91aed1e..9a993a5 100644 --- a/src/H5Sselect.c +++ b/src/H5Sselect.c @@ -67,7 +67,7 @@ H5S_select_offset(H5S_t *space, const hssize_t *offset) /* Check args */ HDassert(space); - HDassert(space->extent.rank); + HDassert(0 < space->extent.rank && space->extent.rank <= H5S_MAX_RANK); HDassert(offset); /* Copy the offset over */ diff --git a/src/H5Tarray.c b/src/H5Tarray.c index 9986631..c73b934 100644 --- a/src/H5Tarray.c +++ b/src/H5Tarray.c @@ -194,7 +194,8 @@ H5T__array_create(H5T_t *base, unsigned ndims, const hsize_t dim[/* ndims */]) ret_value->shared->type = H5T_ARRAY; /* Copy the base type of the array */ - ret_value->shared->parent = H5T_copy(base, H5T_COPY_ALL); + if(NULL == (ret_value->shared->parent = H5T_copy(base, H5T_COPY_ALL))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "unable to copy base datatype") /* Set the array parameters */ ret_value->shared->u.array.ndims = ndims; diff --git a/src/H5trace.c b/src/H5trace.c index b711f40..b559669 100644 --- a/src/H5trace.c +++ b/src/H5trace.c @@ -212,6 +212,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) if('[' == *type) { if('a' == type[1]) { asize_idx = (int)HDstrtol(type + 2, &rest, 10); + HDassert(0 <= asize_idx && asize_idx < (int) NELMTS(asize)); HDassert(']'==*rest); type = rest + 1; } else { diff --git a/test/accum.c b/test/accum.c index c5f6610..e4c1bd8 100644 --- a/test/accum.c +++ b/test/accum.c @@ -1793,15 +1793,17 @@ accum_printf(void) printf("=====================================================\n"); } else { printf("=====================================================\n"); - printf(" accumulator allocated size == %lu\n", (unsigned long)accum->alloc_size); - printf(" accumulated data size == %lu\n", (unsigned long)accum->size); - printf(" accumulator dirty? == %d\n", accum->dirty); + printf(" accumulator allocated size == %zu\n", accum->alloc_size); + printf(" accumulated data size == %zu\n", accum->size); + HDfprintf(stdout, " accumulator dirty? == %t\n", accum->dirty); printf("=====================================================\n"); - printf(" start of accumulated data, loc = %llu\n", accum->loc); - if (accum->dirty) printf(" start of dirty region, loc = %llu\n", accum->loc + accum->dirty_off); - if (accum->dirty) printf(" end of dirty region, loc = %llu\n", accum->loc + accum->dirty_off + accum->dirty_len); - printf(" end of accumulated data, loc = %llu\n", accum->loc + accum->size); - printf(" end of accumulator allocation, loc = %llu\n", accum->loc + accum->alloc_size); + HDfprintf(stdout, " start of accumulated data, loc = %a\n", accum->loc); + if(accum->dirty) { + HDfprintf(stdout, " start of dirty region, loc = %a\n", (haddr_t)(accum->loc + accum->dirty_off)); + HDfprintf(stdout, " end of dirty region, loc = %a\n", (haddr_t)(accum->loc + accum->dirty_off + accum->dirty_len)); + } /* end if */ + HDfprintf(stdout, " end of accumulated data, loc = %a\n", (haddr_t)(accum->loc + accum->size)); + HDfprintf(stdout, " end of accumulator allocation, loc = %a\n", (haddr_t)(accum->loc + accum->alloc_size)); printf("=====================================================\n"); } printf("\n\n"); diff --git a/test/cache.c b/test/cache.c index 0e6cb42..ba51a38 100644 --- a/test/cache.c +++ b/test/cache.c @@ -33532,6 +33532,7 @@ check_notify_cb(void) reset_entries(); file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024)); + if ( !file_ptr ) CACHE_ERROR("setup_cache returned NULL") cache_ptr = file_ptr->shared->cache; base_addr = entries[entry_type]; @@ -33675,8 +33676,7 @@ check_notify_cb(void) } /* end for */ done: - if(file_ptr) - takedown_cache(file_ptr, FALSE, FALSE); + takedown_cache(file_ptr, FALSE, FALSE); if ( pass ) PASSED() diff --git a/test/cache_common.c b/test/cache_common.c index e6dd020..7b26714 100644 --- a/test/cache_common.c +++ b/test/cache_common.c @@ -2031,7 +2031,7 @@ verify_entry_status(H5C_t * cache_ptr, int num_entries, struct expected_entry_status expected[]) { - static char msg[128]; + static char msg[256]; int i; i = 0; diff --git a/test/cache_tagging.c b/test/cache_tagging.c index 9aef651..5eb1e84 100644 --- a/test/cache_tagging.c +++ b/test/cache_tagging.c @@ -740,7 +740,7 @@ check_group_creation_tags(hid_t fcpl, int type) hid_t fid = -1; /* File Identifier */ hid_t gid = -1; /* Group Identifier */ int verbose = FALSE; /* verbose file outout */ - haddr_t root_tag; /* Root Group Tag */ + haddr_t root_tag = HADDR_UNDEF; /* Root Group Tag */ haddr_t g_tag; /* Group Tag */ haddr_t sbe_tag; /* Sblock Extension Tag */ @@ -1249,7 +1249,7 @@ check_group_open_tags(hid_t fcpl, int type) hid_t fid = -1; /* File Identifier */ hid_t gid = -1; /* Group Identifier */ int verbose = FALSE; /* verbose file output */ - haddr_t root_tag; + haddr_t root_tag = HADDR_UNDEF; haddr_t sbe_tag; haddr_t g_tag; @@ -3056,7 +3056,7 @@ check_object_info_tags(hid_t fcpl, int type) hid_t fid = -1; /* File Identifier */ hid_t gid = -1; /* Group Identifier */ int verbose = FALSE; /* verbose file output */ - haddr_t root_tag; + haddr_t root_tag = HADDR_UNDEF; haddr_t sbe_tag; haddr_t g_tag; H5O_info_t oinfo; /* Object info struct */ @@ -3170,7 +3170,7 @@ check_object_copy_tags(hid_t fcpl, int type) hid_t fid = -1; /* File Identifier */ hid_t gid = -1; /* Group Identifier */ int verbose = FALSE; /* verbose file output */ - haddr_t root_tag; + haddr_t root_tag = HADDR_UNDEF; haddr_t sbe_tag; haddr_t g_tag; haddr_t copy_tag; diff --git a/test/dsets.c b/test/dsets.c index ee341c9..3b081da 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -999,8 +999,8 @@ test_conv_buffer(hid_t fid) herr_t status = -1; int j, k, l; - CmpField *cf; - CmpFieldR *cfrR; + CmpField *cf = NULL; + CmpFieldR *cfrR = NULL; hid_t dataset = -1; /* dataset ID */ hid_t space = -1; /* data space ID */ @@ -1014,7 +1014,7 @@ test_conv_buffer(hid_t fid) TESTING("data type conversion buffer size"); - cf = (CmpField *)HDcalloc((size_t)1, sizeof(CmpField)); + if ((cf = (CmpField *)HDcalloc((size_t)1, sizeof(CmpField))) == 0) goto error; /* Populate the data members */ for(j = 0; j < DIM1; j++) @@ -1063,7 +1063,7 @@ test_conv_buffer(hid_t fid) if(H5Tinsert(ctype2, "C", HOFFSET(CmpFieldR, c), arr_type5) < 0) goto error; /* Read should succeed since library will set conversion buffer big enough */ - cfrR = (CmpFieldR *)HDcalloc((size_t)1, sizeof(CmpFieldR)); + if ((cfrR = (CmpFieldR *)HDcalloc((size_t)1, sizeof(CmpFieldR))) == 0) goto error; if(H5Dread(dataset, ctype2, H5S_ALL, H5S_ALL, H5P_DEFAULT, cfrR) < 0) goto error; /* Read should fail since conversion buffer isn't big enough */ @@ -1100,10 +1100,8 @@ test_conv_buffer(hid_t fid) if(H5Tclose(arr_type5) < 0) goto error; if(H5Dclose(dataset) < 0) goto error; - if(cf) - HDfree(cf); - if(cfrR) - HDfree(cfrR); + HDfree(cf); + HDfree(cfrR); puts(" PASSED"); return(0); diff --git a/test/dt_arith.c b/test/dt_arith.c index 0001755..096b83e 100644 --- a/test/dt_arith.c +++ b/test/dt_arith.c @@ -1105,9 +1105,9 @@ test_derived_flt(void) } fails_this_test = 0; - if(buf) free(buf); - if(saved_buf) free(saved_buf); - if(aligned) free(aligned); + free(buf); + free(saved_buf); + free(aligned); buf = NULL; saved_buf = NULL; aligned = NULL; diff --git a/test/dtypes.c b/test/dtypes.c index 3db9bf8..117a21a 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -1127,10 +1127,8 @@ test_compound_5(void) } /* Free memory buffers */ - if(buf) - HDfree(buf); - if(bkg) - HDfree(bkg); + HDfree(buf); + HDfree(bkg); return retval; } @@ -4698,11 +4696,12 @@ test_bitfield_funcs(void) { hid_t type=-1, ntype=-1, super=-1; int size; - char* tag; + char* tag=0; H5T_pad_t inpad; H5T_cset_t cset; H5T_str_t strpad; herr_t ret; + int retval=-1; TESTING("some type functions for bitfield"); @@ -4786,16 +4785,18 @@ test_bitfield_funcs(void) goto error; } /* end if */ - H5Tclose(type); - H5Tclose(ntype); - PASSED(); - reset_hdf5(); - return 0; + retval = 0; error: + + if (retval == -1) retval = 1; + + HDfree(tag); + H5Tclose(ntype); H5Tclose(type); + if (retval == 0) PASSED(); reset_hdf5(); - return 1; + return retval; } @@ -7049,11 +7050,13 @@ error: */ int test_utf_ascii_conv(void) { - hid_t fid; - hid_t did; - hid_t utf8_vtid, ascii_vtid; - hid_t utf8_tid, ascii_tid; - hid_t sid; + hid_t fid = -1; + hid_t did = -1; + hid_t utf8_vtid = -1; + hid_t ascii_vtid = -1; + hid_t utf8_tid = -1; + hid_t ascii_tid = -1; + hid_t sid = -1; const char *utf8_w = "foo!"; char *ascii_r = NULL; const char *ascii_w = "bar!"; diff --git a/test/file_image.c b/test/file_image.c index 73c901e..9d7a48c 100644 --- a/test/file_image.c +++ b/test/file_image.c @@ -86,15 +86,16 @@ typedef struct { static int test_properties(void) { - hid_t fapl_1; - hid_t fapl_2; - char *buffer; + hid_t fapl_1 = -1; + hid_t fapl_2 = -1; + char *buffer = 0; int count = 10; - void *temp; - char *temp2; + void *temp = 0; + char *temp2 = 0; int i; size_t size; size_t temp_size; + int retval = 1; TESTING("File image property list functions"); @@ -145,18 +146,21 @@ test_properties(void) VERIFY(temp2 != temp, "Retrieved buffer is the same as previously retrieved buffer"); VERIFY(0 == HDmemcmp(temp2, buffer, size),"Buffers contain different data"); + retval = 0; + +error: + /* Close everything */ - if(H5Pclose(fapl_1) < 0) FAIL_STACK_ERROR - if(H5Pclose(fapl_2) < 0) FAIL_STACK_ERROR + if(H5Pclose(fapl_1) < 0) retval = 1; + if(H5Pclose(fapl_2) < 0) retval = 1; HDfree(buffer); HDfree(temp); HDfree(temp2); - PASSED(); - return 0; + if(retval == 0) + PASSED(); -error: - return 1; + return retval; } /* end test_properties() */ /****************************************************************************** diff --git a/test/freespace.c b/test/freespace.c index 6960e6d..c0df4c8 100644 --- a/test/freespace.c +++ b/test/freespace.c @@ -1522,8 +1522,10 @@ test_fs_sect_merge(hid_t fapl) /* Free the section node(s) */ if(TEST_sect_free((H5FS_section_info_t *)sect_node1) < 0) TEST_ERROR + sect_node1 = NULL; if(TEST_sect_free((H5FS_section_info_t *)sect_node2) < 0) TEST_ERROR + sect_node2 = NULL; /* Close the free space manager */ if(H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp) < 0) diff --git a/test/h5test.c b/test/h5test.c index 7faba81..ea30fad 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -735,6 +735,8 @@ h5_set_info_object(void) valp = envp = next = HDstrdup(envp); + if (!valp) return 0; + /* create an INFO object if not created yet */ if (h5_io_info_g == MPI_INFO_NULL) MPI_Info_create(&h5_io_info_g); @@ -761,6 +763,8 @@ h5_set_info_object(void) while (*namep && (*namep == ' ' || *namep == '\t')) namep++; + if (!*namep) continue; /* was all white space, so move to next k/v pair */ + /* eat up any ending white spaces */ endp = &namep[strlen(namep) - 1]; diff --git a/test/ntypes.c b/test/ntypes.c index 165d21b..0af3a3f 100644 --- a/test/ntypes.c +++ b/test/ntypes.c @@ -1776,6 +1776,7 @@ test_vl_dtype(hid_t file) } /* end for */ HDfree(tmp); + tmp = NULL; } /* end for */ } /* end for */ diff --git a/test/objcopy.c b/test/objcopy.c index 6b56b66..d7da8f3 100644 --- a/test/objcopy.c +++ b/test/objcopy.c @@ -10343,7 +10343,7 @@ test_copy_cdt_merge_all_suggs(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t did = -1; /* Dataset ID */ hid_t exp_did = -1; /* Dataset ID */ hid_t tid_short = -1; /* Datatype ID */ - hid_t exp_tid; /* Expected datatype ID */ + hid_t exp_tid = -1; /* Expected datatype ID */ hid_t ocpypl_id = -1; /* Object copy plist ID */ unsigned int i; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ diff --git a/test/tunicode.c b/test/tunicode.c index 3b949e9..0386352 100644 --- a/test/tunicode.c +++ b/test/tunicode.c @@ -161,6 +161,7 @@ void test_strpad(hid_t UNUSED fid, const char *string) /* Create a src_type that holds the UTF-8 string and its final NULL */ big_len = length + 1; /* +1 byte for final NULL */ + HDassert((2*big_len)<=sizeof(cmpbuf)); src_type = mkstr(big_len, H5T_STR_NULLTERM); CHECK(src_type, FAIL, "mkstr"); /* Create a dst_type that holds half of the UTF-8 string and a final @@ -224,6 +225,7 @@ void test_strpad(hid_t UNUSED fid, const char *string) /* Create a src_type that holds the UTF-8 string */ big_len = length; + HDassert((2*big_len)<=sizeof(cmpbuf)); src_type = mkstr(big_len, H5T_STR_NULLPAD); CHECK(src_type, FAIL, "mkstr"); /* Create a dst_type that holds half of the UTF-8 string */ diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c index 957d3c8..cf55d7f 100644 --- a/tools/h5repack/h5repack_copy.c +++ b/tools/h5repack/h5repack_copy.c @@ -1541,7 +1541,7 @@ static void print_dataset_info(hid_t dcpl_id, printf(FORMAT_OBJ,"dset",objname ); else { - char str[255], temp[20]; + char str[255], temp[28]; HDstrcpy(str,"dset "); HDstrcat(str,strfilter); sprintf(temp," (%.3f:1)",ratio); diff --git a/tools/h5repack/h5repack_opttable.c b/tools/h5repack/h5repack_opttable.c index 4ec7fcf..00e4bea 100644 --- a/tools/h5repack/h5repack_opttable.c +++ b/tools/h5repack/h5repack_opttable.c @@ -388,7 +388,7 @@ pack_info_t* options_get_object( const char *path, pack_opttbl_t *table ) { unsigned int i; - const char tbl_path[MAX_NC_NAME]; + const char tbl_path[MAX_NC_NAME+1]; /* +1 for start with "/" case */ for ( i = 0; i < table->nelems; i++) diff --git a/tools/misc/talign.c b/tools/misc/talign.c index 88ebaa6..b77d846 100644 --- a/tools/misc/talign.c +++ b/tools/misc/talign.c @@ -148,28 +148,31 @@ out: result = 1; mname = H5Tget_member_name(fix, 0); printf("%14s (%2d) %6s = %s\n", - mname, (int)H5Tget_member_offset(fix,0), + mname ? mname : "(null)", (int)H5Tget_member_offset(fix,0), string5, (char *)(data + H5Tget_member_offset(fix, 0))); - free(mname); + if(mname) + free(mname); fptr = (float *)(data + H5Tget_member_offset(fix, 1)); mname = H5Tget_member_name(fix, 1); printf("Data comparison:\n" "%14s (%2d) %6f = %f\n" " %6f = %f\n", - mname, (int)H5Tget_member_offset(fix,1), + mname ? mname : "(null)", (int)H5Tget_member_offset(fix,1), fok[0], fptr[0], fok[1], fptr[1]); - free(mname); + if(mname) + free(mname); fptr = (float *)(data + H5Tget_member_offset(fix, 2)); mname = H5Tget_member_name(fix, 2); printf("%14s (%2d) %6f = %f\n" " %6f = %6f\n", - mname, (int)H5Tget_member_offset(fix,2), + mname ? mname : "(null)", (int)H5Tget_member_offset(fix,2), fnok[0], fptr[0], fnok[1], fptr[1]); - free(mname); + if(mname) + free(mname); fptr = (float *)(data + H5Tget_member_offset(fix, 1)); printf("\n" |