From fe2de0f4a5cd9813ac5bfa443d42cb237507047e Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Tue, 1 Oct 2024 10:45:27 -0500 Subject: [PATCH] Remove H5E_clear_stack() from library (#4871) Use existing H5G_loc_exists() routine --- src/H5Gloc.c | 3 +-- src/H5Ocopy.c | 22 ++++++++++++++-------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/H5Gloc.c b/src/H5Gloc.c index 897debcb1bd..8f9f74fd368 100644 --- a/src/H5Gloc.c +++ b/src/H5Gloc.c @@ -608,8 +608,7 @@ H5G__loc_exists_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_ * * Purpose: Check if an object actually exists at a location * - * Return: Success: true/false - * Failure: Negative + * Return: Non-negative on success/Negative on failure * *------------------------------------------------------------------------- */ diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c index 6299b7583af..bd19cd34f44 100644 --- a/src/H5Ocopy.c +++ b/src/H5Ocopy.c @@ -1464,12 +1464,17 @@ H5O__copy_search_comm_dt(H5F_t *file_src, H5O_t *oh_src, H5O_loc_t *oloc_dst /*i /* Walk through the list of datatype suggestions */ while (suggestion) { + bool exists = false; + /* Find the object */ - if (H5G_loc_find(&dst_root_loc, suggestion->path, &obj_loc /*out*/) < 0) - /* Ignore errors - i.e. suggestions not present in - * destination file */ - H5E_clear_stack(); - else + if (H5G_loc_exists(&dst_root_loc, suggestion->path, &exists /*out*/) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTFIND, FAIL, "can't check object's existence"); + + if (exists) { + /* Retrieve the object location info */ + if (H5G_loc_find(&dst_root_loc, suggestion->path, &obj_loc /*out*/) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object location"); + /* Check object and add to skip list if appropriate */ if (H5O__copy_search_comm_dt_check(&obj_oloc, &udata) < 0) { if (H5G_loc_free(&obj_loc) < 0) @@ -1477,9 +1482,10 @@ H5O__copy_search_comm_dt(H5F_t *file_src, H5O_t *oh_src, H5O_loc_t *oloc_dst /*i HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't check object"); } /* end if */ - /* Free location */ - if (H5G_loc_free(&obj_loc) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location"); + /* Free location */ + if (H5G_loc_free(&obj_loc) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location"); + } /* end if */ /* Advance the suggestion pointer */ suggestion = suggestion->next;