From e8bde1413c897f904626eaa95a4109c421460dfc Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Fri, 12 Jul 2024 15:13:01 -0500 Subject: [PATCH 1/4] Eliminate more H5E_BEGIN/END_TRY macros and H5E_clear_stack() calls Signed-off-by: Quincey Koziol --- src/H5FDfamily.c | 73 ++++++++++++------------ src/H5Fsuper.c | 131 ++++++++++++++++-------------------------- src/H5SM.c | 145 ++++++++++++++++++++--------------------------- src/H5SMpkg.h | 2 +- src/H5SMtest.c | 7 ++- 5 files changed, 151 insertions(+), 207 deletions(-) diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c index 49fd484a4eb..ecb7de68539 100644 --- a/src/H5FDfamily.c +++ b/src/H5FDfamily.c @@ -423,7 +423,7 @@ H5FD__family_fapl_get(H5FD_t *_file) FUNC_ENTER_PACKAGE if (NULL == (fa = (H5FD_family_fapl_t *)H5MM_calloc(sizeof(H5FD_family_fapl_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, NULL, "memory allocation failed"); fa->memb_size = file->memb_size; if (NULL == (plist = (H5P_genplist_t *)H5I_object(file->memb_fapl_id))) @@ -463,7 +463,7 @@ H5FD__family_fapl_copy(const void *_old_fa) FUNC_ENTER_PACKAGE if (NULL == (new_fa = (H5FD_family_fapl_t *)H5MM_malloc(sizeof(H5FD_family_fapl_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, NULL, "memory allocation failed"); /* Copy the fields of the structure */ H5MM_memcpy(new_fa, old_fa, sizeof(H5FD_family_fapl_t)); @@ -671,7 +671,7 @@ H5FD__family_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxad /* Initialize file from file access properties */ if (NULL == (file = (H5FD_family_t *)H5MM_calloc(sizeof(H5FD_family_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate file struct"); + HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, NULL, "unable to allocate file struct"); if (H5P_FILE_ACCESS_DEFAULT == fapl_id) { H5FD_family_fapl_t default_fa; @@ -760,7 +760,7 @@ H5FD__family_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxad assert(n > 0); if (NULL == (x = (H5FD_t **)H5MM_realloc(file->memb, n * sizeof(H5FD_t *)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to reallocate members"); + HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, NULL, "unable to reallocate members"); file->amembs = n; file->memb = x; } /* end if */ @@ -770,18 +770,21 @@ H5FD__family_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxad * otherwise an open failure means that we've reached the last member. * Allow H5F_ACC_CREAT only on the first family member. */ - H5E_BEGIN_TRY - { - file->memb[file->nmembs] = - H5FDopen(memb_name, (0 == file->nmembs ? flags : t_flags), file->memb_fapl_id, HADDR_UNDEF); + if (0 == file->nmembs) { + if (NULL == (file->memb[file->nmembs] = H5FDopen(memb_name, (0 == file->nmembs ? flags : t_flags), file->memb_fapl_id, HADDR_UNDEF))) + HGOTO_ERROR(H5E_VFL, H5E_CANTOPENFILE, NULL, "unable to open member file"); } - H5E_END_TRY - if (!file->memb[file->nmembs]) { - if (0 == file->nmembs) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open member file"); - H5E_clear_stack(); - break; + else { + H5E_PAUSE_ERRORS + { + file->memb[file->nmembs] = H5FDopen(memb_name, (0 == file->nmembs ? flags : t_flags), file->memb_fapl_id, HADDR_UNDEF); + } + H5E_RESUME_ERRORS + + if (!file->memb[file->nmembs]) + break; } + file->nmembs++; } @@ -1005,7 +1008,7 @@ H5FD__family_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t abs_eoa) H5FD_t **x = (H5FD_t **)H5MM_realloc(file->memb, n * sizeof(H5FD_t *)); if (!x) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate memory block"); + HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "unable to allocate memory block"); file->amembs = n; file->memb = x; file->nmembs = u; @@ -1015,14 +1018,8 @@ H5FD__family_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t abs_eoa) if (u >= file->nmembs || !file->memb[u]) { file->nmembs = MAX(file->nmembs, u + 1); snprintf(memb_name, H5FD_FAM_MEMB_NAME_BUF_SIZE, file->name, u); - H5E_BEGIN_TRY - { - H5_CHECK_OVERFLOW(file->memb_size, hsize_t, haddr_t); - file->memb[u] = H5FDopen(memb_name, file->flags | H5F_ACC_CREAT, file->memb_fapl_id, - (haddr_t)file->memb_size); - } - H5E_END_TRY - if (NULL == file->memb[u]) + H5_CHECK_OVERFLOW(file->memb_size, hsize_t, haddr_t); + if (NULL == (file->memb[u] = H5FDopen(memb_name, file->flags | H5F_ACC_CREAT, file->memb_fapl_id, (haddr_t)file->memb_size))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to open member file"); } /* end if */ @@ -1082,7 +1079,7 @@ H5FD__family_get_eof(const H5FD_t *_file, H5FD_mem_t type) * loop with i==0. */ assert(file->nmembs > 0); - for (i = (int)file->nmembs - 1; i >= 0; --i) { + for (i = (int)(file->nmembs - 1); i >= 0; --i) { if ((eof = H5FD_get_eof(file->memb[i], type)) != 0) break; if (0 == i) @@ -1420,7 +1417,6 @@ H5FD__family_delete(const char *filename, hid_t fapl_id) unsigned current_member; char *member_name = NULL; char *temp = NULL; - herr_t delete_error = FAIL; herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -1469,8 +1465,7 @@ H5FD__family_delete(const char *filename, hid_t fapl_id) filename = temp; } else - HGOTO_ERROR(H5E_VFL, H5E_CANTDELETEFILE, FAIL, - "provided file name cannot generate unique sub-files"); + HGOTO_ERROR(H5E_VFL, H5E_CANTDELETEFILE, FAIL, "provided file name cannot generate unique sub-files"); } /* Delete all the family members */ @@ -1488,18 +1483,22 @@ H5FD__family_delete(const char *filename, hid_t fapl_id) * Note that this means that any missing files in the family will leave * undeleted members behind. */ - H5E_BEGIN_TRY - { - delete_error = H5FD_delete(member_name, memb_fapl_id); - } - H5E_END_TRY - if (FAIL == delete_error) { - if (0 == current_member) + if (0 == current_member) { + if (H5FD_delete(member_name, memb_fapl_id) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTDELETEFILE, FAIL, "unable to delete member file"); - else - H5E_clear_stack(); - break; } + else { + herr_t delete_error; + + H5E_PAUSE_ERRORS + { + delete_error = H5FD_delete(member_name, memb_fapl_id); + } + H5E_RESUME_ERRORS + if (delete_error < 0) + break; + } + current_member++; } /* end while */ diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c index 550560d9387..72b53866cac 100644 --- a/src/H5Fsuper.c +++ b/src/H5Fsuper.c @@ -101,9 +101,7 @@ H5F__super_ext_create(H5F_t *f, H5O_loc_t *ext_ptr) /* Check for older version of superblock format that can't support superblock extensions */ if (f->shared->sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) - HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, - "superblock extension not permitted with version %u of superblock", - f->shared->sblock->super_vers); + HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, "superblock extension not permitted with version %u of superblock", f->shared->sblock->super_vers); else if (H5_addr_defined(f->shared->sblock->ext_addr)) HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, "superblock extension already exists?!?!"); else { @@ -117,7 +115,7 @@ H5F__super_ext_create(H5F_t *f, H5O_loc_t *ext_ptr) */ H5O_loc_reset(ext_ptr); if (H5O_create(f, (size_t)0, (size_t)1, H5P_GROUP_CREATE_DEFAULT, ext_ptr) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "unable to create superblock extension"); + HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, "unable to create superblock extension"); /* Record the address of the superblock extension */ f->shared->sblock->ext_addr = ext_ptr->addr; @@ -156,7 +154,7 @@ H5F__super_ext_open(H5F_t *f, haddr_t ext_addr, H5O_loc_t *ext_ptr) /* Open the superblock extension object header */ if (H5O_open(ext_ptr) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open superblock extension"); + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENOBJ, FAIL, "unable to open superblock extension"); done: FUNC_LEAVE_NOAPI(ret_value) @@ -276,10 +274,8 @@ H5F__update_super_ext_driver_msg(H5F_t *f) */ drvinfo.len = driver_size; drvinfo.buf = dbuf; - if (H5F__super_ext_write_msg(f, H5O_DRVINFO_ID, &drvinfo, false, H5O_MSG_NO_FLAGS_SET) < - 0) - HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, - "unable to update driver info header message"); + if (H5F__super_ext_write_msg(f, H5O_DRVINFO_ID, &drvinfo, false, H5O_MSG_NO_FLAGS_SET) < 0) + HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "unable to update driver info header message"); } /* end if driver_size > 0 */ } /* end if !H5F_HAS_FEATURE(f, H5FD_FEAT_IGNORE_DRVRINFO) */ } /* end if superblock extension exists */ @@ -311,7 +307,7 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, bool initial_read) H5P_genplist_t *c_plist; /* File creation property list */ H5FD_t *file; /* File driver pointer */ unsigned sblock_flags = H5AC__NO_FLAGS_SET; /* flags used in superblock unprotect call */ - haddr_t super_addr; /* Absolute address of superblock */ + haddr_t super_addr = HADDR_UNDEF; /* Absolute address of superblock */ haddr_t eof; /* End of file address */ unsigned rw_flags; /* Read/write permissions for file */ bool skip_eof_check = false; /* Whether to skip checking the EOF value */ @@ -339,7 +335,7 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, bool initial_read) /* If we are an MPI application with at least two processes, the * following superblock signature location optimization is applicable. * - * Note:: For parallel applications which don't setup for using the + * Note: For parallel applications which don't setup for using the * HDF5 MPIO driver, we will arrive here with mpi_size == 1. * This occurs because of the variable initialization (above) and the * fact that we have skipped actually calling MPI functions to determine @@ -361,19 +357,13 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, bool initial_read) /* Search for the file's signature only with rank 0 process */ if (0 == mpi_rank) { - herr_t status; - /* Try detecting file's signature */ /* (Don't leave before Bcast, to avoid hang on error) */ - H5E_BEGIN_TRY + H5E_PAUSE_ERRORS { - status = H5FD_locate_signature(file, &super_addr); + H5FD_locate_signature(file, &super_addr); } - H5E_END_TRY - - /* Set superblock address to undefined on error */ - if (status < 0) - super_addr = HADDR_UNDEF; + H5E_RESUME_ERRORS } /* end if */ /* Broadcast superblock address to other processes */ @@ -579,7 +569,7 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, bool initial_read) /* Check if this private property exists in fapl */ if (H5P_exist_plist(fa_plist, H5F_ACS_SKIP_EOF_CHECK_NAME) > 0) if (H5P_get(fa_plist, H5F_ACS_SKIP_EOF_CHECK_NAME, &skip_eof_check) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get skip EOF check value"); + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get skip EOF check value"); if (H5F_INTENT(f) & H5F_ACC_SWMR_READ) { /* @@ -595,10 +585,7 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, bool initial_read) /* (Account for the stored EOA being absolute offset -QAK) */ if ((eof + sblock->base_addr) < udata.stored_eof) - HGOTO_ERROR(H5E_FILE, H5E_TRUNCATED, FAIL, - "truncated file: eof = %llu, sblock->base_addr = %llu, stored_eof = %llu", - (unsigned long long)eof, (unsigned long long)sblock->base_addr, - (unsigned long long)udata.stored_eof); + HGOTO_ERROR(H5E_FILE, H5E_TRUNCATED, FAIL, "truncated file: eof = %llu, sblock->base_addr = %llu, stored_eof = %llu", (unsigned long long)eof, (unsigned long long)sblock->base_addr, (unsigned long long)udata.stored_eof); } /* @@ -627,13 +614,11 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, bool initial_read) /* extend EOA so we can read at least the fixed sized * portion of the driver info block */ - if (H5FD_set_eoa(f->shared->lf, H5FD_MEM_SUPER, sblock->driver_addr + H5F_DRVINFOBLOCK_HDR_SIZE) < - 0) /* will extend eoa later if required */ + if (H5FD_set_eoa(f->shared->lf, H5FD_MEM_SUPER, sblock->driver_addr + H5F_DRVINFOBLOCK_HDR_SIZE) < 0) /* will extend eoa later if required */ HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "set end of space allocation request failed"); /* Look up the driver info block */ - if (NULL == (drvinfo = (H5O_drvinfo_t *)H5AC_protect(f, H5AC_DRVRINFO, sblock->driver_addr, - &drvrinfo_udata, rw_flags))) + if (NULL == (drvinfo = (H5O_drvinfo_t *)H5AC_protect(f, H5AC_DRVRINFO, sblock->driver_addr, &drvrinfo_udata, rw_flags))) HGOTO_ERROR(H5E_FILE, H5E_CANTPROTECT, FAIL, "unable to load driver info block"); /* Loading the driver info block is enough to set up the right info */ @@ -671,8 +656,7 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, bool initial_read) * superblock version >= 2. */ if (sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, - "invalid superblock - extension message should not be defined for version < 2"); + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "invalid superblock - extension message should not be defined for version < 2"); /* Check for superblock extension being located "outside" the stored * 'eoa' value, which can occur with the split/multi VFD. @@ -747,8 +731,7 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, bool initial_read) /* Get message flags */ if (H5O_msg_get_flags(&ext_loc, H5O_FSINFO_ID, &flags) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, - "unable to message flags for free-space manager info message"); + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to message flags for free-space manager info message"); /* If message is NOT marked "unknown"--set up file space info */ if (!(flags & H5O_MSG_FLAG_WAS_UNKNOWN)) { @@ -760,8 +743,7 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, bool initial_read) */ if (H5P_exist_plist(fa_plist, H5F_ACS_NULL_FSM_ADDR_NAME) > 0) if (H5P_get(fa_plist, H5F_ACS_NULL_FSM_ADDR_NAME, &f->shared->null_fsm_addr) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, - "can't get clearance for persisting fsm addr"); + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get clearance for persisting fsm addr"); /* Retrieve the 'file space info' structure */ if (NULL == H5O_msg_read(&ext_loc, H5O_FSINFO_ID, &fsinfo)) @@ -769,8 +751,7 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, bool initial_read) /* Version bounds check */ if (H5O_fsinfo_check_version(H5F_HIGH_BOUND(f), &fsinfo) < 0) - HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, FAIL, - "File space info message's version out of bounds"); + HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, FAIL, "File space info message's version out of bounds"); /* Update changed values */ if (f->shared->fs_version != fsinfo.version) @@ -883,8 +864,7 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, bool initial_read) if (f->shared->null_fsm_addr) { if (H5F__super_ext_write_msg(f, H5O_FSINFO_ID, &fsinfo, false, H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0) - HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, - "error in writing fsinfo message to superblock extension"); + HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "error in writing fsinfo message to superblock extension"); } else { if (H5F__super_ext_remove_msg(f, H5O_FSINFO_ID) < 0) { @@ -892,14 +872,11 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, bool initial_read) f->shared->sblock = NULL; #endif /* JRM */ - HGOTO_ERROR(H5E_FILE, H5E_CANTDELETE, FAIL, - "error in removing message from superblock extension"); + HGOTO_ERROR(H5E_FILE, H5E_CANTDELETE, FAIL, "error in removing message from superblock extension"); } - if (H5F__super_ext_write_msg(f, H5O_FSINFO_ID, &fsinfo, true, - H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0) - HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, - "error in writing fsinfo message to superblock extension"); + if (H5F__super_ext_write_msg(f, H5O_FSINFO_ID, &fsinfo, true, H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0) + HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "error in writing fsinfo message to superblock extension"); } #if 1 /* bug fix test code -- tidy this up if all goes well */ /* JRM */ f->shared->sblock = NULL; @@ -934,8 +911,7 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, bool initial_read) /* Indicate to the cache that there's an image to load on first protect call */ if (H5AC_load_cache_image_on_next_protect(f, mdci_msg.addr, mdci_msg.size, rw) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTLOAD, FAIL, - "call to H5AC_load_cache_image_on_next_protect failed"); + HGOTO_ERROR(H5E_FILE, H5E_CANTLOAD, FAIL, "call to H5AC_load_cache_image_on_next_protect failed"); } /* end if */ /* Close superblock extension */ @@ -983,8 +959,7 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, bool initial_read) f->shared->sblock = sblock; #endif /* JRM */ if (H5F__super_ext_write_msg(f, H5O_DRVINFO_ID, &drvinfo, false, H5O_MSG_NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, - "error in writing message to superblock extension"); + HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "error in writing message to superblock extension"); #if 1 /* bug fix test code -- tidy this up if all goes well */ /* JRM */ f->shared->sblock = NULL; @@ -996,8 +971,7 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, bool initial_read) else if (H5F_HAS_FEATURE(f, H5FD_FEAT_IGNORE_DRVRINFO)) { /* Remove the driver info message from the superblock extension */ if (H5F__super_ext_remove_msg(f, H5O_DRVINFO_ID) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, - "error in removing message from superblock extension"); + HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "error in removing message from superblock extension"); /* Check if the superblock extension was removed */ if (!H5_addr_defined(sblock->ext_addr)) @@ -1091,7 +1065,7 @@ H5F__super_init(H5F_t *f) /* Allocate space for the superblock */ if (NULL == (sblock = H5FL_CALLOC(H5F_super_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); + HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "memory allocation failed"); /* Initialize various address information */ sblock->base_addr = HADDR_UNDEF; @@ -1101,15 +1075,15 @@ H5F__super_init(H5F_t *f) /* Get the shared file creation property list */ if (NULL == (plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); + HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, FAIL, "not a property list"); /* Initialize sym_leaf_k */ if (H5P_get(plist, H5F_CRT_SYM_LEAF_NAME, &sblock->sym_leaf_k) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get byte number for object size"); + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get byte number for object size"); /* Initialize btree_k */ if (H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, &sblock->btree_k[0]) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get rank for btree internal nodes"); + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get rank for btree internal nodes"); /* Check for non-default free-space settings */ if (!(f->shared->fs_strategy == H5F_FILE_SPACE_STRATEGY_DEF && @@ -1184,9 +1158,9 @@ H5F__super_init(H5F_t *f) H5P_genplist_t *c_plist; /* Property list */ if (NULL == (c_plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not property list"); + HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, FAIL, "not property list"); if (H5P_set(c_plist, H5F_CRT_SUPER_VERS_NAME, &super_vers) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set superblock version"); + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set superblock version"); } /* end if */ if (H5FD_set_paged_aggr(f->shared->lf, (bool)H5F_PAGED_AGGR(f)) < 0) @@ -1209,8 +1183,7 @@ H5F__super_init(H5F_t *f) if (userblock_size < alignment) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "userblock size must be > file object alignment"); if (0 != (userblock_size % alignment)) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, - "userblock size must be an integral multiple of file object alignment"); + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "userblock size must be an integral multiple of file object alignment"); } /* end if */ sblock->base_addr = userblock_size; @@ -1269,9 +1242,8 @@ H5F__super_init(H5F_t *f) H5AC_set_ring(H5AC_RING_SB, &orig_ring); /* Insert superblock into cache, pinned */ - if (H5AC_insert_entry(f, H5AC_SUPERBLOCK, (haddr_t)0, sblock, - H5AC__PIN_ENTRY_FLAG | H5AC__FLUSH_LAST_FLAG | H5AC__FLUSH_COLLECTIVELY_FLAG) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "can't add superblock to cache"); + if (H5AC_insert_entry(f, H5AC_SUPERBLOCK, (haddr_t)0, sblock, H5AC__PIN_ENTRY_FLAG | H5AC__FLUSH_LAST_FLAG | H5AC__FLUSH_COLLECTIVELY_FLAG) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINS, FAIL, "can't add superblock to cache"); sblock_in_cache = true; /* Keep a copy of the superblock info */ @@ -1279,7 +1251,7 @@ H5F__super_init(H5F_t *f) /* Allocate space for the superblock */ if (HADDR_UNDEF == (superblock_addr = H5MF_alloc(f, H5FD_MEM_SUPER, superblock_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for superblock"); + HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "file allocation failed for superblock"); /* set the drvinfo filed to NULL -- will overwrite this later if needed */ f->shared->drvinfo = NULL; @@ -1353,10 +1325,8 @@ H5F__super_init(H5F_t *f) btreek.btree_k[H5B_CHUNK_ID] = sblock->btree_k[H5B_CHUNK_ID]; btreek.btree_k[H5B_SNODE_ID] = sblock->btree_k[H5B_SNODE_ID]; btreek.sym_leaf_k = sblock->sym_leaf_k; - if (H5O_msg_create(&ext_loc, H5O_BTREEK_ID, H5O_MSG_FLAG_CONSTANT | H5O_MSG_FLAG_DONTSHARE, - H5O_UPDATE_TIME, &btreek) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, - "unable to update v1 B-tree 'K' value header message"); + if (H5O_msg_create(&ext_loc, H5O_BTREEK_ID, H5O_MSG_FLAG_CONSTANT | H5O_MSG_FLAG_DONTSHARE, H5O_UPDATE_TIME, &btreek) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to update v1 B-tree 'K' value header message"); } /* end if */ /* Check for driver info to store */ @@ -1404,8 +1374,7 @@ H5F__super_init(H5F_t *f) for (ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; ptype++) fsinfo.fs_addr[ptype - 1] = HADDR_UNDEF; - if (H5O_msg_create(&ext_loc, H5O_FSINFO_ID, H5O_MSG_FLAG_DONTSHARE | H5O_MSG_FLAG_MARK_IF_UNKNOWN, - H5O_UPDATE_TIME, &fsinfo) < 0) + if (H5O_msg_create(&ext_loc, H5O_FSINFO_ID, H5O_MSG_FLAG_DONTSHARE | H5O_MSG_FLAG_MARK_IF_UNKNOWN, H5O_UPDATE_TIME, &fsinfo) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to update free-space info header message"); } /* end if */ } /* end if */ @@ -1417,8 +1386,7 @@ H5F__super_init(H5F_t *f) /* Allocate space for the driver info */ if (NULL == (drvinfo = (H5O_drvinfo_t *)H5MM_calloc(sizeof(H5O_drvinfo_t)))) - HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, - "memory allocation failed for driver info message"); + HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "memory allocation failed for driver info message"); /* Set up driver info message */ /* (NOTE: All the actual information (name & driver information) is @@ -1429,9 +1397,7 @@ H5F__super_init(H5F_t *f) H5_CHECKED_ASSIGN(drvinfo->len, size_t, H5FD_sb_size(f->shared->lf), hsize_t); /* Insert driver info block into cache */ - if (H5AC_insert_entry(f, H5AC_DRVRINFO, sblock->driver_addr, drvinfo, - H5AC__PIN_ENTRY_FLAG | H5AC__FLUSH_LAST_FLAG | - H5AC__FLUSH_COLLECTIVELY_FLAG) < 0) + if (H5AC_insert_entry(f, H5AC_DRVRINFO, sblock->driver_addr, drvinfo, H5AC__PIN_ENTRY_FLAG | H5AC__FLUSH_LAST_FLAG | H5AC__FLUSH_COLLECTIVELY_FLAG) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINS, FAIL, "can't add driver info block to cache"); drvinfo_in_cache = true; f->shared->drvinfo = drvinfo; @@ -1713,13 +1679,12 @@ H5F__super_ext_write_msg(H5F_t *f, unsigned id, void *mesg, bool may_create, uns /* Check if message with ID does not exist in the object header */ if ((status = H5O_msg_exists(&ext_loc, id)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, - "unable to check object header for message or message exists"); + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to check object header for message or message exists"); /* Check for creating vs. writing */ if (may_create) { if (status) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "Message should not exist"); + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "Message should not exist"); /* Create the message with ID in the superblock extension */ if (H5O_msg_create(&ext_loc, id, (mesg_flags | H5O_MSG_FLAG_DONTSHARE), H5O_UPDATE_TIME, mesg) < 0) @@ -1727,7 +1692,7 @@ H5F__super_ext_write_msg(H5F_t *f, unsigned id, void *mesg, bool may_create, uns } /* end if */ else { if (!status) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "Message should exist"); + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "Message should exist"); /* Update the message with ID in the superblock extension */ if (H5O_msg_write(&ext_loc, id, (mesg_flags | H5O_MSG_FLAG_DONTSHARE), H5O_UPDATE_TIME, mesg) < 0) @@ -1784,27 +1749,27 @@ H5F__super_ext_remove_msg(H5F_t *f, unsigned id) /* Check if message with ID exists in the object header */ if ((status = H5O_msg_exists(&ext_loc, id)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to check object header for message"); + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to check object header for message"); else if (status) { /* message exists */ H5O_hdr_info_t hdr_info; /* Object header info for superblock extension */ /* Remove the message */ if (H5O_msg_remove(&ext_loc, id, H5O_ALL, true) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to delete free-space manager info message"); + HGOTO_ERROR(H5E_FILE, H5E_CANTDELETE, FAIL, "unable to delete free-space manager info message"); /* Get info for the superblock extension's object header */ if (H5O_get_hdr_info(&ext_loc, &hdr_info) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to retrieve superblock extension info"); + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to retrieve superblock extension info"); /* If the object header is an empty base chunk, remove superblock extension */ if (hdr_info.nchunks == 1) { if ((null_count = H5O_msg_count(&ext_loc, H5O_NULL_ID)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTCOUNT, FAIL, "unable to count messages"); + HGOTO_ERROR(H5E_FILE, H5E_CANTCOUNT, FAIL, "unable to count messages"); else if ((unsigned)null_count == hdr_info.nmesgs) { assert(H5_addr_defined(ext_loc.addr)); if (H5O_delete(f, ext_loc.addr) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTCOUNT, FAIL, "unable to count messages"); + HGOTO_ERROR(H5E_FILE, H5E_CANTCOUNT, FAIL, "unable to count messages"); f->shared->sblock->ext_addr = HADDR_UNDEF; } /* end else-if */ } /* end if */ diff --git a/src/H5SM.c b/src/H5SM.c index 94f2ea534fc..d70f20e8eda 100644 --- a/src/H5SM.c +++ b/src/H5SM.c @@ -148,8 +148,7 @@ H5SM_init(H5F_t *f, H5P_genplist_t *fc_plist, const H5O_loc_t *ext_loc) type_flags_used = 0; for (x = 0; x < table->num_indexes; ++x) { if (index_type_flags[x] & type_flags_used) - HGOTO_ERROR(H5E_SOHM, H5E_BADVALUE, FAIL, - "the same shared message type flag is assigned to more than one index"); + HGOTO_ERROR(H5E_SOHM, H5E_BADVALUE, FAIL, "the same shared message type flag is assigned to more than one index"); type_flags_used |= index_type_flags[x]; } /* end for */ @@ -167,9 +166,8 @@ H5SM_init(H5F_t *f, H5P_genplist_t *fc_plist, const H5O_loc_t *ext_loc) assert(table->num_indexes > 0 && table->num_indexes <= H5O_SHMESG_MAX_NINDEXES); /* Allocate the SOHM indexes as an array. */ - if (NULL == (table->indexes = - (H5SM_index_header_t *)H5FL_ARR_MALLOC(H5SM_index_header_t, (size_t)table->num_indexes))) - HGOTO_ERROR(H5E_SOHM, H5E_NOSPACE, FAIL, "memory allocation failed for SOHM indexes"); + if (NULL == (table->indexes = (H5SM_index_header_t *)H5FL_ARR_MALLOC(H5SM_index_header_t, (size_t)table->num_indexes))) + HGOTO_ERROR(H5E_SOHM, H5E_CANTALLOC, FAIL, "memory allocation failed for SOHM indexes"); /* Initialize all of the indexes, but don't allocate space for them to * hold messages until we actually need to write to them. @@ -195,7 +193,7 @@ H5SM_init(H5F_t *f, H5P_genplist_t *fc_plist, const H5O_loc_t *ext_loc) /* Allocate space for the table on disk */ if (HADDR_UNDEF == (table_addr = H5MF_alloc(f, H5FD_MEM_SOHM_TABLE, (hsize_t)table->table_size))) - HGOTO_ERROR(H5E_SOHM, H5E_NOSPACE, FAIL, "file allocation failed for SOHM table"); + HGOTO_ERROR(H5E_SOHM, H5E_CANTALLOC, FAIL, "file allocation failed for SOHM table"); /* Cache the new table */ if (H5AC_insert_entry(f, H5AC_SOHM_TABLE, table_addr, table, H5AC__NO_FLAGS_SET) < 0) @@ -217,8 +215,7 @@ H5SM_init(H5F_t *f, H5P_genplist_t *fc_plist, const H5O_loc_t *ext_loc) sohm_table.addr = H5F_SOHM_ADDR(f); sohm_table.version = H5F_SOHM_VERS(f); sohm_table.nindexes = H5F_SOHM_NINDEXES(f); - if (H5O_msg_create(ext_loc, H5O_SHMESG_ID, H5O_MSG_FLAG_CONSTANT | H5O_MSG_FLAG_DONTSHARE, - H5O_UPDATE_TIME, &sohm_table) < 0) + if (H5O_msg_create(ext_loc, H5O_SHMESG_ID, H5O_MSG_FLAG_CONSTANT | H5O_MSG_FLAG_DONTSHARE, H5O_UPDATE_TIME, &sohm_table) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTINIT, FAIL, "unable to update SOHM header message"); done: @@ -288,12 +285,12 @@ H5SM__type_to_flag(unsigned type_id, unsigned *type_flag) * *------------------------------------------------------------------------- */ -ssize_t -H5SM__get_index(const H5SM_master_table_t *table, unsigned type_id) +herr_t +H5SM__get_index(const H5SM_master_table_t *table, unsigned type_id, ssize_t *idx) { - size_t x; unsigned type_flag; - ssize_t ret_value = FAIL; + ssize_t indx = -1; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -304,13 +301,15 @@ H5SM__get_index(const H5SM_master_table_t *table, unsigned type_id) /* Search the indexes until we find one that matches this flag or we've * searched them all. */ - for (x = 0; x < table->num_indexes; ++x) - if (table->indexes[x].mesg_types & type_flag) - HGOTO_DONE((ssize_t)x); + for (size_t x = 0; x < table->num_indexes; ++x) + if (table->indexes[x].mesg_types & type_flag) { + indx = (ssize_t)x; + break; + } + + /* Set output parameter */ + *idx = indx; - /* At this point, ret_value is either the location of the correct - * index or it's still FAIL because we didn't find an index. - */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM__get_index() */ @@ -345,8 +344,7 @@ H5SM_type_shared(H5F_t *f, unsigned type_id) /* Set up user data for callback */ cache_udata.f = f; - if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), - &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table"); } /* end if */ else @@ -396,13 +394,14 @@ H5SM_get_fheap_addr(H5F_t *f, unsigned type_id, haddr_t *fheap_addr) cache_udata.f = f; /* Look up the master SOHM table */ - if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), - &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table"); /* Look up index for message type */ - if ((index_num = H5SM__get_index(table, type_id)) < 0) - HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to find correct SOHM index"); + if (H5SM__get_index(table, type_id, &index_num) < 0) + HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, "unable to check for SOHM index"); + if (index_num < 0) + HGOTO_ERROR(H5E_SOHM, H5E_NOTFOUND, FAIL, "unable to find correct SOHM index"); /* Retrieve heap address for index */ *fheap_addr = table->indexes[index_num].heap_addr; @@ -540,8 +539,7 @@ H5SM__delete_index(H5F_t *f, H5SM_index_header_t *header, bool delete_heap) /* Check the index list's status in the metadata cache */ if (H5AC_get_entry_status(f, header->index_addr, &index_status) < 0) - HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, - "unable to check metadata cache status for direct block"); + HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, "unable to check metadata cache status for direct block"); /* If the index list is in the cache, expunge it now */ if (index_status & H5AC_ES__IN_CACHE) { @@ -611,9 +609,9 @@ H5SM__create_list(H5F_t *f, H5SM_index_header_t *header) /* Allocate list in memory */ if (NULL == (list = H5FL_CALLOC(H5SM_list_t))) - HGOTO_ERROR(H5E_SOHM, H5E_NOSPACE, HADDR_UNDEF, "file allocation failed for SOHM list"); + HGOTO_ERROR(H5E_SOHM, H5E_CANTALLOC, HADDR_UNDEF, "file allocation failed for SOHM list"); if (NULL == (list->messages = (H5SM_sohm_t *)H5FL_ARR_CALLOC(H5SM_sohm_t, num_entries))) - HGOTO_ERROR(H5E_SOHM, H5E_NOSPACE, HADDR_UNDEF, "file allocation failed for SOHM list"); + HGOTO_ERROR(H5E_SOHM, H5E_CANTALLOC, HADDR_UNDEF, "file allocation failed for SOHM list"); /* Initialize messages in list */ for (x = 0; x < num_entries; x++) @@ -624,7 +622,7 @@ H5SM__create_list(H5F_t *f, H5SM_index_header_t *header) /* Allocate space for the list on disk */ if (HADDR_UNDEF == (addr = H5MF_alloc(f, H5FD_MEM_SOHM_INDEX, (hsize_t)header->list_size))) - HGOTO_ERROR(H5E_SOHM, H5E_NOSPACE, HADDR_UNDEF, "file allocation failed for SOHM list"); + HGOTO_ERROR(H5E_SOHM, H5E_CANTALLOC, HADDR_UNDEF, "file allocation failed for SOHM list"); /* Put the list into the cache */ if (H5AC_insert_entry(f, H5AC_SOHM_LIST, addr, list, H5AC__NO_FLAGS_SET) < 0) @@ -731,8 +729,7 @@ H5SM__convert_list_to_btree(H5F_t *f, H5SM_index_header_t *header, H5SM_list_t * } /* end for */ /* Unprotect list in cache and release heap */ - if (H5AC_unprotect(f, H5AC_SOHM_LIST, header->index_addr, list, - H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) + if (H5AC_unprotect(f, H5AC_SOHM_LIST, header->index_addr, list, H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to release SOHM list"); *_list = list = NULL; @@ -834,8 +831,7 @@ H5SM__convert_btree_to_list(H5F_t *f, H5SM_index_header_t *header) cache_udata.header = header; /* Protect the SOHM list */ - if (NULL == (list = (H5SM_list_t *)H5AC_protect(f, H5AC_SOHM_LIST, header->index_addr, &cache_udata, - H5AC__NO_FLAGS_SET))) + if (NULL == (list = (H5SM_list_t *)H5AC_protect(f, H5AC_SOHM_LIST, header->index_addr, &cache_udata, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM list index"); /* Delete the B-tree and have messages copy themselves to the @@ -935,18 +931,17 @@ H5SM_can_share(H5F_t *f, H5SM_master_table_t *table, ssize_t *sohm_index_num, un /* Set up user data for callback */ cache_udata.f = f; - if (NULL == (my_table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), - &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (my_table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table"); } /* end if */ /* Find the right index for this message type. If there is no such index * then this type of message isn't shareable */ - if ((index_num = H5SM__get_index(my_table, type_id)) < 0) { - H5E_clear_stack(); /*ignore error*/ + if (H5SM__get_index(my_table, type_id, &index_num) < 0) + HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, "unable to check for SOHM index"); + if (index_num < 0) HGOTO_DONE(false); - } /* end if */ /* If the message isn't big enough, don't bother sharing it */ if (0 == (mesg_size = H5O_msg_raw_size(f, type_id, true, mesg))) @@ -960,8 +955,7 @@ H5SM_can_share(H5F_t *f, H5SM_master_table_t *table, ssize_t *sohm_index_num, un done: /* Release the master SOHM table, if we protected it */ - if (my_table && my_table != table && - H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), my_table, H5AC__NO_FLAGS_SET) < 0) + if (my_table && my_table != table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), my_table, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table"); FUNC_LEAVE_NOAPI_TAG(ret_value) @@ -1065,8 +1059,7 @@ H5SM_try_share(H5F_t *f, H5O_t *open_oh, unsigned defer_flags, unsigned type_id, cache_udata.f = f; /* Look up the master SOHM table */ - if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), - &cache_udata, H5AC__NO_FLAGS_SET))) + if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), &cache_udata, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table"); /* "complex" sharing checks */ @@ -1234,7 +1227,7 @@ H5SM__write_mesg(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, bool def if ((buf_size = H5O_msg_raw_size(f, type_id, true, mesg)) == 0) HGOTO_ERROR(H5E_SOHM, H5E_BADSIZE, FAIL, "can't find message size"); if (NULL == (encoding_buf = H5MM_malloc(buf_size))) - HGOTO_ERROR(H5E_SOHM, H5E_NOSPACE, FAIL, "can't allocate buffer for encoding"); + HGOTO_ERROR(H5E_SOHM, H5E_CANTALLOC, FAIL, "can't allocate buffer for encoding"); if (H5O_msg_encode(f, type_id, true, (unsigned char *)encoding_buf, mesg) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTENCODE, FAIL, "can't encode message to be shared"); @@ -1262,8 +1255,7 @@ H5SM__write_mesg(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, bool def cache_udata.header = header; /* The index is a list; get it from the cache */ - if (NULL == (list = (H5SM_list_t *)H5AC_protect(f, H5AC_SOHM_LIST, header->index_addr, &cache_udata, - defer ? H5AC__READ_ONLY_FLAG : H5AC__NO_FLAGS_SET))) + if (NULL == (list = (H5SM_list_t *)H5AC_protect(f, H5AC_SOHM_LIST, header->index_addr, &cache_udata, defer ? H5AC__READ_ONLY_FLAG : H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM index"); /* See if the message is already in the index and get its location. @@ -1451,8 +1443,7 @@ H5SM__write_mesg(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, bool def /* Open the index v2 B-tree, if it isn't already */ if (NULL == bt2) { if (NULL == (bt2 = H5B2_open(f, header->index_addr, f))) - HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, - "unable to open v2 B-tree for SOHM index"); + HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for SOHM index"); } /* end if */ if (H5B2_insert(bt2, &key) < 0) @@ -1480,8 +1471,7 @@ H5SM__write_mesg(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, bool def HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for SOHM index"); /* If we got a list out of the cache, release it (it is always dirty after writing a message) */ - if (list && H5AC_unprotect(f, H5AC_SOHM_LIST, header->index_addr, list, - defer ? H5AC__NO_FLAGS_SET : H5AC__DIRTIED_FLAG) < 0) + if (list && H5AC_unprotect(f, H5AC_SOHM_LIST, header->index_addr, list, defer ? H5AC__NO_FLAGS_SET : H5AC__DIRTIED_FLAG) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM index"); if (encoding_buf) @@ -1531,20 +1521,20 @@ H5SM_delete(H5F_t *f, H5O_t *open_oh, H5O_shared_t *sh_mesg) cache_udata.f = f; /* Look up the master SOHM table */ - if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), - &cache_udata, H5AC__NO_FLAGS_SET))) + if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), &cache_udata, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table"); /* Find the correct index and try to delete from it */ - if ((index_num = H5SM__get_index(table, type_id)) < 0) + if (H5SM__get_index(table, type_id, &index_num) < 0) + HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, "unable to check for SOHM index"); + if (index_num < 0) HGOTO_ERROR(H5E_SOHM, H5E_NOTFOUND, FAIL, "unable to find correct SOHM index"); /* If mesg_buf is not NULL, the message's reference count has reached * zero and any file space it uses needs to be freed. mesg_buf holds the * serialized form of the message. */ - if (H5SM__delete_from_index(f, open_oh, &(table->indexes[index_num]), sh_mesg, &cache_flags, &mesg_size, - &mesg_buf) < 0) + if (H5SM__delete_from_index(f, open_oh, &(table->indexes[index_num]), sh_mesg, &cache_flags, &mesg_size, &mesg_buf) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTDELETE, FAIL, "unable to delete message from SOHM index"); /* Release the master SOHM table */ @@ -1557,8 +1547,7 @@ H5SM_delete(H5F_t *f, H5O_t *open_oh, H5O_shared_t *sh_mesg) * master table needs to be unprotected when we do this. */ if (mesg_buf) { - if (NULL == - (native_mesg = H5O_msg_decode(f, open_oh, type_id, mesg_size, (const unsigned char *)mesg_buf))) + if (NULL == (native_mesg = H5O_msg_decode(f, open_oh, type_id, mesg_size, (const unsigned char *)mesg_buf))) HGOTO_ERROR(H5E_SOHM, H5E_CANTDECODE, FAIL, "can't decode shared message."); if (H5O_msg_delete(f, open_oh, type_id, native_mesg) < 0) @@ -1774,8 +1763,7 @@ H5SM__delete_from_index(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, c cache_udata.header = header; /* If the index is stored as a list, get it from the cache */ - if (NULL == (list = (H5SM_list_t *)H5AC_protect(f, H5AC_SOHM_LIST, header->index_addr, &cache_udata, - H5AC__NO_FLAGS_SET))) + if (NULL == (list = (H5SM_list_t *)H5AC_protect(f, H5AC_SOHM_LIST, header->index_addr, &cache_udata, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM index"); /* Find the message in the list */ @@ -1846,8 +1834,7 @@ H5SM__delete_from_index(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, c if (header->num_messages == 0) { /* Unprotect cache and release heap */ - if (list && H5AC_unprotect(f, H5AC_SOHM_LIST, header->index_addr, list, - H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) + if (list && H5AC_unprotect(f, H5AC_SOHM_LIST, header->index_addr, list, H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to release SOHM list"); list = NULL; @@ -1951,8 +1938,7 @@ H5SM_get_info(const H5O_loc_t *ext_loc, H5P_genplist_t *fc_plist) H5AC_set_ring(H5AC_RING_USER, &orig_ring); /* Read the rest of the SOHM table information from the cache */ - if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), - &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table"); /* Get index conversion limits */ @@ -2105,12 +2091,13 @@ H5SM_get_refcount(H5F_t *f, unsigned type_id, const H5O_shared_t *sh_mesg, hsize tbl_cache_udata.f = f; /* Look up the master SOHM table */ - if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), - &tbl_cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), &tbl_cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table"); /* Find the correct index and find the message in it */ - if ((index_num = H5SM__get_index(table, type_id)) < 0) + if (H5SM__get_index(table, type_id, &index_num) < 0) + HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, "unable to check for SOHM index"); + if (index_num < 0) HGOTO_ERROR(H5E_SOHM, H5E_NOTFOUND, FAIL, "unable to find correct SOHM index"); header = &(table->indexes[index_num]); @@ -2144,8 +2131,7 @@ H5SM_get_refcount(H5F_t *f, unsigned type_id, const H5O_shared_t *sh_mesg, hsize lst_cache_udata.header = header; /* If the index is stored as a list, get it from the cache */ - if (NULL == (list = (H5SM_list_t *)H5AC_protect(f, H5AC_SOHM_LIST, header->index_addr, - &lst_cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (list = (H5SM_list_t *)H5AC_protect(f, H5AC_SOHM_LIST, header->index_addr, &lst_cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM index"); /* Find the message in the list */ @@ -2232,8 +2218,7 @@ H5SM__read_iter_op(H5O_t *oh, H5O_mesg_t *mesg /*in,out*/, unsigned sequence, /* Check if the message is dirty & flush it to the object header if so */ if (mesg->dirty) if (H5O_msg_flush(udata->file, oh, mesg) < 0) - HGOTO_ERROR(H5E_SOHM, H5E_CANTENCODE, H5_ITER_ERROR, - "unable to encode object header message"); + HGOTO_ERROR(H5E_SOHM, H5E_CANTENCODE, H5_ITER_ERROR, "unable to encode object header message"); /* Get the message's encoded size */ udata->buf_size = mesg->raw_size; @@ -2241,7 +2226,7 @@ H5SM__read_iter_op(H5O_t *oh, H5O_mesg_t *mesg /*in,out*/, unsigned sequence, /* Allocate buffer to return the message in */ if (NULL == (udata->encoding_buf = H5MM_malloc(udata->buf_size))) - HGOTO_ERROR(H5E_SOHM, H5E_NOSPACE, H5_ITER_ERROR, "memory allocation failed"); + HGOTO_ERROR(H5E_SOHM, H5E_CANTALLOC, H5_ITER_ERROR, "memory allocation failed"); /* Copy the encoded message into the buffer to return */ H5MM_memcpy(udata->encoding_buf, mesg->raw, udata->buf_size); @@ -2275,7 +2260,7 @@ H5SM__read_mesg_fh_cb(const void *obj, size_t obj_len, void *_udata) /* Allocate a buffer to hold the message */ if (NULL == (udata->encoding_buf = H5MM_malloc(obj_len))) - HGOTO_ERROR(H5E_SOHM, H5E_NOSPACE, FAIL, "memory allocation failed"); + HGOTO_ERROR(H5E_SOHM, H5E_CANTALLOC, FAIL, "memory allocation failed"); /* Copy the message from the heap */ H5MM_memcpy(udata->encoding_buf, obj, obj_len); @@ -2475,15 +2460,13 @@ H5SM_table_debug(H5F_t *f, haddr_t table_addr, FILE *stream, int indent, int fwi if (table_vers > HDF5_SHAREDHEADER_VERSION) HGOTO_ERROR(H5E_SOHM, H5E_BADVALUE, FAIL, "unknown shared message table version"); if (num_indexes == 0 || num_indexes > H5O_SHMESG_MAX_NINDEXES) - HGOTO_ERROR(H5E_SOHM, H5E_BADVALUE, FAIL, - "number of indexes must be between 1 and H5O_SHMESG_MAX_NINDEXES"); + HGOTO_ERROR(H5E_SOHM, H5E_BADVALUE, FAIL, "number of indexes must be between 1 and H5O_SHMESG_MAX_NINDEXES"); /* Set up user data for callback */ cache_udata.f = f; /* Look up the master SOHM table */ - if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, table_addr, &cache_udata, - H5AC__READ_ONLY_FLAG))) + if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, table_addr, &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table"); fprintf(stream, "%*sShared Message Master Table...\n", indent, ""); @@ -2552,8 +2535,7 @@ H5SM_list_debug(H5F_t *f, haddr_t list_addr, FILE *stream, int indent, int fwidt tbl_cache_udata.f = f; /* Look up the master SOHM table */ - if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, table_addr, &tbl_cache_udata, - H5AC__READ_ONLY_FLAG))) + if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, table_addr, &tbl_cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table"); /* Determine which index the list is part of */ @@ -2565,16 +2547,14 @@ H5SM_list_debug(H5F_t *f, haddr_t list_addr, FILE *stream, int indent, int fwidt } /* end if */ } /* end for */ if (x == table->num_indexes) - HGOTO_ERROR(H5E_SOHM, H5E_BADVALUE, FAIL, - "list address doesn't match address for any indices in table"); + HGOTO_ERROR(H5E_SOHM, H5E_BADVALUE, FAIL, "list address doesn't match address for any indices in table"); /* Set up user data for metadata cache callback */ lst_cache_udata.f = f; lst_cache_udata.header = &(table->indexes[index_num]); /* Get the list from the cache */ - if (NULL == (list = (H5SM_list_t *)H5AC_protect(f, H5AC_SOHM_LIST, list_addr, &lst_cache_udata, - H5AC__READ_ONLY_FLAG))) + if (NULL == (list = (H5SM_list_t *)H5AC_protect(f, H5AC_SOHM_LIST, list_addr, &lst_cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM index"); /* Open the heap, if one exists */ @@ -2655,8 +2635,7 @@ H5SM_ih_size(H5F_t *f, hsize_t *hdr_size, H5_ih_info_t *ih_info) cache_udata.f = f; /* Look up the master SOHM table */ - if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), - &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table"); /* Get SOHM header size */ diff --git a/src/H5SMpkg.h b/src/H5SMpkg.h index 439954a1db3..4ff4c7da81f 100644 --- a/src/H5SMpkg.h +++ b/src/H5SMpkg.h @@ -252,7 +252,7 @@ H5_DLLVAR const H5B2_class_t H5SM_INDEX[1]; /****************************/ /* General routines */ -H5_DLL ssize_t H5SM__get_index(const H5SM_master_table_t *table, unsigned type_id); +H5_DLL herr_t H5SM__get_index(const H5SM_master_table_t *table, unsigned type_id, ssize_t *idx); /* Encode and decode routines, used for B-tree and cache encoding/decoding */ H5_DLL herr_t H5SM__message_compare(const void *rec1, const void *rec2, int *result); diff --git a/src/H5SMtest.c b/src/H5SMtest.c index bde1d1d5e9c..19e248fd493 100644 --- a/src/H5SMtest.c +++ b/src/H5SMtest.c @@ -81,12 +81,13 @@ H5SM__get_mesg_count_test(H5F_t *f, unsigned type_id, size_t *mesg_count) cache_udata.f = f; /* Look up the master SOHM table */ - if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), - &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table"); /* Find the correct index for this message type */ - if ((index_num = H5SM__get_index(table, type_id)) < 0) + if (H5SM__get_index(table, type_id, &index_num) < 0) + HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, "unable to check for SOHM index"); + if (index_num < 0) HGOTO_ERROR(H5E_SOHM, H5E_NOTFOUND, FAIL, "unable to find correct SOHM index"); header = &(table->indexes[index_num]); From 1e7c9fd08b243843171c3fd2a4541acb4284dae7 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 12 Jul 2024 20:59:49 +0000 Subject: [PATCH 2/4] Committing clang-format changes --- src/H5FDfamily.c | 18 ++++++---- src/H5Fsuper.c | 81 ++++++++++++++++++++++++++++-------------- src/H5SM.c | 91 +++++++++++++++++++++++++++++++----------------- src/H5SMtest.c | 3 +- 4 files changed, 128 insertions(+), 65 deletions(-) diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c index ecb7de68539..642da8d0b66 100644 --- a/src/H5FDfamily.c +++ b/src/H5FDfamily.c @@ -771,13 +771,15 @@ H5FD__family_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxad * Allow H5F_ACC_CREAT only on the first family member. */ if (0 == file->nmembs) { - if (NULL == (file->memb[file->nmembs] = H5FDopen(memb_name, (0 == file->nmembs ? flags : t_flags), file->memb_fapl_id, HADDR_UNDEF))) + if (NULL == (file->memb[file->nmembs] = H5FDopen(memb_name, (0 == file->nmembs ? flags : t_flags), + file->memb_fapl_id, HADDR_UNDEF))) HGOTO_ERROR(H5E_VFL, H5E_CANTOPENFILE, NULL, "unable to open member file"); } else { H5E_PAUSE_ERRORS { - file->memb[file->nmembs] = H5FDopen(memb_name, (0 == file->nmembs ? flags : t_flags), file->memb_fapl_id, HADDR_UNDEF); + file->memb[file->nmembs] = H5FDopen(memb_name, (0 == file->nmembs ? flags : t_flags), + file->memb_fapl_id, HADDR_UNDEF); } H5E_RESUME_ERRORS @@ -1019,7 +1021,8 @@ H5FD__family_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t abs_eoa) file->nmembs = MAX(file->nmembs, u + 1); snprintf(memb_name, H5FD_FAM_MEMB_NAME_BUF_SIZE, file->name, u); H5_CHECK_OVERFLOW(file->memb_size, hsize_t, haddr_t); - if (NULL == (file->memb[u] = H5FDopen(memb_name, file->flags | H5F_ACC_CREAT, file->memb_fapl_id, (haddr_t)file->memb_size))) + if (NULL == (file->memb[u] = H5FDopen(memb_name, file->flags | H5F_ACC_CREAT, file->memb_fapl_id, + (haddr_t)file->memb_size))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to open member file"); } /* end if */ @@ -1415,9 +1418,9 @@ H5FD__family_delete(const char *filename, hid_t fapl_id) bool default_config = false; hid_t memb_fapl_id = H5I_INVALID_HID; unsigned current_member; - char *member_name = NULL; - char *temp = NULL; - herr_t ret_value = SUCCEED; + char *member_name = NULL; + char *temp = NULL; + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -1465,7 +1468,8 @@ H5FD__family_delete(const char *filename, hid_t fapl_id) filename = temp; } else - HGOTO_ERROR(H5E_VFL, H5E_CANTDELETEFILE, FAIL, "provided file name cannot generate unique sub-files"); + HGOTO_ERROR(H5E_VFL, H5E_CANTDELETEFILE, FAIL, + "provided file name cannot generate unique sub-files"); } /* Delete all the family members */ diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c index 72b53866cac..6c4e7d57ef2 100644 --- a/src/H5Fsuper.c +++ b/src/H5Fsuper.c @@ -101,7 +101,9 @@ H5F__super_ext_create(H5F_t *f, H5O_loc_t *ext_ptr) /* Check for older version of superblock format that can't support superblock extensions */ if (f->shared->sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) - HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, "superblock extension not permitted with version %u of superblock", f->shared->sblock->super_vers); + HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, + "superblock extension not permitted with version %u of superblock", + f->shared->sblock->super_vers); else if (H5_addr_defined(f->shared->sblock->ext_addr)) HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, "superblock extension already exists?!?!"); else { @@ -274,8 +276,10 @@ H5F__update_super_ext_driver_msg(H5F_t *f) */ drvinfo.len = driver_size; drvinfo.buf = dbuf; - if (H5F__super_ext_write_msg(f, H5O_DRVINFO_ID, &drvinfo, false, H5O_MSG_NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "unable to update driver info header message"); + if (H5F__super_ext_write_msg(f, H5O_DRVINFO_ID, &drvinfo, false, H5O_MSG_NO_FLAGS_SET) < + 0) + HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, + "unable to update driver info header message"); } /* end if driver_size > 0 */ } /* end if !H5F_HAS_FEATURE(f, H5FD_FEAT_IGNORE_DRVRINFO) */ } /* end if superblock extension exists */ @@ -307,7 +311,7 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, bool initial_read) H5P_genplist_t *c_plist; /* File creation property list */ H5FD_t *file; /* File driver pointer */ unsigned sblock_flags = H5AC__NO_FLAGS_SET; /* flags used in superblock unprotect call */ - haddr_t super_addr = HADDR_UNDEF; /* Absolute address of superblock */ + haddr_t super_addr = HADDR_UNDEF; /* Absolute address of superblock */ haddr_t eof; /* End of file address */ unsigned rw_flags; /* Read/write permissions for file */ bool skip_eof_check = false; /* Whether to skip checking the EOF value */ @@ -585,7 +589,10 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, bool initial_read) /* (Account for the stored EOA being absolute offset -QAK) */ if ((eof + sblock->base_addr) < udata.stored_eof) - HGOTO_ERROR(H5E_FILE, H5E_TRUNCATED, FAIL, "truncated file: eof = %llu, sblock->base_addr = %llu, stored_eof = %llu", (unsigned long long)eof, (unsigned long long)sblock->base_addr, (unsigned long long)udata.stored_eof); + HGOTO_ERROR(H5E_FILE, H5E_TRUNCATED, FAIL, + "truncated file: eof = %llu, sblock->base_addr = %llu, stored_eof = %llu", + (unsigned long long)eof, (unsigned long long)sblock->base_addr, + (unsigned long long)udata.stored_eof); } /* @@ -614,11 +621,13 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, bool initial_read) /* extend EOA so we can read at least the fixed sized * portion of the driver info block */ - if (H5FD_set_eoa(f->shared->lf, H5FD_MEM_SUPER, sblock->driver_addr + H5F_DRVINFOBLOCK_HDR_SIZE) < 0) /* will extend eoa later if required */ + if (H5FD_set_eoa(f->shared->lf, H5FD_MEM_SUPER, sblock->driver_addr + H5F_DRVINFOBLOCK_HDR_SIZE) < + 0) /* will extend eoa later if required */ HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "set end of space allocation request failed"); /* Look up the driver info block */ - if (NULL == (drvinfo = (H5O_drvinfo_t *)H5AC_protect(f, H5AC_DRVRINFO, sblock->driver_addr, &drvrinfo_udata, rw_flags))) + if (NULL == (drvinfo = (H5O_drvinfo_t *)H5AC_protect(f, H5AC_DRVRINFO, sblock->driver_addr, + &drvrinfo_udata, rw_flags))) HGOTO_ERROR(H5E_FILE, H5E_CANTPROTECT, FAIL, "unable to load driver info block"); /* Loading the driver info block is enough to set up the right info */ @@ -656,7 +665,8 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, bool initial_read) * superblock version >= 2. */ if (sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "invalid superblock - extension message should not be defined for version < 2"); + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, + "invalid superblock - extension message should not be defined for version < 2"); /* Check for superblock extension being located "outside" the stored * 'eoa' value, which can occur with the split/multi VFD. @@ -731,7 +741,8 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, bool initial_read) /* Get message flags */ if (H5O_msg_get_flags(&ext_loc, H5O_FSINFO_ID, &flags) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to message flags for free-space manager info message"); + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, + "unable to message flags for free-space manager info message"); /* If message is NOT marked "unknown"--set up file space info */ if (!(flags & H5O_MSG_FLAG_WAS_UNKNOWN)) { @@ -743,7 +754,8 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, bool initial_read) */ if (H5P_exist_plist(fa_plist, H5F_ACS_NULL_FSM_ADDR_NAME) > 0) if (H5P_get(fa_plist, H5F_ACS_NULL_FSM_ADDR_NAME, &f->shared->null_fsm_addr) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get clearance for persisting fsm addr"); + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, + "can't get clearance for persisting fsm addr"); /* Retrieve the 'file space info' structure */ if (NULL == H5O_msg_read(&ext_loc, H5O_FSINFO_ID, &fsinfo)) @@ -751,7 +763,8 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, bool initial_read) /* Version bounds check */ if (H5O_fsinfo_check_version(H5F_HIGH_BOUND(f), &fsinfo) < 0) - HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, FAIL, "File space info message's version out of bounds"); + HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, FAIL, + "File space info message's version out of bounds"); /* Update changed values */ if (f->shared->fs_version != fsinfo.version) @@ -864,7 +877,8 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, bool initial_read) if (f->shared->null_fsm_addr) { if (H5F__super_ext_write_msg(f, H5O_FSINFO_ID, &fsinfo, false, H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0) - HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "error in writing fsinfo message to superblock extension"); + HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, + "error in writing fsinfo message to superblock extension"); } else { if (H5F__super_ext_remove_msg(f, H5O_FSINFO_ID) < 0) { @@ -872,11 +886,14 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, bool initial_read) f->shared->sblock = NULL; #endif /* JRM */ - HGOTO_ERROR(H5E_FILE, H5E_CANTDELETE, FAIL, "error in removing message from superblock extension"); + HGOTO_ERROR(H5E_FILE, H5E_CANTDELETE, FAIL, + "error in removing message from superblock extension"); } - if (H5F__super_ext_write_msg(f, H5O_FSINFO_ID, &fsinfo, true, H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0) - HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "error in writing fsinfo message to superblock extension"); + if (H5F__super_ext_write_msg(f, H5O_FSINFO_ID, &fsinfo, true, + H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0) + HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, + "error in writing fsinfo message to superblock extension"); } #if 1 /* bug fix test code -- tidy this up if all goes well */ /* JRM */ f->shared->sblock = NULL; @@ -911,7 +928,8 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, bool initial_read) /* Indicate to the cache that there's an image to load on first protect call */ if (H5AC_load_cache_image_on_next_protect(f, mdci_msg.addr, mdci_msg.size, rw) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTLOAD, FAIL, "call to H5AC_load_cache_image_on_next_protect failed"); + HGOTO_ERROR(H5E_FILE, H5E_CANTLOAD, FAIL, + "call to H5AC_load_cache_image_on_next_protect failed"); } /* end if */ /* Close superblock extension */ @@ -959,7 +977,8 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, bool initial_read) f->shared->sblock = sblock; #endif /* JRM */ if (H5F__super_ext_write_msg(f, H5O_DRVINFO_ID, &drvinfo, false, H5O_MSG_NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "error in writing message to superblock extension"); + HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, + "error in writing message to superblock extension"); #if 1 /* bug fix test code -- tidy this up if all goes well */ /* JRM */ f->shared->sblock = NULL; @@ -971,7 +990,8 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, bool initial_read) else if (H5F_HAS_FEATURE(f, H5FD_FEAT_IGNORE_DRVRINFO)) { /* Remove the driver info message from the superblock extension */ if (H5F__super_ext_remove_msg(f, H5O_DRVINFO_ID) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "error in removing message from superblock extension"); + HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, + "error in removing message from superblock extension"); /* Check if the superblock extension was removed */ if (!H5_addr_defined(sblock->ext_addr)) @@ -1183,7 +1203,8 @@ H5F__super_init(H5F_t *f) if (userblock_size < alignment) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "userblock size must be > file object alignment"); if (0 != (userblock_size % alignment)) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "userblock size must be an integral multiple of file object alignment"); + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, + "userblock size must be an integral multiple of file object alignment"); } /* end if */ sblock->base_addr = userblock_size; @@ -1242,7 +1263,8 @@ H5F__super_init(H5F_t *f) H5AC_set_ring(H5AC_RING_SB, &orig_ring); /* Insert superblock into cache, pinned */ - if (H5AC_insert_entry(f, H5AC_SUPERBLOCK, (haddr_t)0, sblock, H5AC__PIN_ENTRY_FLAG | H5AC__FLUSH_LAST_FLAG | H5AC__FLUSH_COLLECTIVELY_FLAG) < 0) + if (H5AC_insert_entry(f, H5AC_SUPERBLOCK, (haddr_t)0, sblock, + H5AC__PIN_ENTRY_FLAG | H5AC__FLUSH_LAST_FLAG | H5AC__FLUSH_COLLECTIVELY_FLAG) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINS, FAIL, "can't add superblock to cache"); sblock_in_cache = true; @@ -1325,8 +1347,10 @@ H5F__super_init(H5F_t *f) btreek.btree_k[H5B_CHUNK_ID] = sblock->btree_k[H5B_CHUNK_ID]; btreek.btree_k[H5B_SNODE_ID] = sblock->btree_k[H5B_SNODE_ID]; btreek.sym_leaf_k = sblock->sym_leaf_k; - if (H5O_msg_create(&ext_loc, H5O_BTREEK_ID, H5O_MSG_FLAG_CONSTANT | H5O_MSG_FLAG_DONTSHARE, H5O_UPDATE_TIME, &btreek) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to update v1 B-tree 'K' value header message"); + if (H5O_msg_create(&ext_loc, H5O_BTREEK_ID, H5O_MSG_FLAG_CONSTANT | H5O_MSG_FLAG_DONTSHARE, + H5O_UPDATE_TIME, &btreek) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, + "unable to update v1 B-tree 'K' value header message"); } /* end if */ /* Check for driver info to store */ @@ -1374,7 +1398,8 @@ H5F__super_init(H5F_t *f) for (ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; ptype++) fsinfo.fs_addr[ptype - 1] = HADDR_UNDEF; - if (H5O_msg_create(&ext_loc, H5O_FSINFO_ID, H5O_MSG_FLAG_DONTSHARE | H5O_MSG_FLAG_MARK_IF_UNKNOWN, H5O_UPDATE_TIME, &fsinfo) < 0) + if (H5O_msg_create(&ext_loc, H5O_FSINFO_ID, H5O_MSG_FLAG_DONTSHARE | H5O_MSG_FLAG_MARK_IF_UNKNOWN, + H5O_UPDATE_TIME, &fsinfo) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to update free-space info header message"); } /* end if */ } /* end if */ @@ -1386,7 +1411,8 @@ H5F__super_init(H5F_t *f) /* Allocate space for the driver info */ if (NULL == (drvinfo = (H5O_drvinfo_t *)H5MM_calloc(sizeof(H5O_drvinfo_t)))) - HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "memory allocation failed for driver info message"); + HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, + "memory allocation failed for driver info message"); /* Set up driver info message */ /* (NOTE: All the actual information (name & driver information) is @@ -1397,7 +1423,9 @@ H5F__super_init(H5F_t *f) H5_CHECKED_ASSIGN(drvinfo->len, size_t, H5FD_sb_size(f->shared->lf), hsize_t); /* Insert driver info block into cache */ - if (H5AC_insert_entry(f, H5AC_DRVRINFO, sblock->driver_addr, drvinfo, H5AC__PIN_ENTRY_FLAG | H5AC__FLUSH_LAST_FLAG | H5AC__FLUSH_COLLECTIVELY_FLAG) < 0) + if (H5AC_insert_entry(f, H5AC_DRVRINFO, sblock->driver_addr, drvinfo, + H5AC__PIN_ENTRY_FLAG | H5AC__FLUSH_LAST_FLAG | + H5AC__FLUSH_COLLECTIVELY_FLAG) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINS, FAIL, "can't add driver info block to cache"); drvinfo_in_cache = true; f->shared->drvinfo = drvinfo; @@ -1679,7 +1707,8 @@ H5F__super_ext_write_msg(H5F_t *f, unsigned id, void *mesg, bool may_create, uns /* Check if message with ID does not exist in the object header */ if ((status = H5O_msg_exists(&ext_loc, id)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to check object header for message or message exists"); + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, + "unable to check object header for message or message exists"); /* Check for creating vs. writing */ if (may_create) { diff --git a/src/H5SM.c b/src/H5SM.c index d70f20e8eda..24a8aef5403 100644 --- a/src/H5SM.c +++ b/src/H5SM.c @@ -148,7 +148,8 @@ H5SM_init(H5F_t *f, H5P_genplist_t *fc_plist, const H5O_loc_t *ext_loc) type_flags_used = 0; for (x = 0; x < table->num_indexes; ++x) { if (index_type_flags[x] & type_flags_used) - HGOTO_ERROR(H5E_SOHM, H5E_BADVALUE, FAIL, "the same shared message type flag is assigned to more than one index"); + HGOTO_ERROR(H5E_SOHM, H5E_BADVALUE, FAIL, + "the same shared message type flag is assigned to more than one index"); type_flags_used |= index_type_flags[x]; } /* end for */ @@ -166,7 +167,8 @@ H5SM_init(H5F_t *f, H5P_genplist_t *fc_plist, const H5O_loc_t *ext_loc) assert(table->num_indexes > 0 && table->num_indexes <= H5O_SHMESG_MAX_NINDEXES); /* Allocate the SOHM indexes as an array. */ - if (NULL == (table->indexes = (H5SM_index_header_t *)H5FL_ARR_MALLOC(H5SM_index_header_t, (size_t)table->num_indexes))) + if (NULL == (table->indexes = + (H5SM_index_header_t *)H5FL_ARR_MALLOC(H5SM_index_header_t, (size_t)table->num_indexes))) HGOTO_ERROR(H5E_SOHM, H5E_CANTALLOC, FAIL, "memory allocation failed for SOHM indexes"); /* Initialize all of the indexes, but don't allocate space for them to @@ -215,7 +217,8 @@ H5SM_init(H5F_t *f, H5P_genplist_t *fc_plist, const H5O_loc_t *ext_loc) sohm_table.addr = H5F_SOHM_ADDR(f); sohm_table.version = H5F_SOHM_VERS(f); sohm_table.nindexes = H5F_SOHM_NINDEXES(f); - if (H5O_msg_create(ext_loc, H5O_SHMESG_ID, H5O_MSG_FLAG_CONSTANT | H5O_MSG_FLAG_DONTSHARE, H5O_UPDATE_TIME, &sohm_table) < 0) + if (H5O_msg_create(ext_loc, H5O_SHMESG_ID, H5O_MSG_FLAG_CONSTANT | H5O_MSG_FLAG_DONTSHARE, + H5O_UPDATE_TIME, &sohm_table) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTINIT, FAIL, "unable to update SOHM header message"); done: @@ -289,8 +292,8 @@ herr_t H5SM__get_index(const H5SM_master_table_t *table, unsigned type_id, ssize_t *idx) { unsigned type_flag; - ssize_t indx = -1; - herr_t ret_value = SUCCEED; /* Return value */ + ssize_t indx = -1; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -344,7 +347,8 @@ H5SM_type_shared(H5F_t *f, unsigned type_id) /* Set up user data for callback */ cache_udata.f = f; - if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), + &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table"); } /* end if */ else @@ -394,7 +398,8 @@ H5SM_get_fheap_addr(H5F_t *f, unsigned type_id, haddr_t *fheap_addr) cache_udata.f = f; /* Look up the master SOHM table */ - if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), + &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table"); /* Look up index for message type */ @@ -539,7 +544,8 @@ H5SM__delete_index(H5F_t *f, H5SM_index_header_t *header, bool delete_heap) /* Check the index list's status in the metadata cache */ if (H5AC_get_entry_status(f, header->index_addr, &index_status) < 0) - HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, "unable to check metadata cache status for direct block"); + HGOTO_ERROR(H5E_SOHM, H5E_CANTGET, FAIL, + "unable to check metadata cache status for direct block"); /* If the index list is in the cache, expunge it now */ if (index_status & H5AC_ES__IN_CACHE) { @@ -729,7 +735,8 @@ H5SM__convert_list_to_btree(H5F_t *f, H5SM_index_header_t *header, H5SM_list_t * } /* end for */ /* Unprotect list in cache and release heap */ - if (H5AC_unprotect(f, H5AC_SOHM_LIST, header->index_addr, list, H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) + if (H5AC_unprotect(f, H5AC_SOHM_LIST, header->index_addr, list, + H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to release SOHM list"); *_list = list = NULL; @@ -831,7 +838,8 @@ H5SM__convert_btree_to_list(H5F_t *f, H5SM_index_header_t *header) cache_udata.header = header; /* Protect the SOHM list */ - if (NULL == (list = (H5SM_list_t *)H5AC_protect(f, H5AC_SOHM_LIST, header->index_addr, &cache_udata, H5AC__NO_FLAGS_SET))) + if (NULL == (list = (H5SM_list_t *)H5AC_protect(f, H5AC_SOHM_LIST, header->index_addr, &cache_udata, + H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM list index"); /* Delete the B-tree and have messages copy themselves to the @@ -931,7 +939,8 @@ H5SM_can_share(H5F_t *f, H5SM_master_table_t *table, ssize_t *sohm_index_num, un /* Set up user data for callback */ cache_udata.f = f; - if (NULL == (my_table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (my_table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), + &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table"); } /* end if */ @@ -955,7 +964,8 @@ H5SM_can_share(H5F_t *f, H5SM_master_table_t *table, ssize_t *sohm_index_num, un done: /* Release the master SOHM table, if we protected it */ - if (my_table && my_table != table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), my_table, H5AC__NO_FLAGS_SET) < 0) + if (my_table && my_table != table && + H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), my_table, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table"); FUNC_LEAVE_NOAPI_TAG(ret_value) @@ -1059,7 +1069,8 @@ H5SM_try_share(H5F_t *f, H5O_t *open_oh, unsigned defer_flags, unsigned type_id, cache_udata.f = f; /* Look up the master SOHM table */ - if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), &cache_udata, H5AC__NO_FLAGS_SET))) + if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), + &cache_udata, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table"); /* "complex" sharing checks */ @@ -1255,7 +1266,8 @@ H5SM__write_mesg(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, bool def cache_udata.header = header; /* The index is a list; get it from the cache */ - if (NULL == (list = (H5SM_list_t *)H5AC_protect(f, H5AC_SOHM_LIST, header->index_addr, &cache_udata, defer ? H5AC__READ_ONLY_FLAG : H5AC__NO_FLAGS_SET))) + if (NULL == (list = (H5SM_list_t *)H5AC_protect(f, H5AC_SOHM_LIST, header->index_addr, &cache_udata, + defer ? H5AC__READ_ONLY_FLAG : H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM index"); /* See if the message is already in the index and get its location. @@ -1443,7 +1455,8 @@ H5SM__write_mesg(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, bool def /* Open the index v2 B-tree, if it isn't already */ if (NULL == bt2) { if (NULL == (bt2 = H5B2_open(f, header->index_addr, f))) - HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for SOHM index"); + HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, + "unable to open v2 B-tree for SOHM index"); } /* end if */ if (H5B2_insert(bt2, &key) < 0) @@ -1471,7 +1484,8 @@ H5SM__write_mesg(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, bool def HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for SOHM index"); /* If we got a list out of the cache, release it (it is always dirty after writing a message) */ - if (list && H5AC_unprotect(f, H5AC_SOHM_LIST, header->index_addr, list, defer ? H5AC__NO_FLAGS_SET : H5AC__DIRTIED_FLAG) < 0) + if (list && H5AC_unprotect(f, H5AC_SOHM_LIST, header->index_addr, list, + defer ? H5AC__NO_FLAGS_SET : H5AC__DIRTIED_FLAG) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM index"); if (encoding_buf) @@ -1521,7 +1535,8 @@ H5SM_delete(H5F_t *f, H5O_t *open_oh, H5O_shared_t *sh_mesg) cache_udata.f = f; /* Look up the master SOHM table */ - if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), &cache_udata, H5AC__NO_FLAGS_SET))) + if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), + &cache_udata, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table"); /* Find the correct index and try to delete from it */ @@ -1534,7 +1549,8 @@ H5SM_delete(H5F_t *f, H5O_t *open_oh, H5O_shared_t *sh_mesg) * zero and any file space it uses needs to be freed. mesg_buf holds the * serialized form of the message. */ - if (H5SM__delete_from_index(f, open_oh, &(table->indexes[index_num]), sh_mesg, &cache_flags, &mesg_size, &mesg_buf) < 0) + if (H5SM__delete_from_index(f, open_oh, &(table->indexes[index_num]), sh_mesg, &cache_flags, &mesg_size, + &mesg_buf) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTDELETE, FAIL, "unable to delete message from SOHM index"); /* Release the master SOHM table */ @@ -1547,7 +1563,8 @@ H5SM_delete(H5F_t *f, H5O_t *open_oh, H5O_shared_t *sh_mesg) * master table needs to be unprotected when we do this. */ if (mesg_buf) { - if (NULL == (native_mesg = H5O_msg_decode(f, open_oh, type_id, mesg_size, (const unsigned char *)mesg_buf))) + if (NULL == + (native_mesg = H5O_msg_decode(f, open_oh, type_id, mesg_size, (const unsigned char *)mesg_buf))) HGOTO_ERROR(H5E_SOHM, H5E_CANTDECODE, FAIL, "can't decode shared message."); if (H5O_msg_delete(f, open_oh, type_id, native_mesg) < 0) @@ -1763,7 +1780,8 @@ H5SM__delete_from_index(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, c cache_udata.header = header; /* If the index is stored as a list, get it from the cache */ - if (NULL == (list = (H5SM_list_t *)H5AC_protect(f, H5AC_SOHM_LIST, header->index_addr, &cache_udata, H5AC__NO_FLAGS_SET))) + if (NULL == (list = (H5SM_list_t *)H5AC_protect(f, H5AC_SOHM_LIST, header->index_addr, &cache_udata, + H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM index"); /* Find the message in the list */ @@ -1834,7 +1852,8 @@ H5SM__delete_from_index(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, c if (header->num_messages == 0) { /* Unprotect cache and release heap */ - if (list && H5AC_unprotect(f, H5AC_SOHM_LIST, header->index_addr, list, H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) + if (list && H5AC_unprotect(f, H5AC_SOHM_LIST, header->index_addr, list, + H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to release SOHM list"); list = NULL; @@ -1938,7 +1957,8 @@ H5SM_get_info(const H5O_loc_t *ext_loc, H5P_genplist_t *fc_plist) H5AC_set_ring(H5AC_RING_USER, &orig_ring); /* Read the rest of the SOHM table information from the cache */ - if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), + &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table"); /* Get index conversion limits */ @@ -2091,7 +2111,8 @@ H5SM_get_refcount(H5F_t *f, unsigned type_id, const H5O_shared_t *sh_mesg, hsize tbl_cache_udata.f = f; /* Look up the master SOHM table */ - if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), &tbl_cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), + &tbl_cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table"); /* Find the correct index and find the message in it */ @@ -2131,7 +2152,8 @@ H5SM_get_refcount(H5F_t *f, unsigned type_id, const H5O_shared_t *sh_mesg, hsize lst_cache_udata.header = header; /* If the index is stored as a list, get it from the cache */ - if (NULL == (list = (H5SM_list_t *)H5AC_protect(f, H5AC_SOHM_LIST, header->index_addr, &lst_cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (list = (H5SM_list_t *)H5AC_protect(f, H5AC_SOHM_LIST, header->index_addr, + &lst_cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM index"); /* Find the message in the list */ @@ -2218,7 +2240,8 @@ H5SM__read_iter_op(H5O_t *oh, H5O_mesg_t *mesg /*in,out*/, unsigned sequence, /* Check if the message is dirty & flush it to the object header if so */ if (mesg->dirty) if (H5O_msg_flush(udata->file, oh, mesg) < 0) - HGOTO_ERROR(H5E_SOHM, H5E_CANTENCODE, H5_ITER_ERROR, "unable to encode object header message"); + HGOTO_ERROR(H5E_SOHM, H5E_CANTENCODE, H5_ITER_ERROR, + "unable to encode object header message"); /* Get the message's encoded size */ udata->buf_size = mesg->raw_size; @@ -2460,13 +2483,15 @@ H5SM_table_debug(H5F_t *f, haddr_t table_addr, FILE *stream, int indent, int fwi if (table_vers > HDF5_SHAREDHEADER_VERSION) HGOTO_ERROR(H5E_SOHM, H5E_BADVALUE, FAIL, "unknown shared message table version"); if (num_indexes == 0 || num_indexes > H5O_SHMESG_MAX_NINDEXES) - HGOTO_ERROR(H5E_SOHM, H5E_BADVALUE, FAIL, "number of indexes must be between 1 and H5O_SHMESG_MAX_NINDEXES"); + HGOTO_ERROR(H5E_SOHM, H5E_BADVALUE, FAIL, + "number of indexes must be between 1 and H5O_SHMESG_MAX_NINDEXES"); /* Set up user data for callback */ cache_udata.f = f; /* Look up the master SOHM table */ - if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, table_addr, &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, table_addr, &cache_udata, + H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table"); fprintf(stream, "%*sShared Message Master Table...\n", indent, ""); @@ -2535,7 +2560,8 @@ H5SM_list_debug(H5F_t *f, haddr_t list_addr, FILE *stream, int indent, int fwidt tbl_cache_udata.f = f; /* Look up the master SOHM table */ - if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, table_addr, &tbl_cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, table_addr, &tbl_cache_udata, + H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table"); /* Determine which index the list is part of */ @@ -2547,14 +2573,16 @@ H5SM_list_debug(H5F_t *f, haddr_t list_addr, FILE *stream, int indent, int fwidt } /* end if */ } /* end for */ if (x == table->num_indexes) - HGOTO_ERROR(H5E_SOHM, H5E_BADVALUE, FAIL, "list address doesn't match address for any indices in table"); + HGOTO_ERROR(H5E_SOHM, H5E_BADVALUE, FAIL, + "list address doesn't match address for any indices in table"); /* Set up user data for metadata cache callback */ lst_cache_udata.f = f; lst_cache_udata.header = &(table->indexes[index_num]); /* Get the list from the cache */ - if (NULL == (list = (H5SM_list_t *)H5AC_protect(f, H5AC_SOHM_LIST, list_addr, &lst_cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (list = (H5SM_list_t *)H5AC_protect(f, H5AC_SOHM_LIST, list_addr, &lst_cache_udata, + H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM index"); /* Open the heap, if one exists */ @@ -2635,7 +2663,8 @@ H5SM_ih_size(H5F_t *f, hsize_t *hdr_size, H5_ih_info_t *ih_info) cache_udata.f = f; /* Look up the master SOHM table */ - if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), + &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table"); /* Get SOHM header size */ diff --git a/src/H5SMtest.c b/src/H5SMtest.c index 19e248fd493..84da3195556 100644 --- a/src/H5SMtest.c +++ b/src/H5SMtest.c @@ -81,7 +81,8 @@ H5SM__get_mesg_count_test(H5F_t *f, unsigned type_id, size_t *mesg_count) cache_udata.f = f; /* Look up the master SOHM table */ - if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), &cache_udata, H5AC__READ_ONLY_FLAG))) + if (NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), + &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table"); /* Find the correct index for this message type */ From ea4c86dc41430972ccbe8bba77c6f8df12b35fbe Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Mon, 15 Jul 2024 17:07:30 -0500 Subject: [PATCH 3/4] Update per reviewer feedback Signed-off-by: Quincey Koziol --- src/H5SM.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/H5SM.c b/src/H5SM.c index 24a8aef5403..1c152bf123f 100644 --- a/src/H5SM.c +++ b/src/H5SM.c @@ -292,8 +292,8 @@ herr_t H5SM__get_index(const H5SM_master_table_t *table, unsigned type_id, ssize_t *idx) { unsigned type_flag; - ssize_t indx = -1; - herr_t ret_value = SUCCEED; /* Return value */ + ssize_t found_index = -1; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -306,12 +306,12 @@ H5SM__get_index(const H5SM_master_table_t *table, unsigned type_id, ssize_t *idx */ for (size_t x = 0; x < table->num_indexes; ++x) if (table->indexes[x].mesg_types & type_flag) { - indx = (ssize_t)x; + found_index = (ssize_t)x; break; } /* Set output parameter */ - *idx = indx; + *idx = found_index; done: FUNC_LEAVE_NOAPI(ret_value) From b2110a3c6c567cdba30175c70c6fedf4d82b434a Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 15 Jul 2024 22:09:11 +0000 Subject: [PATCH 4/4] Committing clang-format changes --- src/H5SM.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/H5SM.c b/src/H5SM.c index 1c152bf123f..1c2d4e6caa7 100644 --- a/src/H5SM.c +++ b/src/H5SM.c @@ -292,8 +292,8 @@ herr_t H5SM__get_index(const H5SM_master_table_t *table, unsigned type_id, ssize_t *idx) { unsigned type_flag; - ssize_t found_index = -1; - herr_t ret_value = SUCCEED; /* Return value */ + ssize_t found_index = -1; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE