Skip to content

Instantly share code, notes, and snippets.

@houjun
Created September 27, 2021 22:15
Show Gist options
  • Save houjun/4c556f5e5c5e64275c3f412eca395c4e to your computer and use it in GitHub Desktop.
Save houjun/4c556f5e5c5e64275c3f412eca395c4e to your computer and use it in GitHub Desktop.
diff --git a/src/H5Iint.c b/src/H5Iint.c
index 86a2810437..2166603635 100644
--- a/src/H5Iint.c
+++ b/src/H5Iint.c
@@ -1533,14 +1533,20 @@ H5I__iterate_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata)
object = H5I__unwrap((void *)info->object, type); /* Casting away const OK */
H5_GCC_CLANG_DIAG_ON("cast-qual")
- /* Invoke callback function */
- cb_ret_val = (*udata->user_func)((void *)object, info->id, udata->user_udata);
-
- /* Set the return value based on the callback's return value */
- if (cb_ret_val > 0)
- ret_value = H5_ITER_STOP; /* terminate iteration early */
- else if (cb_ret_val < 0)
- ret_value = H5_ITER_ERROR; /* indicate failure (which terminates iteration) */
+ // Tang debug
+ if (NULL == object) {
+ ret_value = 0;
+ }
+ else {
+ /* Invoke callback function */
+ cb_ret_val = (*udata->user_func)((void *)object, info->id, udata->user_udata);
+
+ /* Set the return value based on the callback's return value */
+ if (cb_ret_val > 0)
+ ret_value = H5_ITER_STOP; /* terminate iteration early */
+ else if (cb_ret_val < 0)
+ ret_value = H5_ITER_ERROR; /* indicate failure (which terminates iteration) */
+ }
}
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5Oattribute.c b/src/H5Oattribute.c
index 6ca4204168..31b4977b15 100644
--- a/src/H5Oattribute.c
+++ b/src/H5Oattribute.c
@@ -471,13 +471,13 @@ H5O__attr_open_by_name(const H5O_loc_t *loc, const char *name)
/* If found the attribute is already opened, make a copy of it to share the
* object information. If not, open attribute as a new object
*/
- if ((found_open_attr = H5O__attr_find_opened_attr(loc, &exist_attr, name)) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, NULL, "failed in finding opened attribute")
- else if (found_open_attr == TRUE) {
- if (NULL == (opened_attr = H5A__copy(NULL, exist_attr)))
- HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, NULL, "can't copy existing attribute")
- } /* end else if */
- else {
+ /* if ((found_open_attr = H5O__attr_find_opened_attr(loc, &exist_attr, name)) < 0) */
+ /* HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, NULL, "failed in finding opened attribute") */
+ /* else if (found_open_attr == TRUE) { */
+ /* if (NULL == (opened_attr = H5A__copy(NULL, exist_attr))) */
+ /* HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, NULL, "can't copy existing attribute") */
+ /* } /1* end else if *1/ */
+ /* else { */
/* Check for attributes in dense storage */
if (H5F_addr_defined(ainfo.fheap_addr)) {
/* Open attribute with dense storage */
@@ -510,7 +510,7 @@ H5O__attr_open_by_name(const H5O_loc_t *loc, const char *name)
/* Mark datatype as being on disk now */
if (H5T_set_loc(opened_attr->shared->dt, H5F_VOL_OBJ(loc->file), H5T_LOC_DISK) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "invalid datatype location")
- } /* end else */
+ /* } /1* end else *1/ */
/* Set return value */
ret_value = opened_attr;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment