summaryrefslogtreecommitdiffstats
path: root/tools/h5repack
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-12-10 13:58:14 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-12-10 13:58:14 (GMT)
commit57ac6e674527a2b5b6d77f7a06b9dad2c572ef1b (patch)
tree380ac2bbfb34b1c1444f5a59c48acdf09996bc87 /tools/h5repack
parent892050a830bd87e32b9a64e388654bc1a9af4cf1 (diff)
downloadhdf5-57ac6e674527a2b5b6d77f7a06b9dad2c572ef1b.zip
hdf5-57ac6e674527a2b5b6d77f7a06b9dad2c572ef1b.tar.gz
hdf5-57ac6e674527a2b5b6d77f7a06b9dad2c572ef1b.tar.bz2
[svn-r17982] Description:
Bring r17980 from trunk to 1.8 branch: Bring Coverity changes into the trunk: (also other minor cleanups) r17955: Fix Coverity item 24. Add missing error condition to H5AC_ext_config_2_int_config. r17956: Fix Coverity item 24. Improve error checking in H5A_compact_build_table_cb. r17957: Fix Coverity item 150. Fix warning in H5A_compact_build_table_cb. r17958: Fix Coverity item 117. Fix error handling in H5B_shared_new. r17959: Fix Coverity item 209. Added an assertion for leaf->shared in H5B2_cache_leaf_dest. r17960: Fix Coverity item 208. Added an assertion for internal->shared in H5B2_cache_internal_dest. r17961: Fix Coverity item 89. Reworked the code to avoid array overrun in H5C__autoadjust__ageout__insert_new_marker. r17962: Fix for coverity Resource_leak 195,203,204,205. r17963: Fix Coverity item 44. Prevented potential NULL dereference in H5D_btree_debug. r17964: Fix Coverity issues #197, 198 & 199: memory not being released. (Also clean up other resource leaks in nearby and/or similar code). r17965: Fix Coverity issue #151: release resources on error r17966: Fix Coverity issue #187: Remove leftover code remnant from prior bugfix which was causing resource leak of open files. r17967: Fixed Coverity issues # 193 & 194. Removed unnecessary memory allocation and added comparison of length of path parameter to the size of the destination buffer in h5import.h/h5import.c. r17968: Fix Coverity item 144. Fixed memory leak on error in H5D_chunk_copy. r17969: Fix for coverity Resource_leak #196. r17970: Coverity 167-173: Initialized pointer of buffers. In error handling, closed types and free memory. Tested on: FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode (h5committested on trunk)
Diffstat (limited to 'tools/h5repack')
-rw-r--r--tools/h5repack/h5repack.c22
-rw-r--r--tools/h5repack/h5repack_opttable.c18
-rw-r--r--tools/h5repack/h5repacktst.c16
3 files changed, 27 insertions, 29 deletions
diff --git a/tools/h5repack/h5repack.c b/tools/h5repack/h5repack.c
index 3c8cec8..6b10e2c 100644
--- a/tools/h5repack/h5repack.c
+++ b/tools/h5repack/h5repack.c
@@ -109,6 +109,7 @@ int h5repack_init (pack_opt_t *options,
return (options_table_init(&(options->op_tbl)));
}
+
/*-------------------------------------------------------------------------
* Function: h5repack_end
*
@@ -122,6 +123,7 @@ int h5repack_end (pack_opt_t *options)
return options_table_free(options->op_tbl);
}
+
/*-------------------------------------------------------------------------
* Function: h5repack_addfilter
*
@@ -132,7 +134,6 @@ int h5repack_end (pack_opt_t *options)
*
*-------------------------------------------------------------------------
*/
-
int h5repack_addfilter(const char* str,
pack_opt_t *options)
{
@@ -144,38 +145,33 @@ int h5repack_addfilter(const char* str,
/* parse the -f option */
- obj_list=parse_filter(str,&n_objs,&filter,options,&is_glb);
- if (obj_list==NULL)
- {
+ if(NULL == (obj_list = parse_filter(str, &n_objs, &filter, options, &is_glb)))
return -1;
- }
/* if it applies to all objects */
- if (is_glb)
+ if(is_glb)
{
-
int n;
n = options->n_filter_g++; /* increase # of global filters */
- if (options->n_filter_g > H5_REPACK_MAX_NFILTERS)
+ if(options->n_filter_g > H5_REPACK_MAX_NFILTERS)
{
- error_msg(progname, "maximum number of filters exceeded for <%s>\n",str);
+ error_msg(progname, "maximum number of filters exceeded for <%s>\n", str);
+ free(obj_list);
return -1;
-
}
options->filter_g[n] = filter;
}
-
else
- options_add_filter(obj_list,n_objs,filter,options->op_tbl);
+ options_add_filter(obj_list, n_objs, filter, options->op_tbl);
free(obj_list);
return 0;
}
-
+
/*-------------------------------------------------------------------------
* Function: h5repack_addlayout
*
diff --git a/tools/h5repack/h5repack_opttable.c b/tools/h5repack/h5repack_opttable.c
index 5b6d5d0..7c87359 100644
--- a/tools/h5repack/h5repack_opttable.c
+++ b/tools/h5repack/h5repack_opttable.c
@@ -136,6 +136,7 @@ static int aux_inctable(pack_opttbl_t *table, int n_objs )
return 0;
}
+
/*-------------------------------------------------------------------------
* Function: options_table_init
*
@@ -145,33 +146,34 @@ static int aux_inctable(pack_opttbl_t *table, int n_objs )
*
*-------------------------------------------------------------------------
*/
-
int options_table_init( pack_opttbl_t **tbl )
{
unsigned int i;
- pack_opttbl_t* table = (pack_opttbl_t*) malloc(sizeof(pack_opttbl_t));
- if (table==NULL) {
+ pack_opttbl_t *table;
+
+ if(NULL == (table = (pack_opttbl_t *)malloc(sizeof(pack_opttbl_t))))
+ {
error_msg(progname, "not enough memory for options table\n");
return -1;
}
table->size = 30;
table->nelems = 0;
- table->objs = (pack_info_t*) malloc(table->size * sizeof(pack_info_t));
- if (table->objs==NULL) {
+ if(NULL == (table->objs = (pack_info_t*)malloc(table->size * sizeof(pack_info_t))))
+ {
error_msg(progname, "not enough memory for options table\n");
+ free(table);
return -1;
}
- for ( i=0; i<table->size; i++)
- {
+ for(i = 0; i < table->size; i++)
init_packobject(&table->objs[i]);
- }
*tbl = table;
return 0;
}
+
/*-------------------------------------------------------------------------
* Function: options_table_free
*
diff --git a/tools/h5repack/h5repacktst.c b/tools/h5repack/h5repacktst.c
index eaebbd6..0a885c7 100644
--- a/tools/h5repack/h5repacktst.c
+++ b/tools/h5repack/h5repacktst.c
@@ -4047,6 +4047,7 @@ int make_dset_reg_ref(hid_t loc_id)
hdset_reg_ref_t *wbuf=NULL; /* buffer to write to disk */
int *dwbuf=NULL; /* Buffer for writing numeric data to disk */
int i; /* counting variables */
+ int retval = -1; /* return value */
/* Allocate write & read buffers */
wbuf = (hdset_reg_ref_t *)calloc(sizeof(hdset_reg_ref_t), (size_t)SPACE1_DIM1);
@@ -4102,24 +4103,23 @@ int make_dset_reg_ref(hid_t loc_id)
if (H5Dclose(did2) < 0)
goto out;
- if (wbuf)
+ retval = 0;
+
+out:
+ if(wbuf)
free(wbuf);
- if (dwbuf)
+ if(dwbuf)
free(dwbuf);
- return 0;
-
-out:
H5E_BEGIN_TRY
{
-
H5Sclose(sid1);
H5Sclose(sid2);
H5Dclose(did1);
H5Dclose(did2);
-
} H5E_END_TRY;
- return -1;
+
+ return retval;
}
/*-------------------------------------------------------------------------