[svn-r17980] Description:

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/32 6.3 (duty) in debug mode
    FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
    Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
        w/C++ & FORTRAN, w/threadsafe, in debug mode
    Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x,
        w/C++ & FORTRAN, in production mode
    Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
        w/szip filter, in production mode
    Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
    in production mode
    Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode
    Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
    Mac OS X/32 10.6.2 (amazon) in debug mode
    Mac OS X/32 10.6.2 (amazon) w/C++ & FORTRAN, w/threadsafe,
        in production mode
This commit is contained in:
Quincey Koziol 2009-12-10 07:36:56 -05:00
parent adce7dfd84
commit 34d14bdf89
27 changed files with 967 additions and 638 deletions

View File

@ -3637,7 +3637,8 @@ H5AC_ext_config_2_int_config(H5AC_cache_config_t * ext_conf_ptr,
if ( ( ext_conf_ptr == NULL ) ||
( ext_conf_ptr->version != H5AC__CURR_CACHE_CONFIG_VERSION ) ||
( int_conf_ptr == NULL ) ) {
HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \
"Bad ext_conf_ptr or inf_conf_ptr on entry.")
}
int_conf_ptr->version = H5C__CURR_AUTO_SIZE_CTL_VER;

View File

@ -150,32 +150,21 @@ H5A_compact_build_table_cb(H5O_t UNUSED *oh, H5O_mesg_t *mesg/*in,out*/,
/* Re-allocate the table if necessary */
if(udata->curr_attr == udata->atable->nattrs) {
size_t i;
size_t n = MAX(1, 2 * udata->atable->nattrs);
H5A_t **table = (H5A_t **)H5FL_SEQ_CALLOC(H5A_t_ptr, n);
H5A_t **new_table; /* New table for attributes */
size_t new_table_size; /* Number of attributes in new table */
/* Use attribute functions for operation */
for(i=0; i<udata->atable->nattrs; i++) {
table[i] = (H5A_t *)H5FL_CALLOC(H5A_t);
if(NULL == H5A_copy(table[i], udata->atable->attrs[i]))
HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy attribute")
if(H5A_close(udata->atable->attrs[i]) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTCLOSEOBJ, H5_ITER_ERROR, "can't close attribute")
}
if(udata->atable->nattrs)
udata->atable->attrs = (H5A_t **)H5FL_SEQ_FREE(H5A_t_ptr, udata->atable->attrs);
if(!table)
/* Allocate larger table */
new_table_size = MAX(1, 2 * udata->atable->nattrs);
if(NULL == (new_table = (H5A_t **)H5FL_SEQ_REALLOC(H5A_t_ptr, udata->atable->attrs, new_table_size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5_ITER_ERROR, "unable to extend attribute table")
udata->atable->attrs = table;
udata->atable->nattrs = n;
/* Update table information in user data */
udata->atable->attrs = new_table;
udata->atable->nattrs = new_table_size;
} /* end if */
/* Copy attribute into table */
udata->atable->attrs[udata->curr_attr] = (H5A_t *)H5FL_CALLOC(H5A_t);
if(NULL == H5A_copy(udata->atable->attrs[udata->curr_attr], (const H5A_t *)mesg->native))
if(NULL == (udata->atable->attrs[udata->curr_attr] = H5A_copy(NULL, (const H5A_t *)mesg->native)))
HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy attribute")
/* Assign [somewhat arbitrary] creation order value, if requested */

View File

@ -1760,7 +1760,7 @@ done:
H5B_shared_t *
H5B_shared_new(const H5F_t *f, const H5B_class_t *type, size_t sizeof_rkey)
{
H5B_shared_t *shared; /* New shared B-tree struct */
H5B_shared_t *shared = NULL; /* New shared B-tree struct */
size_t u; /* Local index variable */
H5B_shared_t *ret_value; /* Return value */
@ -1772,8 +1772,8 @@ H5B_shared_new(const H5F_t *f, const H5B_class_t *type, size_t sizeof_rkey)
HDassert(type);
/* Allocate space for the shared structure */
if(NULL == (shared = H5FL_MALLOC(H5B_shared_t)))
HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, NULL, "memory allocation failed for shared B-tree info")
if(NULL == (shared = H5FL_CALLOC(H5B_shared_t)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for shared B-tree info")
/* Set up the "global" information for this file's groups */
shared->type = type;
@ -1788,12 +1788,12 @@ H5B_shared_new(const H5F_t *f, const H5B_class_t *type, size_t sizeof_rkey)
/* Allocate shared buffers */
if(NULL == (shared->page = H5FL_BLK_MALLOC(page, shared->sizeof_rnode)))
HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, NULL, "memory allocation failed for B-tree page")
HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for B-tree page")
#ifdef H5_CLEAR_MEMORY
HDmemset(shared->page, 0, shared->sizeof_rnode);
#endif /* H5_CLEAR_MEMORY */
if(NULL == (shared->nkey = H5FL_SEQ_MALLOC(size_t, (size_t)(shared->two_k + 1))))
HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, NULL, "memory allocation failed for B-tree page")
HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for B-tree native keys")
/* Initialize the offsets into the native key buffer */
for(u = 0; u < (shared->two_k + 1); u++)
@ -1803,6 +1803,15 @@ HDmemset(shared->page, 0, shared->sizeof_rnode);
ret_value = shared;
done:
if(NULL == ret_value)
if(shared) {
if(shared->page)
shared->page = H5FL_BLK_FREE(page, shared->page);
if(shared->nkey)
shared->nkey = H5FL_SEQ_FREE(size_t, shared->nkey);
shared = H5FL_FREE(H5B_shared_t, shared);
} /* end if */
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5B_shared_new() */

View File

@ -9814,12 +9814,8 @@ H5C__autoadjust__ageout__insert_new_marker(H5C_t * cache_ptr)
i++;
}
HDassert( i < H5C__MAX_EPOCH_MARKERS );
if ( (cache_ptr->epoch_marker_active)[i] != FALSE ) {
if(i >= H5C__MAX_EPOCH_MARKERS)
HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't find unused marker.")
}
HDassert( ((cache_ptr->epoch_markers)[i]).addr == (haddr_t)i );
HDassert( ((cache_ptr->epoch_markers)[i]).next == NULL );

View File

@ -1485,8 +1485,9 @@ done:
/* Free the raw B-tree node buffer */
if(NULL == storage.u.btree.shared)
HDONE_ERROR(H5E_IO, H5E_CANTFREE, FAIL, "ref-counted page nil")
if(H5RC_DEC(storage.u.btree.shared) < 0)
HDONE_ERROR(H5E_IO, H5E_CANTFREE, FAIL, "unable to decrement ref-counted page")
else
if(H5RC_DEC(storage.u.btree.shared) < 0)
HDONE_ERROR(H5E_IO, H5E_CANTFREE, FAIL, "unable to decrement ref-counted page")
} /* end if */
FUNC_LEAVE_NOAPI(ret_value)

View File

@ -4396,16 +4396,22 @@ H5D_chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src,
/* create a memory copy of the variable-length datatype */
if(NULL == (dt_mem = H5T_copy(dt_src, H5T_COPY_TRANSIENT)))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy")
if((tid_mem = H5I_register(H5I_DATATYPE, dt_mem, FALSE)) < 0)
if((tid_mem = H5I_register(H5I_DATATYPE, dt_mem, FALSE)) < 0) {
(void)H5T_close(dt_mem);
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register memory datatype")
} /* end if */
/* create variable-length datatype at the destinaton file */
if(NULL == (dt_dst = H5T_copy(dt_src, H5T_COPY_TRANSIENT)))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy")
if(H5T_set_loc(dt_dst, f_dst, H5T_LOC_DISK) < 0)
if(H5T_set_loc(dt_dst, f_dst, H5T_LOC_DISK) < 0) {
(void)H5T_close(dt_dst);
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "cannot mark datatype on disk")
if((tid_dst = H5I_register(H5I_DATATYPE, dt_dst, FALSE)) < 0)
} /* end if */
if((tid_dst = H5I_register(H5I_DATATYPE, dt_dst, FALSE)) < 0) {
(void)H5T_close(dt_dst);
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register destination file datatype")
} /* end if */
/* Set up the conversion functions */
if(NULL == (tpath_src_mem = H5T_path_find(dt_src, dt_mem, NULL, NULL, dxpl_id, FALSE)))
@ -4435,7 +4441,7 @@ H5D_chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src,
/* Atomize */
if((sid_buf = H5I_register(H5I_DATASPACE, buf_space, FALSE)) < 0) {
H5S_close(buf_space);
(void)H5S_close(buf_space);
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace ID")
} /* end if */

View File

@ -234,6 +234,21 @@ H5O_attr_decode(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, unsigned UNUSED mesg_fl
ret_value = attr;
done:
if(NULL == ret_value) {
if(attr) {
if(attr->shared) {
/* Free any dynamicly allocated items */
if(H5A_free(attr) < 0)
HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, NULL, "can't release attribute info")
/* Destroy shared attribute struct */
attr->shared = H5FL_FREE(H5A_shared_t, attr->shared);
} /* end if */
} /* end if */
attr = H5FL_FREE(H5A_t, attr);
} /* end if */
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_attr_decode() */

View File

@ -2770,7 +2770,7 @@ test_insert_lots(hid_t fapl, const H5B2_create_t *cparam,
curr_time=1109170019;
HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time);
#endif /* QAK */
HDsrandom((unsigned long)curr_time);
HDsrandom((unsigned)curr_time);
/*
* Test inserting many records into v2 B-tree
@ -6445,7 +6445,7 @@ test_remove_lots(const char *env_h5_drvr, hid_t fapl, const H5B2_create_t *cpara
curr_time = 1163537969;
HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time);
#endif /* QAK */
HDsrandom((unsigned long)curr_time);
HDsrandom((unsigned)curr_time);
/*
* Test removing many records into v2 B-tree

View File

@ -7309,7 +7309,7 @@ main(void)
envval = "nomatch";
/* Set the random # seed */
HDsrandom((unsigned long)HDtime(NULL));
HDsrandom((unsigned)HDtime(NULL));
/* Testing setup */
h5_reset();

View File

@ -5218,7 +5218,7 @@ main(void)
unsigned long nerrors = 0;
/* Set the random # seed */
HDsrandom((unsigned long)HDtime(NULL));
HDsrandom((unsigned)HDtime(NULL));
reset_hdf5();

View File

@ -6337,7 +6337,7 @@ main(void)
hid_t fapl = -1;
/* Set the random # seed */
HDsrandom((unsigned long)HDtime(NULL));
HDsrandom((unsigned)HDtime(NULL));
reset_hdf5();
fapl = h5_fileaccess();

View File

@ -1234,7 +1234,7 @@ main(int argc, char *argv[])
printf("\n");
/* Set the random # seed */
HDsrandom((unsigned long)HDtime(NULL));
HDsrandom((unsigned)HDtime(NULL));
/*
* Open the library explicitly for thread-safe builds, so per-thread

View File

@ -596,7 +596,7 @@ main(int argc, char *argv[])
printf("\n");
/* Set the random # seed */
HDsrandom((unsigned long)HDtime(NULL));
HDsrandom((unsigned)HDtime(NULL));
/* Reset library */
h5_reset();

File diff suppressed because it is too large Load Diff

View File

@ -645,7 +645,7 @@ test_allocate_random(void)
curr_time=1115412944;
HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time);
#endif /* QAK */
HDsrandom((unsigned long)curr_time);
HDsrandom((unsigned)curr_time);
/* Create a memory pool */
if(NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS)))

View File

@ -93,7 +93,7 @@ test_heap_init(void)
/* Create randomized set of numbers */
curr_time=time(NULL);
HDsrandom((unsigned long)curr_time);
HDsrandom((unsigned)curr_time);
for(u=0; u<NUM_ELEMS; u++)
/* Generate random numbers from -1000 to 1000 */
rand_num[u].val=(int)(HDrandom()%2001)-1001;

View File

@ -71,7 +71,7 @@ test_skiplist_init(void)
/* Initialize random number seed */
curr_time = HDtime(NULL);
HDsrandom((unsigned long)curr_time);
HDsrandom((unsigned)curr_time);
/* Create randomized set of numbers */
for(u=0; u<NUM_ELEMS; u++) {

View File

@ -124,7 +124,7 @@ test_tst_init(void)
for(u=0; u<num_uniq_words; u++)
rand_uniq_words[u]=uniq_words[u];
curr_time=HDtime(NULL);
HDsrandom((unsigned long)curr_time);
HDsrandom((unsigned)curr_time);
for(u=0; u<num_uniq_words; u++) {
v=u+(HDrandom()%(num_uniq_words-u));
if(u!=v) {

View File

@ -807,7 +807,7 @@ void test_unicode(void)
MESSAGE(5, ("Testing UTF-8 Encoding\n"));
/* Create a random string with length NUM_CHARS */
HDsrandom((unsigned long)HDtime(NULL));
HDsrandom((unsigned)HDtime(NULL));
HDmemset(test_string, 0, sizeof(test_string));
for(x=0; x<NUM_CHARS; x++)

View File

@ -1487,8 +1487,8 @@ delete_node(hid_t pid, hid_t id)
static int
test_unlink_rightleaf(hid_t fid)
{
hid_t rootid, /* Group ID for root group */
*gids; /* Array of IDs for groups created */
hid_t rootid = -1, /* Group ID for root group */
*gids = NULL; /* Array of IDs for groups created */
int n, /* Local index variable */
ngroups = 150; /* Number of groups to create */
char name[256]; /* Name of object to create */
@ -1496,7 +1496,7 @@ test_unlink_rightleaf(hid_t fid)
TESTING("deleting right-most child in non-leaf B-tree node");
/* Allocate space for the group IDs */
if(NULL == (gids = (hid_t *)HDmalloc((size_t)ngroups * sizeof(hid_t)))) TEST_ERROR
if(NULL == (gids = (hid_t *)HDcalloc((size_t)ngroups, sizeof(hid_t)))) TEST_ERROR
if((rootid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
@ -1514,8 +1514,10 @@ test_unlink_rightleaf(hid_t fid)
} /* end for */
/* Close all the groups */
for (n = 0; n < ngroups; n++)
for (n = 0; n < ngroups; n++) {
if(H5Gclose(gids[n]) < 0) TEST_ERROR
gids[n] = 0;
} /* end for */
/* Close root group ID */
if(H5Gclose(rootid) < 0) TEST_ERROR
@ -1527,6 +1529,20 @@ test_unlink_rightleaf(hid_t fid)
return 0;
error:
if(gids) {
/* Close any open groups */
for (n = 0; n < ngroups; n++)
if(gids[n]) {
H5E_BEGIN_TRY {
H5Gclose(gids[n]);
} H5E_END_TRY;
} /* end if */
HDfree(gids);
} /* end if */
H5E_BEGIN_TRY {
H5Gclose(rootid);
} H5E_END_TRY;
return 1;
} /* end test_unlink_rightleaf() */
@ -1550,8 +1566,8 @@ error:
static int
test_unlink_rightnode(hid_t fid)
{
hid_t rootid, /* Group ID for root group */
*gids; /* Array of IDs for groups created */
hid_t rootid = -1, /* Group ID for root group */
*gids = NULL; /* Array of IDs for groups created */
int n, /* Local index variable */
ngroups = 150; /* Number of groups to create */
char name[256]; /* Name of object to create */
@ -1559,7 +1575,7 @@ test_unlink_rightnode(hid_t fid)
TESTING("deleting right-most child in non-leaf B-tree node");
/* Allocate space for the group IDs */
if(NULL == (gids = (hid_t *)HDmalloc((size_t)ngroups * sizeof(hid_t)))) TEST_ERROR
if(NULL == (gids = (hid_t *)HDcalloc((size_t)ngroups, sizeof(hid_t)))) TEST_ERROR
if((rootid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
@ -1570,8 +1586,10 @@ test_unlink_rightnode(hid_t fid)
} /* end for */
/* Close all the groups */
for (n = 0; n < ngroups; n++)
for (n = 0; n < ngroups; n++) {
if(H5Gclose(gids[n]) < 0) FAIL_STACK_ERROR
gids[n] = 0;
} /* end for */
/* Unlink specific objects to trigger deletion of right leaf in non-leaf node */
if(H5Ldelete(fid, "/ZoneB77", H5P_DEFAULT) < 0) FAIL_STACK_ERROR
@ -1590,6 +1608,20 @@ test_unlink_rightnode(hid_t fid)
return 0;
error:
if(gids) {
/* Close any open groups */
for (n = 0; n < ngroups; n++)
if(gids[n]) {
H5E_BEGIN_TRY {
H5Gclose(gids[n]);
} H5E_END_TRY;
} /* end if */
HDfree(gids);
} /* end if */
H5E_BEGIN_TRY {
H5Gclose(rootid);
} H5E_END_TRY;
return 1;
} /* end test_unlink_rightnode() */
@ -1613,8 +1645,8 @@ error:
static int
test_unlink_middlenode(hid_t fid)
{
hid_t rootid, /* Group ID for root group */
*gids; /* Array of IDs for groups created */
hid_t rootid = -1, /* Group ID for root group */
*gids = NULL; /* Array of IDs for groups created */
int n, /* Local index variable */
ngroups = 250; /* Number of groups to create */
char name[256]; /* Name of object to create */
@ -1622,7 +1654,7 @@ test_unlink_middlenode(hid_t fid)
TESTING("deleting right-most child in non-leaf B-tree node");
/* Allocate space for the group IDs */
if(NULL == (gids = (hid_t *)HDmalloc((size_t)ngroups * sizeof(hid_t)))) TEST_ERROR
if(NULL == (gids = (hid_t *)HDcalloc((size_t)ngroups, sizeof(hid_t)))) TEST_ERROR
if((rootid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
@ -1633,8 +1665,10 @@ test_unlink_middlenode(hid_t fid)
} /* end for */
/* Close all the groups */
for (n = 0; n < ngroups; n++)
for (n = 0; n < ngroups; n++) {
if(H5Gclose(gids[n]) < 0) FAIL_STACK_ERROR
gids[n] = 0;
} /* end for */
/* Unlink specific objects to trigger deletion of all leafs in "interior" non-leaf node */
if(H5Ldelete(fid, "/ZoneC11", H5P_DEFAULT) < 0) FAIL_STACK_ERROR
@ -1796,6 +1830,20 @@ test_unlink_middlenode(hid_t fid)
return 0;
error:
if(gids) {
/* Close any open groups */
for (n = 0; n < ngroups; n++)
if(gids[n]) {
H5E_BEGIN_TRY {
H5Gclose(gids[n]);
} H5E_END_TRY;
} /* end if */
HDfree(gids);
} /* end if */
H5E_BEGIN_TRY {
H5Gclose(rootid);
} H5E_END_TRY;
return 1;
} /* end test_unlink_middlenode() */
@ -1819,7 +1867,7 @@ error:
static int
test_resurrect_dataset(hid_t fapl)
{
hid_t f =-1, s =-1, d =-1;
hid_t f = -1, s = -1, d = -1;
char filename[1024];
TESTING("resurrecting dataset after deletion");
@ -2404,7 +2452,7 @@ main(void)
double rdcc_w0;
/* Set the random # seed */
HDsrandom((unsigned long)HDtime(NULL));
HDsrandom((unsigned)HDtime(NULL));
/* Open */
h5_reset();

View File

@ -808,7 +808,6 @@ test_family_compat(void)
char filename[1024];
char pathname[1024], pathname_individual[1024];
char newname[1024], newname_individual[1024];
FILE *tmp_fp, *old_fp; /* Pointers to temp & old files */
int counter = 0;
TESTING("FAMILY file driver backward compatibility");
@ -838,10 +837,6 @@ test_family_compat(void)
sprintf(pathname_individual, pathname, counter);
}
if ((NULL != (old_fp = HDfopen(pathname_individual,"rb"))) &&
(NULL != (tmp_fp = HDfopen(newname_individual,"wb"))))
TEST_ERROR;
/* Make sure we can open the file. Use the read and write mode to flush the
* superblock. */
if((file = H5Fopen(newname, H5F_ACC_RDWR, fapl)) < 0)

View File

@ -1587,16 +1587,29 @@ static int
parsePathInfo(struct path_info *path, char *temp)
{
const char delimiter[] = "/";
char *token = (char*) malloc(255*sizeof(char));
char *token;
int i=0;
const char *err1 = "Path string larger than MAX_PATH_NAME_LENGTH.\n";
token = HDstrtok (temp, delimiter);
if (HDstrlen(token) >= MAX_PATH_NAME_LENGTH)
{
(void) fprintf(stderr, err1);
return (-1);
}
HDstrcpy(path->group[i++],token);
HDstrcpy(path->group[i++],HDstrtok (temp, delimiter));
while (1)
{
token = HDstrtok (NULL, delimiter);
if (token == NULL)
break;
if (HDstrlen(token) >= MAX_PATH_NAME_LENGTH)
{
(void) fprintf(stderr, err1);
return (-1);
}
HDstrcpy(path->group[i++],token);
}
path->count = i;
@ -1608,11 +1621,12 @@ parseDimensions(struct Input *in, char *strm)
{
const char delimiter[] = ",";
char temp[255];
char *token = (char*) malloc(255*sizeof(char));
char *token;
int i=0;
const char *err1 = "Unable to allocate dynamic memory.\n";
HDstrcpy(temp, strm);
HDstrncpy(temp, strm, sizeof(temp));
temp[sizeof(temp)-1] = '\0';
HDstrtok (temp, delimiter);
while (1)
@ -1631,7 +1645,8 @@ parseDimensions(struct Input *in, char *strm)
}
i=0;
HDstrcpy(temp, strm);
HDstrncpy(temp, strm, sizeof(temp));
temp[sizeof(temp)-1] = '\0';
in->sizeOfDimension[i++] = HDstrtol(HDstrtok (temp, delimiter), NULL, BASE_10);
while (1)

View File

@ -38,6 +38,7 @@
#define ERR 20 /* invalid token */
#define MAX_GROUPS_IN_PATH 20
#define MAX_PATH_NAME_LENGTH 255
#define NUM_KEYS 14
#define MIN_NUM_DIMENSION 1
#define MAX_NUM_DIMENSION 32
@ -73,7 +74,7 @@
struct path_info
{
char group[MAX_GROUPS_IN_PATH][255];
char group[MAX_GROUPS_IN_PATH][MAX_PATH_NAME_LENGTH];
int count;
};

View File

@ -345,6 +345,8 @@ create_textfile(const char *name, size_t size)
HDwrite(fd, buf, size);
free(buf);
HDclose(fd);
}

View File

@ -112,6 +112,7 @@ h5repack_init(pack_opt_t *options, int verbose, H5F_file_space_type_t strategy,
return (options_table_init(&(options->op_tbl)));
}
/*-------------------------------------------------------------------------
* Function: h5repack_end
*
@ -125,6 +126,7 @@ int h5repack_end (pack_opt_t *options)
return options_table_free(options->op_tbl);
}
/*-------------------------------------------------------------------------
* Function: h5repack_addfilter
*
@ -135,7 +137,6 @@ int h5repack_end (pack_opt_t *options)
*
*-------------------------------------------------------------------------
*/
int h5repack_addfilter(const char* str,
pack_opt_t *options)
{
@ -147,38 +148,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
*

View File

@ -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
*

View File

@ -4056,6 +4056,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);
@ -4111,24 +4112,23 @@ int make_dset_reg_ref(hid_t loc_id)
if (H5Dclose(did2) < 0)
goto out;
if (wbuf)
free(wbuf);
if (dwbuf)
free(dwbuf);
return 0;
retval = 0;
out:
if(wbuf)
free(wbuf);
if(dwbuf)
free(dwbuf);
H5E_BEGIN_TRY
{
H5Sclose(sid1);
H5Sclose(sid2);
H5Dclose(did1);
H5Dclose(did2);
} H5E_END_TRY;
return -1;
return retval;
}
/*-------------------------------------------------------------------------