diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5A.c | 2 | ||||
-rw-r--r-- | src/H5Adeprec.c | 2 | ||||
-rw-r--r-- | src/H5Dchunk.c | 14 | ||||
-rw-r--r-- | src/H5E.c | 6 | ||||
-rw-r--r-- | src/H5Eint.c | 6 | ||||
-rw-r--r-- | src/H5G.c | 3 | ||||
-rw-r--r-- | src/H5Gname.c | 9 | ||||
-rw-r--r-- | src/H5Gstab.c | 3 | ||||
-rw-r--r-- | src/H5MM.c | 14 | ||||
-rw-r--r-- | src/H5Oattribute.c | 2 | ||||
-rw-r--r-- | src/H5Ztrans.c | 4 |
11 files changed, 39 insertions, 26 deletions
@@ -547,7 +547,7 @@ H5Aopen(hid_t loc_id, const char *attr_name, hid_t UNUSED aapl_id) /* Read in attribute from object header */ if(NULL == (attr = H5O_attr_open_by_name(loc.oloc, attr_name, H5AC_ind_dxpl_id))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to load attribute info from object header") + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to load attribute info from object header for attribute: '%s'", attr_name) /* Finish initializing attribute */ if(H5A_open_common(&loc, attr) < 0) diff --git a/src/H5Adeprec.c b/src/H5Adeprec.c index 2b244fd..b289ae0 100644 --- a/src/H5Adeprec.c +++ b/src/H5Adeprec.c @@ -211,7 +211,7 @@ H5Aopen_name(hid_t loc_id, const char *name) /* Open the attribute on the object header */ if(NULL == (attr = H5A_open_by_name(&loc, ".", name, H5P_LINK_ACCESS_DEFAULT, H5AC_ind_dxpl_id))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute: '%s'", name) /* Register the attribute and get an ID for it */ if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0) diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 643e1cb..0026183 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -3479,6 +3479,7 @@ H5D_chunk_prune_fill(H5D_chunk_it_ud1_t *udata) void *chunk; /* The file chunk */ H5D_chunk_ud_t chk_udata; /* User data for locking chunk */ uint32_t bytes_accessed; /* Bytes accessed in chunk */ + hbool_t chunk_iter_init = FALSE; /* Whether the chunk iterator has been initialized */ unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -3544,16 +3545,11 @@ H5D_chunk_prune_fill(H5D_chunk_it_ud1_t *udata) /* Create a selection iterator for scattering the elements to memory buffer */ if(H5S_select_iter_init(&chunk_iter, udata->chunk_space, layout->u.chunk.dim[rank]) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize chunk selection information") + chunk_iter_init = TRUE; /* Scatter the data into memory */ - if(H5D_scatter_mem(udata->fb_info.fill_buf, udata->chunk_space, &chunk_iter, (size_t)sel_nelmts, io_info->dxpl_cache, chunk/*out*/) < 0) { - H5S_SELECT_ITER_RELEASE(&chunk_iter); + if(H5D_scatter_mem(udata->fb_info.fill_buf, udata->chunk_space, &chunk_iter, (size_t)sel_nelmts, io_info->dxpl_cache, chunk/*out*/) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "scatter failed") - } /* end if */ - - /* Release the selection iterator */ - if(H5S_SELECT_ITER_RELEASE(&chunk_iter) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") /* The number of bytes accessed in the chunk */ @@ -3566,6 +3562,10 @@ H5D_chunk_prune_fill(H5D_chunk_it_ud1_t *udata) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to unlock raw data chunk") done: + /* Release the selection iterator */ + if(chunk_iter_init && H5S_SELECT_ITER_RELEASE(&chunk_iter) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") + FUNC_LEAVE_NOAPI(ret_value) } /* H5D_chunk_prune_fill */ @@ -1333,6 +1333,7 @@ H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line, int desc_len; /* Actual length of description when formatted */ #endif /* H5_HAVE_VASPRINTF */ char *tmp = NULL; /* Buffer to place formatted description in */ + hbool_t va_started = FALSE; /* Whether the variable argument list is open */ herr_t ret_value=SUCCEED; /* Return value */ /* Don't clear the error stack! :-) */ @@ -1357,6 +1358,7 @@ H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line, /* Format the description */ va_start(ap, fmt); + va_started = TRUE; #ifdef H5_HAVE_VASPRINTF /* Use the vasprintf() routine, since it does what we're trying to do below */ @@ -1398,13 +1400,13 @@ H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line, } /* end while */ #endif /* H5_HAVE_VASPRINTF */ - va_end(ap); - /* Push the error on the stack */ if(H5E_push_stack(estack, file, func, line, cls_id, maj_id, min_id, tmp) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't push error on stack") done: + if(va_started) + va_end(ap); if(tmp) H5MM_xfree(tmp); diff --git a/src/H5Eint.c b/src/H5Eint.c index f650581..10161ea 100644 --- a/src/H5Eint.c +++ b/src/H5Eint.c @@ -694,6 +694,7 @@ H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned lin int desc_len; /* Actual length of description when formatted */ #endif /* H5_HAVE_VASPRINTF */ char *tmp = NULL; /* Buffer to place formatted description in */ + hbool_t va_started = FALSE; /* Whether the variable argument list is open */ herr_t ret_value = SUCCEED; /* Return value */ /* @@ -718,6 +719,7 @@ H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned lin /* Start the variable-argument parsing */ va_start(ap, fmt); + va_started = TRUE; #ifdef H5_HAVE_VASPRINTF /* Use the vasprintf() routine, since it does what we're trying to do below */ @@ -759,13 +761,13 @@ H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned lin } /* end while */ #endif /* H5_HAVE_VASPRINTF */ - va_end(ap); - /* Push the error on the stack */ if(H5E_push_stack(estack, file, func, line, cls_id, maj_id, min_id, tmp) < 0) HGOTO_DONE(FAIL) done: + if(va_started) + va_end(ap); if(tmp) H5MM_xfree(tmp); @@ -1737,6 +1737,9 @@ H5G_visit(hid_t loc_id, const char *group_name, H5_index_t idx_type, unsigned rc; /* Reference count of object */ herr_t ret_value; /* Return value */ + /* Portably clear udata struct (before FUNC_ENTER) */ + HDmemset(&udata, 0, sizeof(udata)); + FUNC_ENTER_NOAPI(H5G_visit, FAIL) /* Check args */ diff --git a/src/H5Gname.c b/src/H5Gname.c index c7feb62..2ba2d52 100644 --- a/src/H5Gname.c +++ b/src/H5Gname.c @@ -1105,7 +1105,8 @@ H5G_get_name_by_addr_cb(hid_t gid, const char *path, const H5L_info_t *linfo, /* Check for object in same file (handles mounted files) */ /* (re-verify address, in case we traversed a file mount) */ if(udata->loc->addr == obj_loc.oloc->addr && udata->loc->file == obj_loc.oloc->file) { - udata->path = H5MM_strdup(path); + if(NULL == (udata->path = H5MM_strdup(path))) + HGOTO_ERROR(H5E_SYM, H5E_CANTALLOC, H5_ITER_ERROR, "can't duplicate path string") /* We found a match so we return immediately */ HGOTO_DONE(H5_ITER_STOP) @@ -1145,6 +1146,9 @@ H5G_get_name_by_addr(hid_t file, hid_t lapl_id, hid_t dxpl_id, const H5O_loc_t * herr_t status; /* Status from iteration */ ssize_t ret_value; /* Return value */ + /* Portably clear udata struct (before FUNC_ENTER) */ + HDmemset(&udata, 0, sizeof(udata)); + FUNC_ENTER_NOAPI(H5G_get_name_by_addr, FAIL) /* Construct the link info for the file's root group */ @@ -1153,7 +1157,8 @@ H5G_get_name_by_addr(hid_t file, hid_t lapl_id, hid_t dxpl_id, const H5O_loc_t * /* Check for root group being the object looked for */ if(root_loc.oloc->addr == loc->addr && root_loc.oloc->file == loc->file) { - udata.path = H5MM_strdup(""); + if(NULL == (udata.path = H5MM_strdup(""))) + HGOTO_ERROR(H5E_SYM, H5E_CANTALLOC, FAIL, "can't duplicate path string") found_obj = TRUE; } /* end if */ else { diff --git a/src/H5Gstab.c b/src/H5Gstab.c index afa137c..001c463 100644 --- a/src/H5Gstab.c +++ b/src/H5Gstab.c @@ -714,6 +714,9 @@ H5G_stab_get_name_by_idx(H5O_loc_t *oloc, H5_iter_order_t order, hsize_t n, hbool_t udata_valid = FALSE; /* Whether iteration information is valid */ ssize_t ret_value; /* Return value */ + /* Portably clear udata struct (before FUNC_ENTER) */ + HDmemset(&udata, 0, sizeof(udata)); + FUNC_ENTER_NOAPI(H5G_stab_get_name_by_idx, FAIL) /* Sanity check */ @@ -110,7 +110,8 @@ H5MM_calloc(size_t size) * H5MM_realloc (NULL, 0) <==> NULL * * Return: Success: Ptr to new memory or NULL if the memory - * was freed. + * was freed or HDrealloc couldn't allocate + * memory. * * Failure: NULL * @@ -130,17 +131,14 @@ H5MM_realloc(void *mem, size_t size) if(NULL == mem) { if(0 == size) - mem = NULL; + ret_value = NULL; else - mem = H5MM_malloc(size); + ret_value = H5MM_malloc(size); } /* end if */ else if(0 == size) - mem = H5MM_xfree(mem); + ret_value = H5MM_xfree(mem); else - mem = HDrealloc(mem, size); - - /* Set return value */ - ret_value = mem; + ret_value = HDrealloc(mem, size); FUNC_LEAVE_NOAPI(ret_value) } /* end H5MM_realloc() */ diff --git a/src/H5Oattribute.c b/src/H5Oattribute.c index 4a19ed4..cafc664 100644 --- a/src/H5Oattribute.c +++ b/src/H5Oattribute.c @@ -527,7 +527,7 @@ H5O_attr_open_by_name(const H5O_loc_t *loc, const char *name, hid_t dxpl_id) /* Check that we found the attribute */ if(!udata.attr) - HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, NULL, "can't locate attribute") + HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, NULL, "can't locate attribute: '%s'", name) /* Get attribute opened from object header */ HDassert(udata.attr); diff --git a/src/H5Ztrans.c b/src/H5Ztrans.c index 8028123..e0f87ac 100644 --- a/src/H5Ztrans.c +++ b/src/H5Ztrans.c @@ -1383,7 +1383,7 @@ H5Z_xform_create(const char *expr) * we don't need to allocate any space since no array will have to be * stored */ if(count > 0) - if((data_xform_prop->dat_val_pointers->ptr_dat_val = (void**) H5MM_calloc(count * sizeof(void**))) == NULL) + if(NULL == (data_xform_prop->dat_val_pointers->ptr_dat_val = (void *)H5MM_calloc(count * sizeof(void *)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate memory for pointers in transform array") /* Initialize the num_ptrs field, which will be used to keep track of the number of copies @@ -1518,7 +1518,7 @@ H5Z_xform_copy(H5Z_data_xform_t **data_xform_prop) count++; if(count > 0) - if((new_data_xform_prop->dat_val_pointers->ptr_dat_val = (void**) H5MM_calloc(count * sizeof(void**))) == NULL) + if(NULL == (new_data_xform_prop->dat_val_pointers->ptr_dat_val = (void *)H5MM_calloc(count * sizeof(void *)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate memory for pointers in transform array") /* Zero out num_pointers prior to H5Z_xform_cop_tree call; that call will increment it to the right amount */ |