diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5.c | 54 | ||||
-rw-r--r-- | src/H5E.c | 1671 | ||||
-rw-r--r-- | src/H5Edeprec.c | 433 | ||||
-rw-r--r-- | src/H5Eint.c | 859 | ||||
-rw-r--r-- | src/H5Epkg.h | 105 | ||||
-rw-r--r-- | src/H5Eprivate.h | 36 | ||||
-rw-r--r-- | src/H5Epublic.h | 92 | ||||
-rw-r--r-- | src/H5FDmulti.c | 54 | ||||
-rw-r--r-- | src/H5FDstdio.c | 28 | ||||
-rw-r--r-- | src/H5trace.c | 18 | ||||
-rwxr-xr-x | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/Makefile.in | 6 |
12 files changed, 1783 insertions, 1575 deletions
@@ -205,10 +205,10 @@ done: void H5_term_library(void) { - int pending, ntries=0, n; - unsigned at=0; + int pending, ntries = 0, n; + unsigned at = 0; char loop[1024]; - H5E_auto_stack_t func; + H5E_auto2_t func; #ifdef H5_HAVE_THREADSAFE /* explicit locking of the API */ @@ -217,11 +217,11 @@ H5_term_library(void) #endif /* Don't do anything if the library is already closed */ - if (!(H5_INIT_GLOBAL)) + if(!(H5_INIT_GLOBAL)) goto done; /* Check if we should display error output */ - (void)H5Eget_auto_stack(H5E_DEFAULT,&func,NULL); + (void)H5Eget_auto2(H5E_DEFAULT, &func, NULL); /* * Terminate each interface. The termination functions return a positive @@ -229,14 +229,14 @@ H5_term_library(void) * way that would necessitate some cleanup work in the other interface. */ #define DOWN(F) \ - (((n=H5##F##_term_interface()) && at+8<sizeof loop)? \ - (sprintf(loop+at, "%s%s", at?",":"", #F), \ - at += HDstrlen(loop+at), \ + (((n = H5##F##_term_interface()) && (at + 8) < sizeof loop)? \ + (sprintf(loop + at, "%s%s", (at ? "," : ""), #F), \ + at += HDstrlen(loop + at), \ n): \ - ((n>0 && at+5<sizeof loop)? \ - (sprintf(loop+at, "..."), \ - at += HDstrlen(loop+at), \ - n):n)) + ((n > 0 && (at + 5) < sizeof loop) ? \ + (sprintf(loop + at, "..."), \ + at += HDstrlen(loop + at), \ + n) : n)) do { pending = 0; @@ -251,7 +251,7 @@ H5_term_library(void) pending += DOWN(S); pending += DOWN(T); /* Don't shut down the file code until objects in files are shut down */ - if(pending==0) + if(pending == 0) pending += DOWN(F); /* Don't shut down "low-level" components until "high-level" components @@ -259,49 +259,49 @@ H5_term_library(void) * from being closed "out from underneath" of the high-level objects * that depend on them. -QAK */ - if(pending==0) { + if(pending == 0) { pending += DOWN(AC); pending += DOWN(Z); pending += DOWN(FD); pending += DOWN(P); /* Don't shut down the error code until other APIs which use it are shut down */ - if(pending==0) + if(pending == 0) pending += DOWN(E); /* Don't shut down the ID code until other APIs which use them are shut down */ - if(pending==0) + if(pending == 0) pending += DOWN(I); /* Don't shut down the free list code until _everything_ else is down */ - if(pending==0) + if(pending == 0) pending += DOWN(FL); } - } while (pending && ntries++ < 100); + } while(pending && ntries++ < 100); - if (pending) { + if(pending) { /* Only display the error message if the user is interested in them. */ - if (func) { + if(func) { fprintf(stderr, "HDF5: infinite loop closing library\n"); fprintf(stderr, " %s\n", loop); #ifndef NDEBUG HDabort(); #endif /* NDEBUG */ - } - } + } /* end if */ + } /* end if */ #ifdef H5_HAVE_MPE /* Close MPE instrumentation library. May need to move this * down if any of the below code involves using the instrumentation code. */ - if (H5_MPEinit_g) - { + if(H5_MPEinit_g) { int mpe_code; int mpi_initialized; + MPI_Initialized(&mpi_initialized); - if (mpi_initialized){ + if(mpi_initialized) { mpe_code = MPE_Finish_log("cpilog"); assert(mpe_code >=0); - } + } /* end if */ H5_MPEinit_g = FALSE; /* turn it off no matter what */ - } + } /* end if */ #endif /* Mark library as closed */ @@ -41,67 +41,66 @@ * */ +/****************/ +/* Module Setup */ +/****************/ + +#define H5E_PACKAGE /*suppress error about including H5Epkg */ + /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5E_init_interface -#include "H5private.h" /* Generic Functions */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Eprivate.h" /* Private error routines */ +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Epkg.h" /* Error handling */ #include "H5FLprivate.h" /* Free lists */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5MMprivate.h" /* Memory management */ -/* HDF5 error class ID */ -hid_t H5E_ERR_CLS_g = FAIL; +/****************/ +/* Local Macros */ +/****************/ -/* - * Predefined errors. These are initialized at runtime in H5E_init_interface() - * in this source file. - */ -/* Include the automatically generated error code definitions */ -#include "H5Edefin.h" +/* Reserved atoms in for error API IDs */ +#define H5E_RESERVED_ATOMS 0 -/* Amount to indent each error */ -#define H5E_INDENT 2 - -#ifdef H5_HAVE_THREADSAFE -/* - * The per-thread error stack. pthread_once() initializes a special - * key that will be used by all threads to create a stack specific to - * each thread individually. The association of stacks to threads will - * be handled by the pthread library. - * - * In order for this macro to work, H5E_get_my_stack() must be preceeded - * by "H5E_t *estack =". - */ -static H5E_t * H5E_get_stack(void); -#define H5E_get_my_stack() H5E_get_stack() -#else /* H5_HAVE_THREADSAFE */ -/* - * The current error stack. - */ -H5E_t H5E_stack_g[1]; -#define H5E_get_my_stack() (H5E_stack_g+0) -#endif /* H5_HAVE_THREADSAFE */ +/* HDF5 error class */ +#define H5E_CLS_NAME "HDF5" +#define H5E_CLS_LIB_NAME "HDF5" /******************/ /* Local Typedefs */ /******************/ -/* Some syntactic sugar to make the compiler happy with two different kinds of callbacks */ -typedef union { - H5E_auto_stack_t stack_efunc; /* New-style callback, with error stack param. */ - H5E_auto_t efunc; /* Old-style callback, NO error stack param. */ -} H5E_auto_op_t; -#ifdef H5_HAVE_PARALLEL -/* - * variables used for MPI error reporting - */ -char H5E_mpi_error_str[MPI_MAX_ERROR_STRING]; -int H5E_mpi_error_str_len; -#endif +/********************/ +/* Package Typedefs */ +/********************/ + + +/********************/ +/* Local Prototypes */ +/********************/ + + +/*********************/ +/* Package Variables */ +/*********************/ + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + /* Static function declarations */ static H5E_cls_t *H5E_register_class(const char *cls_name, const char *lib_name, @@ -111,20 +110,10 @@ static ssize_t H5E_get_class_name(const H5E_cls_t *cls, char *name, size_t size) static int H5E_close_msg_cb(void *obj_ptr, hid_t obj_id, void *key); static herr_t H5E_close_msg(H5E_msg_t *err); static H5E_msg_t *H5E_create_msg(H5E_cls_t *cls, H5E_type_t msg_type, const char *msg); -static ssize_t H5E_get_msg(const H5E_msg_t *msg_ptr, H5E_type_t *type, char *msg, size_t size); static H5E_t *H5E_get_current_stack(void); static herr_t H5E_set_current_stack(H5E_t *estack); static herr_t H5E_close_stack(H5E_t *err_stack); static ssize_t H5E_get_num(const H5E_t *err_stack); -static herr_t H5E_pop(H5E_t *err_stack, size_t count); -static herr_t H5E_clear_entries(H5E_t *estack, size_t nentries); -static herr_t H5E_print_stack(const H5E_t *estack, FILE *stream, hbool_t bk_compatible); -static herr_t H5E_walk_stack(const H5E_t *estack, H5E_direction_t direction, H5E_walk_t func, - H5E_walk_stack_t stack_func, hbool_t bk_compatible, void *client_data); -static herr_t H5E_walk_cb(unsigned n, const H5E_error_t *err_desc, void *client_data); -static herr_t H5E_walk_stack_cb(unsigned n, const H5E_error_stack_t *err_desc, void *client_data); -static herr_t H5E_get_auto_stack(const H5E_t *estack, hbool_t new_api, H5E_auto_op_t *func, void **client_data); -static herr_t H5E_set_auto_stack(H5E_t *estack, hbool_t new_api, H5E_auto_op_t *func, void *client_data); /* Declare a free list to manage the H5E_t struct */ H5FL_DEFINE_STATIC(H5E_t); @@ -148,21 +137,19 @@ H5FL_DEFINE_STATIC(H5E_msg_t); * Programmer: Quincey Koziol * Tuesday, June 29, 2004 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t H5E_init(void) { - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5E_init, FAIL) /* FUNC_ENTER() does all the work */ done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5E_init() */ /*-------------------------------------------------------------------------- * Function: H5E_init_interface @@ -190,10 +177,12 @@ H5E_init_interface(void) if(H5I_register_type(H5I_ERROR_CLASS, (size_t)H5I_ERRCLS_HASHSIZE, H5E_RESERVED_ATOMS, (H5I_free_t)H5E_unregister_class) < H5I_FILE) HGOTO_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL, "unable to initialize ID group") + /* Initialize the atom group for the major error IDs */ if(H5I_register_type(H5I_ERROR_MSG, (size_t)H5I_ERRMSG_HASHSIZE, H5E_RESERVED_ATOMS, (H5I_free_t)H5E_close_msg) < H5I_FILE) HGOTO_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL, "unable to initialize ID group") + /* Initialize the atom group for the error stacks */ if(H5I_register_type(H5I_ERROR_STACK, (size_t)H5I_ERRSTK_HASHSIZE, H5E_RESERVED_ATOMS, (H5I_free_t)H5E_close_stack) < H5I_FILE) @@ -206,17 +195,17 @@ H5E_init_interface(void) H5E_stack_g[0].u.func = (H5E_auto_t)H5Eprint; #else /*H5_WANT_H5_V1_6_COMPAT*/ H5E_stack_g[0].new_api = TRUE; - H5E_stack_g[0].u.func_stack = (H5E_auto_stack_t)H5Eprint_stack; + H5E_stack_g[0].u.func2 = (H5E_auto2_t)H5Eprint2; #endif /*H5_WANT_H5_V1_6_COMPAT*/ H5E_stack_g[0].auto_data = NULL; #endif /* H5_HAVE_THREADSAFE */ /* Allocate the HDF5 error class */ - assert(H5E_ERR_CLS_g==(-1)); - HDsnprintf(lib_vers,sizeof(lib_vers),"%u.%u.%u%s",H5_VERS_MAJOR,H5_VERS_MINOR,H5_VERS_RELEASE,(HDstrlen(H5_VERS_SUBRELEASE)>0 ? "-"H5_VERS_SUBRELEASE : "")); - if((cls = H5E_register_class(H5E_CLS_NAME, H5E_CLS_LIB_NAME, lib_vers))==NULL) + HDassert(H5E_ERR_CLS_g == (-1)); + HDsnprintf(lib_vers, sizeof(lib_vers), "%u.%u.%u%s", H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE, (HDstrlen(H5_VERS_SUBRELEASE) > 0 ? "-"H5_VERS_SUBRELEASE : "")); + if(NULL == (cls = H5E_register_class(H5E_CLS_NAME, H5E_CLS_LIB_NAME, lib_vers))) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "class initialization failed") - if((H5E_ERR_CLS_g = H5I_register(H5I_ERROR_CLASS, cls))<0) + if((H5E_ERR_CLS_g = H5I_register(H5I_ERROR_CLASS, cls)) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error class") /* Include the automatically generated error code initialization */ @@ -224,7 +213,7 @@ H5E_init_interface(void) done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5E_init_interface() */ /*------------------------------------------------------------------------- @@ -240,50 +229,50 @@ done: * Programmer: Raymond Lu * Tuesday, July 22, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ int H5E_term_interface(void) { - int ncls, nmsg, nstk, n=0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5E_term_interface) - if (H5_interface_initialize_g) { + if(H5_interface_initialize_g) { + int ncls, nmsg, nstk; + /* Check if there are any open error stacks, classes or messages */ ncls = H5I_nmembers(H5I_ERROR_CLASS); nmsg = H5I_nmembers(H5I_ERROR_MSG); nstk = H5I_nmembers(H5I_ERROR_STACK); n = ncls + nmsg + nstk; - if(n>0) { + if(n > 0) { /* Clear any outstanding error stacks */ - if (nstk>0) + if(nstk > 0) H5I_clear_type(H5I_ERROR_STACK, FALSE); /* Clear all the error classes */ - if (ncls>0) { + if(ncls > 0) { H5I_clear_type(H5I_ERROR_CLASS, FALSE); /* Reset the HDF5 error class, if its been closed */ - if(H5I_nmembers(H5I_ERROR_CLASS)==0) + if(H5I_nmembers(H5I_ERROR_CLASS) == 0) H5E_ERR_CLS_g = -1; - } + } /* end if */ /* Clear all the error messages */ - if (nmsg>0) { + if(nmsg > 0) { H5I_clear_type(H5I_ERROR_MSG, FALSE); /* Reset the HDF5 error messages, if they've been closed */ - if(H5I_nmembers(H5I_ERROR_MSG)==0) { + if(H5I_nmembers(H5I_ERROR_MSG) == 0) { /* Include the automatically generated error code termination */ #include "H5Eterm.h" } /* end if */ } /* end if */ - - } else { + } /* end if */ + else { /* Destroy the error class, message, and stack id groups */ H5I_dec_type_ref(H5I_ERROR_STACK); H5I_dec_type_ref(H5I_ERROR_CLASS); @@ -292,11 +281,11 @@ H5E_term_interface(void) /* Mark closed */ H5_interface_initialize_g = 0; n = 1; /*H5I*/ - } - } + } /* end else */ + } /* end if */ FUNC_LEAVE_NOAPI(n) -} +} /* end H5E_term_interface() */ #ifdef H5_HAVE_THREADSAFE @@ -313,8 +302,6 @@ H5E_term_interface(void) * Programmer: Chee Wai LEE * April 24, 2000 * - * Modifications: - * *------------------------------------------------------------------------- */ static H5E_t * @@ -326,7 +313,7 @@ H5E_get_stack(void) estack = pthread_getspecific(H5TS_errstk_key_g); - if (!estack) { + if(!estack) { /* no associated value with current thread - create one */ estack = (H5E_t *)H5FL_MALLOC(H5E_t); HDassert(estack); @@ -334,7 +321,7 @@ H5E_get_stack(void) /* Set the thread-specific info */ estack->nused = 0; estack->new_api = TRUE; - estack->u.func_stack = (H5E_auto_stack_t)H5Eprint_stack; + estack->u.func_stack = (H5E_auto2_t)H5Eprint2; estack->auto_data = NULL; /* (It's not necessary to release this in this API, it is @@ -342,11 +329,11 @@ H5E_get_stack(void) * routines. See calls to pthread_key_create() in H5TS.c -QAK) */ pthread_setspecific(H5TS_errstk_key_g, (void *)estack); - } + } /* end if */ /* Set return value */ FUNC_LEAVE_NOAPI(estack) -} +} /* end H5E_get_stack() */ #endif /* H5_HAVE_THREADSAFE */ @@ -360,8 +347,6 @@ H5E_get_stack(void) * Programmer: Raymond Lu * Friday, July 11, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ hid_t @@ -374,20 +359,20 @@ H5Eregister_class(const char *cls_name, const char *lib_name, const char *versio H5TRACE3("i", "*s*s*s", cls_name, lib_name, version); /* Check arguments */ - if (cls_name==NULL || lib_name==NULL || version==NULL) + if(cls_name == NULL || lib_name == NULL || version == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid string") /* Create the new error class object */ - if((cls=H5E_register_class(cls_name, lib_name, version))==NULL) + if(NULL == (cls = H5E_register_class(cls_name, lib_name, version))) HGOTO_ERROR(H5E_ERROR, H5E_CANTCREATE, FAIL, "can't create error class") /* Register the new error class to get an ID for it */ - if((ret_value = H5I_register(H5I_ERROR_CLASS, cls))<0) + if((ret_value = H5I_register(H5I_ERROR_CLASS, cls)) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error class") done: FUNC_LEAVE_API(ret_value) -} +} /* end H5Eregister_class() */ /*------------------------------------------------------------------------- @@ -400,8 +385,6 @@ done: * Programmer: Raymond Lu * Friday, July 11, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ static H5E_cls_t * @@ -413,28 +396,28 @@ H5E_register_class(const char *cls_name, const char *lib_name, const char *versi FUNC_ENTER_NOAPI_NOINIT(H5E_register_class) /* Check arguments */ - assert(cls_name); - assert(lib_name); - assert(version); + HDassert(cls_name); + HDassert(lib_name); + HDassert(version); /* Allocate space for new error class */ - if((cls = H5FL_MALLOC(H5E_cls_t))==NULL) + if(NULL == (cls = H5FL_MALLOC(H5E_cls_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Duplicate string information */ - if((cls->cls_name = H5MM_xstrdup(cls_name))==NULL) + if(NULL == (cls->cls_name = H5MM_xstrdup(cls_name))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - if((cls->lib_name = H5MM_xstrdup(lib_name))==NULL) + if(NULL == (cls->lib_name = H5MM_xstrdup(lib_name))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - if((cls->lib_vers = H5MM_xstrdup(version))==NULL) + if(NULL == (cls->lib_vers = H5MM_xstrdup(version))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Set the return value */ - ret_value=cls; + ret_value = cls; done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5E_register_class() */ /*------------------------------------------------------------------------- @@ -447,8 +430,6 @@ done: * Programmer: Raymond Lu * Friday, July 11, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -460,19 +441,19 @@ H5Eunregister_class(hid_t class_id) H5TRACE1("e", "i", class_id); /* Check arguments */ - if (H5I_ERROR_CLASS != H5I_get_type(class_id)) + if(H5I_ERROR_CLASS != H5I_get_type(class_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an error class") /* * Decrement the counter on the dataset. It will be freed if the count * reaches zero. */ - if(H5I_dec_ref(class_id)<0) + if(H5I_dec_ref(class_id) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error class") done: FUNC_LEAVE_API(ret_value) -} +} /* end H5Eunregister_class() */ /*------------------------------------------------------------------------- @@ -485,8 +466,6 @@ done: * Programmer: Raymond Lu * Friday, July 11, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t @@ -495,7 +474,7 @@ H5E_unregister_class(H5E_cls_t *cls) FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5E_unregister_class) /* Check arguments */ - assert(cls); + HDassert(cls); /* Iterate over all the messages and delete those in this error class */ /* (Ignore return value, since callback isn't designed to return a particular object) */ @@ -511,7 +490,7 @@ H5E_unregister_class(H5E_cls_t *cls) H5FL_FREE(H5E_cls_t, cls); FUNC_LEAVE_NOAPI(SUCCEED) -} +} /* end H5E_unregister_class() */ /*------------------------------------------------------------------------- @@ -525,8 +504,6 @@ H5E_unregister_class(H5E_cls_t *cls) * Programmer: Raymond Lu * Friday, July 11, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ ssize_t @@ -539,16 +516,16 @@ H5Eget_class_name(hid_t class_id, char *name, size_t size) H5TRACE3("Zs", "i*sz", class_id, name, size); /* Get the error class */ - if(NULL==(cls = H5I_object_verify(class_id, H5I_ERROR_CLASS))) + if(NULL == (cls = H5I_object_verify(class_id, H5I_ERROR_CLASS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error class ID") /* Retrieve the class name */ - if((ret_value = H5E_get_class_name(cls, name, size))<0) + if((ret_value = H5E_get_class_name(cls, name, size)) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get error class name") done: FUNC_LEAVE_API(ret_value) -} +} /* end H5Eget_class_name() */ /*------------------------------------------------------------------------- @@ -562,33 +539,31 @@ done: * Programmer: Raymond Lu * Friday, July 11, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ static ssize_t H5E_get_class_name(const H5E_cls_t *cls, char *name, size_t size) { - ssize_t len; /* Length of rror class's name */ + ssize_t len; /* Length of error class's name */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5E_get_class_name) /* Check arguments */ - assert(cls); + HDassert(cls); /* Get the class's name */ len = (ssize_t)HDstrlen(cls->cls_name); /* Set the user's buffer, if provided */ if(name) { - HDstrncpy(name, cls->cls_name, MIN((size_t)(len+1), size)); + HDstrncpy(name, cls->cls_name, MIN((size_t)(len + 1), size)); if((size_t)len >= size) - name[size-1]='\0'; - } + name[size - 1] = '\0'; + } /* end if */ /* Return the full length */ FUNC_LEAVE_NOAPI(len) -} +} /* end H5E_get_class_name() */ /*------------------------------------------------------------------------- @@ -597,12 +572,10 @@ H5E_get_class_name(const H5E_cls_t *cls, char *name, size_t size) * Purpose: H5I_search callback function to close error messages in the * error class. * - * Programmer: Raymond Lu - * July 14, 2003 - * * Return: Non-negative value on success/Negative on failure * - * Modifications: + * Programmer: Raymond Lu + * July 14, 2003 * *------------------------------------------------------------------------- */ @@ -616,16 +589,16 @@ H5E_close_msg_cb(void *obj_ptr, hid_t obj_id, void *key) FUNC_ENTER_NOAPI_NOINIT(H5E_close_msg_cb) /* Check arguments */ - assert(err_msg); + HDassert(err_msg); /* Close the message if it is in the class being closed */ if(err_msg->cls == cls) - if(H5I_dec_ref(obj_id)<0) + if(H5I_dec_ref(obj_id) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error message") done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5E_close_msg_cb() */ /*------------------------------------------------------------------------- @@ -638,8 +611,6 @@ done: * Programmer: Raymond Lu * Friday, July 11, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -651,16 +622,16 @@ H5Eclose_msg(hid_t err_id) H5TRACE1("e", "i", err_id); /* Check arguments */ - if (H5I_ERROR_MSG != H5I_get_type(err_id)) + if(H5I_ERROR_MSG != H5I_get_type(err_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an error class") /* Decrement the counter. It will be freed if the count reaches zero. */ - if(H5I_dec_ref(err_id)<0) + if(H5I_dec_ref(err_id) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error message") done: FUNC_LEAVE_API(ret_value) -} +} /* end H5Eclose_msg() */ /*------------------------------------------------------------------------- * Function: H5E_close_msg @@ -672,8 +643,6 @@ done: * Programmer: Raymond Lu * Friday, July 11, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t @@ -682,7 +651,7 @@ H5E_close_msg(H5E_msg_t *err) FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5E_close_msg) /* Check arguments */ - assert(err); + HDassert(err); if(err->msg) H5MM_xfree((void*)err->msg); @@ -691,7 +660,7 @@ H5E_close_msg(H5E_msg_t *err) H5FL_FREE(H5E_msg_t, err); FUNC_LEAVE_NOAPI(SUCCEED) -} +} /* end H5E_close_msg() */ /*------------------------------------------------------------------------- * Function: H5Ecreate_msg @@ -703,8 +672,6 @@ H5E_close_msg(H5E_msg_t *err) * Programmer: Raymond Lu * Friday, July 11, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ hid_t @@ -718,26 +685,26 @@ H5Ecreate_msg(hid_t class_id, H5E_type_t msg_type, const char *msg_str) H5TRACE3("i", "iEt*s", class_id, msg_type, msg_str); /* Check arguments */ - if(msg_type!=H5E_MAJOR && msg_type!=H5E_MINOR) + if(msg_type != H5E_MAJOR && msg_type != H5E_MINOR) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid message type") - if(msg_str==NULL) + if(msg_str == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "message is NULL") /* Get the error class */ - if(NULL==(cls = H5I_object_verify(class_id, H5I_ERROR_CLASS))) + if(NULL == (cls = H5I_object_verify(class_id, H5I_ERROR_CLASS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error class ID") /* Create the new error message object */ - if((msg = H5E_create_msg(cls, msg_type, msg_str))==NULL) + if(NULL == (msg = H5E_create_msg(cls, msg_type, msg_str))) HGOTO_ERROR(H5E_ERROR, H5E_CANTCREATE, FAIL, "can't create error message") /* Register the new error class to get an ID for it */ - if((ret_value = H5I_register(H5I_ERROR_MSG, msg))<0) + if((ret_value = H5I_register(H5I_ERROR_MSG, msg)) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") done: FUNC_LEAVE_API(ret_value) -} +} /* end H5Ecreate_msg() */ /*------------------------------------------------------------------------- * Function: H5E_create_msg @@ -749,8 +716,6 @@ done: * Programmer: Raymond Lu * Friday, July 11, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ static H5E_msg_t * @@ -762,18 +727,18 @@ H5E_create_msg(H5E_cls_t *cls, H5E_type_t msg_type, const char *msg_str) FUNC_ENTER_NOAPI_NOINIT(H5E_create_msg) /* Check arguments */ - assert(cls); - assert(msg_type==H5E_MAJOR || msg_type==H5E_MINOR); - assert(msg_str); + HDassert(cls); + HDassert(msg_type == H5E_MAJOR || msg_type == H5E_MINOR); + HDassert(msg_str); /* Allocate new message object */ - if((msg = H5FL_MALLOC(H5E_msg_t))==NULL) + if(NULL == (msg = H5FL_MALLOC(H5E_msg_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Fill new message object */ msg->cls = cls; msg->type = msg_type; - if((msg->msg = H5MM_xstrdup(msg_str))==NULL) + if(NULL == (msg->msg = H5MM_xstrdup(msg_str))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Set return value */ @@ -781,107 +746,7 @@ H5E_create_msg(H5E_cls_t *cls, H5E_type_t msg_type, const char *msg_str) done: FUNC_LEAVE_NOAPI(ret_value) -} - - -/*------------------------------------------------------------------------- - * Function: H5Eget_major - * - * Purpose: Retrieves a major error message. - * - * Return: Returns message if succeeds. - * otherwise returns NULL. - * - * Programmer: Raymond Lu - * Friday, July 14, 2003 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -const char * -H5Eget_major(H5E_major_t maj) -{ - H5E_msg_t *msg; /* Pointer to error message */ - ssize_t size = 0; /* Return value */ - H5E_type_t type; - char *msg_str; - char *ret_value = NULL; - - FUNC_ENTER_API_NOCLEAR(H5Eget_major,NULL) - - /* Get the message object */ - if((msg = H5I_object_verify(maj, H5I_ERROR_MSG))==NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a error message ID") - - /* Get the message's text */ - if((size = H5E_get_msg(msg, &type, NULL, (size_t)0)) < 0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "can't get error message text") - - if(type != H5E_MAJOR) - HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "Error message isn't a major one") - - /* Don't know who is going to free it */ - msg_str = (char*)H5MM_malloc((size_t)(++size)*sizeof(char)); - - if(H5E_get_msg(msg, NULL, msg_str, (size_t)size)<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "can't get error message text") - - ret_value = msg_str; - -done: - FUNC_LEAVE_API(ret_value) -} - - -/*------------------------------------------------------------------------- - * Function: H5Eget_minor - * - * Purpose: Retrieves a minor error message. - * - * Return: Returns message if succeeds. - * otherwise returns NULL. - * - * Programmer: Raymond Lu - * Friday, July 14, 2003 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -const char * -H5Eget_minor(H5E_minor_t min) -{ - H5E_msg_t *msg; /* Pointer to error message */ - ssize_t size = 0; /* Return value */ - H5E_type_t type; - char *msg_str; - char *ret_value = NULL; - - FUNC_ENTER_API_NOCLEAR(H5Eget_minor,NULL) - - /* Get the message object */ - if((msg = H5I_object_verify(min, H5I_ERROR_MSG))==NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a error message ID") - - /* Get the message's text */ - if((size = H5E_get_msg(msg, &type, NULL, (size_t)0)) < 0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "can't get error message text") - - if(type != H5E_MINOR) - HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "Error message isn't a minor one") - - /* Don't know who is going to free it */ - msg_str = (char*)H5MM_malloc((size_t)(++size)*sizeof(char)); - - if(H5E_get_msg(msg, NULL, msg_str, (size_t)size)<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "can't get error message text") - - ret_value = msg_str; - -done: - FUNC_LEAVE_API(ret_value) -} +} /* end H5E_create_msg() */ /*------------------------------------------------------------------------- @@ -895,8 +760,6 @@ done: * Programmer: Raymond Lu * Friday, July 14, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ ssize_t @@ -909,60 +772,16 @@ H5Eget_msg(hid_t msg_id, H5E_type_t *type, char *msg_str, size_t size) H5TRACE4("Zs", "i*Et*sz", msg_id, type, msg_str, size); /* Get the message object */ - if((msg = H5I_object_verify(msg_id, H5I_ERROR_MSG))==NULL) + if(NULL == (msg = H5I_object_verify(msg_id, H5I_ERROR_MSG))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error message ID") /* Get the message's text */ - if((ret_value = H5E_get_msg(msg, type, msg_str, size))<0) + if((ret_value = H5E_get_msg(msg, type, msg_str, size)) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get error message text") done: FUNC_LEAVE_API(ret_value) -} - - -/*------------------------------------------------------------------------- - * Function: H5E_get_msg - * - * Purpose: Private function to retrieve an error message. - * - * Return: Non-negative for name length if succeeds(zero means no name); - * otherwise returns negative value. - * - * Programmer: Raymond Lu - * Friday, July 14, 2003 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static ssize_t -H5E_get_msg(const H5E_msg_t *msg, H5E_type_t *type, char *msg_str, size_t size) -{ - ssize_t len; /* Length of rror class's name */ - - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5E_get_msg) - - /* Check arguments */ - assert(msg); - - /* Get the length of the message string */ - len = (ssize_t)HDstrlen(msg->msg); - - /* Copy the message into the user's buffer, if given */ - if(msg_str) { - HDstrncpy(msg_str, msg->msg, MIN((size_t)(len+1), size)); - if((size_t)len >= size) - msg_str[size-1]='\0'; - } - - /* Give the message type, if asked */ - if(type) - *type = msg->type; - - /* Set the return value to the full length of the message */ - FUNC_LEAVE_NOAPI(len) -} +} /* end H5Eget_msg() */ /*------------------------------------------------------------------------- @@ -976,8 +795,6 @@ H5E_get_msg(const H5E_msg_t *msg, H5E_type_t *type, char *msg_str, size_t size) * Programmer: Raymond Lu * Friday, July 14, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ hid_t @@ -991,16 +808,16 @@ H5Eget_current_stack(void) H5TRACE0("i",""); /* Get the current stack */ - if((stk=H5E_get_current_stack())==NULL) + if(NULL == (stk = H5E_get_current_stack())) HGOTO_ERROR(H5E_ERROR, H5E_CANTCREATE, FAIL, "can't create error stack") /* Register the stack */ - if((ret_value = H5I_register(H5I_ERROR_STACK, stk))<0) + if((ret_value = H5I_register(H5I_ERROR_STACK, stk)) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't create error stack") done: FUNC_LEAVE_API(ret_value) -} +} /* end H5Eget_current_stack() */ /*------------------------------------------------------------------------- @@ -1013,8 +830,6 @@ done: * Programmer: Raymond Lu * Friday, July 11, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ static H5E_t * @@ -1028,38 +843,38 @@ H5E_get_current_stack(void) FUNC_ENTER_NOAPI_NOINIT(H5E_get_current_stack) /* Get a pointer to the current error stack */ - if((current_stack = H5E_get_my_stack ())==NULL) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + if(NULL == (current_stack = H5E_get_my_stack ())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "can't get current error stack") /* Allocate a new error stack */ - if((estack_copy = H5FL_MALLOC(H5E_t))==NULL) + if(NULL == (estack_copy = H5FL_MALLOC(H5E_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Make a copy of current error stack */ estack_copy->nused = current_stack->nused; - for(u=0; u<current_stack->nused; u++) { - H5E_error_stack_t *current_error, *new_error; /* Pointers to errors on each stack */ + for(u = 0; u < current_stack->nused; u++) { + H5E_error2_t *current_error, *new_error; /* Pointers to errors on each stack */ /* Get pointers into the current error stack location */ current_error = &(current_stack->slot[u]); new_error = &(estack_copy->slot[u]); /* Increment the IDs to indicate that they are used in this stack */ - if(H5I_inc_ref(current_error->cls_id)<0) + if(H5I_inc_ref(current_error->cls_id) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, NULL, "unable to increment ref count on error class") new_error->cls_id = current_error->cls_id; - if(H5I_inc_ref(current_error->maj_num)<0) + if(H5I_inc_ref(current_error->maj_num) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, NULL, "unable to increment ref count on error message") new_error->maj_num = current_error->maj_num; - if(H5I_inc_ref(current_error->min_num)<0) + if(H5I_inc_ref(current_error->min_num) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, NULL, "unable to increment ref count on error message") new_error->min_num = current_error->min_num; - if((new_error->func_name = H5MM_xstrdup(current_error->func_name))==NULL) + if(NULL == (new_error->func_name = H5MM_xstrdup(current_error->func_name))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - if((new_error->file_name = H5MM_xstrdup(current_error->file_name))==NULL) + if(NULL == (new_error->file_name = H5MM_xstrdup(current_error->file_name))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") new_error->line = current_error->line; - if((new_error->desc = H5MM_xstrdup(current_error->desc))==NULL) + if(NULL == (new_error->desc = H5MM_xstrdup(current_error->desc))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") } /* end for */ @@ -1070,13 +885,12 @@ H5E_get_current_stack(void) ret_value = estack_copy; done: - if(ret_value==NULL) { - if(estack_copy!=NULL) + if(ret_value == NULL) + if(estack_copy) H5FL_FREE(H5E_t, estack_copy); - } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5E_get_current_stack() */ /*------------------------------------------------------------------------- @@ -1089,31 +903,29 @@ done: * Programmer: Raymond Lu * Friday, July 15, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t H5Eset_current_stack(hid_t err_stack) { - H5E_t *estack; - herr_t ret_value = SUCCEED; /* Return value */ + H5E_t *estack; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(H5Eset_current_stack, FAIL) H5TRACE1("e", "i", err_stack); if(err_stack != H5E_DEFAULT) { - if((estack = H5I_object_verify(err_stack, H5I_ERROR_STACK))==NULL) + if(NULL == (estack = H5I_object_verify(err_stack, H5I_ERROR_STACK))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") /* Set the current error stack */ - if(H5E_set_current_stack(estack)<0) + if(H5E_set_current_stack(estack) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "unable to set error stack") } /* end if */ done: FUNC_LEAVE_API(ret_value) -} +} /* end H5Eset_current_stack() */ /*------------------------------------------------------------------------- @@ -1126,8 +938,6 @@ done: * Programmer: Raymond Lu * Friday, July 15, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t @@ -1140,10 +950,10 @@ H5E_set_current_stack(H5E_t *estack) FUNC_ENTER_NOAPI_NOINIT(H5E_set_current_stack) /* Sanity check */ - assert(estack); + HDassert(estack); /* Get a pointer to the current error stack */ - if((current_stack = H5E_get_my_stack ())==NULL) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + if(NULL == (current_stack = H5E_get_my_stack ())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") /* Empty current error stack */ @@ -1151,35 +961,35 @@ H5E_set_current_stack(H5E_t *estack) /* Copy new stack to current error stack */ current_stack->nused = estack->nused; - for(u=0; u<current_stack->nused; u++) { - H5E_error_stack_t *current_error, *new_error; /* Pointers to errors on each stack */ + for(u = 0; u < current_stack->nused; u++) { + H5E_error2_t *current_error, *new_error; /* Pointers to errors on each stack */ /* Get pointers into the current error stack location */ current_error = &(current_stack->slot[u]); new_error = &(estack->slot[u]); /* Increment the IDs to indicate that they are used in this stack */ - if(H5I_inc_ref(new_error->cls_id)<0) + if(H5I_inc_ref(new_error->cls_id) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, FAIL, "unable to decrement ref count on error class") current_error->cls_id = new_error->cls_id; - if(H5I_inc_ref(new_error->maj_num)<0) + if(H5I_inc_ref(new_error->maj_num) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, FAIL, "unable to decrement ref count on error class") current_error->maj_num = new_error->maj_num; - if(H5I_inc_ref(new_error->min_num)<0) + if(H5I_inc_ref(new_error->min_num) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, FAIL, "unable to decrement ref count on error class") current_error->min_num = new_error->min_num; - if((current_error->func_name = H5MM_xstrdup(new_error->func_name))==NULL) + if(NULL == (current_error->func_name = H5MM_xstrdup(new_error->func_name))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - if((current_error->file_name = H5MM_xstrdup(new_error->file_name))==NULL) + if(NULL == (current_error->file_name = H5MM_xstrdup(new_error->file_name))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") current_error->line = new_error->line; - if((current_error->desc = H5MM_xstrdup(new_error->desc))==NULL) + if(NULL == (current_error->desc = H5MM_xstrdup(new_error->desc))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") } /* end for */ done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5E_set_current_stack() */ /*------------------------------------------------------------------------- @@ -1192,8 +1002,6 @@ done: * Programmer: Raymond Lu * Friday, July 14, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -1219,7 +1027,7 @@ H5Eclose_stack(hid_t stack_id) done: FUNC_LEAVE_API(ret_value) -} +} /* end H5Eclose_stack() */ /*------------------------------------------------------------------------- @@ -1232,8 +1040,6 @@ done: * Programmer: Raymond Lu * Friday, July 14, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t @@ -1242,7 +1048,7 @@ H5E_close_stack(H5E_t *estack) FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5E_close_stack) /* Sanity check */ - assert(estack); + HDassert(estack); /* Release the stack's error information */ H5E_clear_stack(estack); @@ -1251,7 +1057,7 @@ H5E_close_stack(H5E_t *estack) H5FL_FREE(H5E_t, estack); FUNC_LEAVE_NOAPI(SUCCEED) -} +} /* end H5E_close_stack() */ /*------------------------------------------------------------------------- @@ -1264,11 +1070,6 @@ H5E_close_stack(H5E_t *estack) * Programmer: Raymond Lu * Friday, July 15, 2003 * - * Modifications: - * Raymond Lu - * Monday, May 16, 2005 - * Changed return value type from INT to SIZE_T. - * *------------------------------------------------------------------------- */ ssize_t @@ -1283,7 +1084,7 @@ H5Eget_num(hid_t error_stack_id) /* Need to check for errors */ if(error_stack_id == H5E_DEFAULT) { - if((estack = H5E_get_my_stack())==NULL) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + if(NULL == (estack = H5E_get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") } /* end if */ else { @@ -1291,17 +1092,17 @@ H5Eget_num(hid_t error_stack_id) H5E_clear_stack(NULL); /* Get the error stack to operate on */ - if((estack = H5I_object_verify(error_stack_id, H5I_ERROR_STACK))==NULL) + if(NULL == (estack = H5I_object_verify(error_stack_id, H5I_ERROR_STACK))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") } /* end else */ /* Get the number of errors on stack */ - if((ret_value=H5E_get_num(estack))<0) + if((ret_value = H5E_get_num(estack)) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get number of errors") done: FUNC_LEAVE_API(ret_value) -} +} /* end H5Eget_num() */ /*------------------------------------------------------------------------- @@ -1314,11 +1115,6 @@ done: * Programmer: Raymond Lu * Friday, July 15, 2003 * - * Modifications: - * Raymond Lu - * Monday, May 16, 2005 - * Changed return value type from INT to SIZE_T. - * *------------------------------------------------------------------------- */ static ssize_t @@ -1326,10 +1122,10 @@ H5E_get_num(const H5E_t *estack) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5E_get_num) - assert(estack); + HDassert(estack); FUNC_LEAVE_NOAPI((ssize_t)estack->nused) -} +} /* end H5E_get_num() */ /*------------------------------------------------------------------------- @@ -1342,15 +1138,13 @@ H5E_get_num(const H5E_t *estack) * Programmer: Raymond Lu * Friday, July 16, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t H5Epop(hid_t err_stack, size_t count) { H5E_t *estack; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ /* Don't clear the error stack! :-) */ FUNC_ENTER_API_NOCLEAR(H5Epop, FAIL) @@ -1358,7 +1152,7 @@ H5Epop(hid_t err_stack, size_t count) /* Need to check for errors */ if(err_stack == H5E_DEFAULT) { - if((estack = H5E_get_my_stack())==NULL) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + if(NULL == (estack = H5E_get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") } /* end if */ else { @@ -1366,7 +1160,7 @@ H5Epop(hid_t err_stack, size_t count) H5E_clear_stack(NULL); /* Get the error stack to operate on */ - if((estack = H5I_object_verify(err_stack, H5I_ERROR_STACK))==NULL) + if(NULL == (estack = H5I_object_verify(err_stack, H5I_ERROR_STACK))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") } /* end else */ @@ -1375,93 +1169,16 @@ H5Epop(hid_t err_stack, size_t count) count = estack->nused; /* Pop the errors off the stack */ - if(H5E_pop(estack, count)<0) + if(H5E_pop(estack, count) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTRELEASE, FAIL, "can't pop errors from stack") done: FUNC_LEAVE_API(ret_value) -} +} /* end H5Epop() */ /*------------------------------------------------------------------------- - * Function: H5E_pop - * - * Purpose: Private function to delete some error messages from the top - * of error stack. - * - * Return: Non-negative value on success/Negative on failure - * - * Programmer: Raymond Lu - * Friday, July 16, 2003 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static herr_t -H5E_pop(H5E_t *estack, size_t count) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT(H5E_pop) - - /* Sanity check */ - assert(estack); - assert(estack->nused>=count); - - /* Remove the entries from the error stack */ - if(H5E_clear_entries(estack, count)<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTRELEASE, FAIL, "can't remove errors from stack") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - - -/*------------------------------------------------------------------------- - * Function: H5Epush - * - * Purpose: This function definition is for backward compatibility only. - * It doesn't have error stack and error class as parameters. - * The old definition of major and minor is casted as HID_T - * in H5Epublic.h - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Raymond Lu - * Tuesday, Sep 16, 2003 - * - * Notes: Basically a public API wrapper around the H5E_push_stack - * function. For backward compatibility, it maintains the - * same parameter as the old function, in contrary to - * H5Epush_stack. - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -herr_t -H5Epush(const char *file, const char *func, unsigned line, - H5E_major_t maj, H5E_minor_t min, const char *str) -{ - H5E_t *estack = NULL; /* Default error stack */ - herr_t ret_value=SUCCEED; /* Return value */ - - /* Don't clear the error stack! :-) */ - FUNC_ENTER_API_NOCLEAR(H5Epush, FAIL) - H5TRACE6("e", "*s*sIuii*s", file, func, line, maj, min, str); - - /* Push the error on the stack */ - if(H5E_push_stack(estack, file, func, line, H5E_ERR_CLS_g, maj, min, str)<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't push error on stack") - -done: - FUNC_LEAVE_API(ret_value) -} - - -/*------------------------------------------------------------------------- - * Function: H5Epush_stack + * Function: H5Epush2 * * Purpose: Pushes a new error record onto error stack for the current * thread. The error has major and minor IDs MAJ_ID and @@ -1479,18 +1196,10 @@ done: * Notes: Basically a new public API wrapper around the H5E_push_stack * function. * - * Modifications: - * Raymond Lu - * Tuesday, July 15, 2003 - * - * Added the ID of the error stack to which the error is pushed - * on. The error message can be appended more message in the - * same control format as printf and fprintf. - * *------------------------------------------------------------------------- */ herr_t -H5Epush_stack(hid_t err_stack, const char *file, const char *func, unsigned line, +H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line, hid_t cls_id, hid_t maj_id, hid_t min_id, const char *fmt, ...) { va_list ap; /* Varargs info */ @@ -1500,11 +1209,11 @@ H5Epush_stack(hid_t err_stack, const char *file, const char *func, unsigned line int tmp_len; /* Current size of description buffer */ int desc_len; /* Actual length of description when formatted */ #endif /* H5_HAVE_VASPRINTF */ - char *tmp=NULL; /* Buffer to place formatted description in */ + char *tmp = NULL; /* Buffer to place formatted description in */ herr_t ret_value=SUCCEED; /* Return value */ /* Don't clear the error stack! :-) */ - FUNC_ENTER_API_NOCLEAR(H5Epush_stack, FAIL) + FUNC_ENTER_API_NOCLEAR(H5Epush2, FAIL) H5TRACE7("e","issIuiis",err_stack,file,func,line,maj_id,min_id,fmt); if(err_stack == H5E_DEFAULT) @@ -1514,14 +1223,14 @@ H5Epush_stack(hid_t err_stack, const char *file, const char *func, unsigned line H5E_clear_stack(NULL); /* Get the error stack to operate on */ - if((estack = H5I_object_verify(err_stack, H5I_ERROR_STACK))==NULL) + if(NULL == (estack = H5I_object_verify(err_stack, H5I_ERROR_STACK))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") } /* end else */ /* Check for mis-matches in major & minor error classes */ - if((maj_ptr = H5I_object_verify(maj_id, H5I_ERROR_MSG))==NULL) + if(NULL == (maj_ptr = H5I_object_verify(maj_id, H5I_ERROR_MSG))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error message ID") - if((min_ptr = H5I_object_verify(min_id, H5I_ERROR_MSG))==NULL) + if(NULL == (min_ptr = H5I_object_verify(min_id, H5I_ERROR_MSG))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error message ID") if(maj_ptr->cls != min_ptr->cls) HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "major and minor errors not from same error class") @@ -1531,24 +1240,24 @@ H5Epush_stack(hid_t err_stack, const char *file, const char *func, unsigned line #ifdef H5_HAVE_VASPRINTF /* Use the vasprintf() routine, since it does what we're trying to do below */ - if(HDvasprintf(&tmp,fmt,ap)<0) + if(HDvasprintf(&tmp, fmt, ap) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") #else /* H5_HAVE_VASPRINTF */ /* Allocate space for the formatted description buffer */ - tmp_len=128; - if((tmp=H5MM_malloc((size_t)tmp_len))==NULL) + tmp_len = 128; + if(NULL == (tmp = H5MM_malloc((size_t)tmp_len))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* If the description doesn't fit into the initial buffer size, allocate more space and try again */ - while((desc_len=HDvsnprintf(tmp, (size_t)tmp_len, fmt, ap)) + while((desc_len = HDvsnprintf(tmp, (size_t)tmp_len, fmt, ap)) #ifdef H5_VSNPRINTF_WORKS > #else /* H5_VSNPRINTF_WORKS */ >= #endif /* H5_VSNPRINTF_WORKS */ - (tmp_len-1) + (tmp_len - 1) #ifndef H5_VSNPRINTF_WORKS - || desc_len<0 + || (desc_len < 0) #endif /* H5_VSNPRINTF_WORKS */ ) { /* shutdown & restart the va_list */ @@ -1560,11 +1269,11 @@ H5Epush_stack(hid_t err_stack, const char *file, const char *func, unsigned line /* Allocate a description of the appropriate length */ #ifdef H5_VSNPRINTF_WORKS - tmp_len = desc_len+1; + tmp_len = desc_len + 1; #else /* H5_VSNPRINTF_WORKS */ tmp_len = 2 * tmp_len; #endif /* H5_VSNPRINTF_WORKS */ - if((tmp=H5MM_malloc((size_t)tmp_len))==NULL) + if(NULL == (tmp = H5MM_malloc((size_t)tmp_len))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") } /* end while */ #endif /* H5_HAVE_VASPRINTF */ @@ -1572,7 +1281,7 @@ H5Epush_stack(hid_t err_stack, const char *file, const char *func, unsigned line 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) + 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: @@ -1580,137 +1289,11 @@ done: H5MM_xfree(tmp); FUNC_LEAVE_API(ret_value) -} - - -/*------------------------------------------------------------------------- - * Function: H5E_push_stack - * - * Purpose: Pushes a new error record onto error stack for the current - * thread. The error has major and minor IDs MAJ_ID and - * MIN_ID, the name of a function where the error was detected, - * the name of the file where the error was detected, the - * line within that file, and an error description string. The - * function name, file name, and error description strings must - * be statically allocated (the FUNC_ENTER() macro takes care of - * the function name and file name automatically, but the - * programmer is responsible for the description string). - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Robb Matzke - * Friday, December 12, 1997 - * - * Modifications: - * Raymond Lu - * Tuesday, July 15, 2003 - * - * Added the ID of the error stack to which the error is pushed - * on. The error message can be appended more message in the - * same control format as printf and fprintf. - * - *------------------------------------------------------------------------- - */ -herr_t -H5E_push_stack(H5E_t *estack, const char *file, const char *func, unsigned line, - hid_t cls_id, hid_t maj_id, hid_t min_id, const char *desc) -{ - herr_t ret_value=SUCCEED; /* Return value */ - - /* - * WARNING: We cannot call HERROR() from within this function or else we - * could enter infinite recursion. Furthermore, we also cannot - * call any other HDF5 macro or function which might call - * HERROR(). HERROR() is called by HRETURN_ERROR() which could - * be called by FUNC_ENTER(). - */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5E_push_stack) - - /* Sanity check */ - assert(cls_id>0); - assert(maj_id>0); - assert(min_id>0); - - /* Check for 'default' error stack */ - if(estack==NULL) - if((estack = H5E_get_my_stack())==NULL) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ - HGOTO_DONE(FAIL) - - /* - * Don't fail if arguments are bad. Instead, substitute some default - * value. - */ - if (!func) func = "Unknown_Function"; - if (!file) file = "Unknown_File"; - if (!desc) desc = "No description given"; - - /* - * Push the error if there's room. Otherwise just forget it. - */ - assert (estack); - - if (estack->nused<H5E_NSLOTS) { - /* Increment the IDs to indicate that they are used in this stack */ - if(H5I_inc_ref(cls_id)<0) - HGOTO_DONE(FAIL) - estack->slot[estack->nused].cls_id = cls_id; - if(H5I_inc_ref(maj_id)<0) - HGOTO_DONE(FAIL) - estack->slot[estack->nused].maj_num = maj_id; - if(H5I_inc_ref(min_id)<0) - HGOTO_DONE(FAIL) - estack->slot[estack->nused].min_num = min_id; - if((estack->slot[estack->nused].func_name = H5MM_xstrdup(func))==NULL) - HGOTO_DONE(FAIL) - if((estack->slot[estack->nused].file_name = H5MM_xstrdup(file))==NULL) - HGOTO_DONE(FAIL) - estack->slot[estack->nused].line = line; - if((estack->slot[estack->nused].desc = H5MM_xstrdup(desc))==NULL) - HGOTO_DONE(FAIL) - estack->nused++; - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - - -/*------------------------------------------------------------------------- - * Function: H5Eclear - * - * Purpose: This function is for backward compatbility. - * Clears the error stack for the specified error stack. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Raymond Lu - * Wednesday, July 16, 2003 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -herr_t -H5Eclear(void) -{ - H5E_t *estack = NULL; /* Default error stack to operate on */ - herr_t ret_value=SUCCEED; /* Return value */ - - /* Don't clear the error stack! :-) */ - FUNC_ENTER_API_NOCLEAR(H5Eclear, FAIL) - H5TRACE0("e",""); - - /* Clear the error stack */ - if(H5E_clear_stack(estack)<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't clear error stack") - -done: - FUNC_LEAVE_API(ret_value) -} +} /* end H5Epush2() */ /*------------------------------------------------------------------------- - * Function: H5Eclear_stack + * Function: H5Eclear2 * * Purpose: Clears the error stack for the specified error stack. * @@ -1719,18 +1302,16 @@ done: * Programmer: Raymond Lu * Wednesday, July 16, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t -H5Eclear_stack(hid_t err_stack) +H5Eclear2(hid_t err_stack) { H5E_t *estack; /* Error stack to operate on */ - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ /* Don't clear the error stack! :-) */ - FUNC_ENTER_API_NOCLEAR(H5Eclear_stack, FAIL) + FUNC_ENTER_API_NOCLEAR(H5Eclear2, FAIL) H5TRACE1("e", "i", err_stack); /* Need to check for errors */ @@ -1740,160 +1321,21 @@ H5Eclear_stack(hid_t err_stack) /* Only clear the error stack if it's not the default stack */ H5E_clear_stack(NULL); - if((estack = H5I_object_verify(err_stack, H5I_ERROR_STACK))==NULL) + if(NULL == (estack = H5I_object_verify(err_stack, H5I_ERROR_STACK))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") } /* end else */ /* Clear the error stack */ - if(H5E_clear_stack(estack)<0) + if(H5E_clear_stack(estack) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't clear error stack") done: FUNC_LEAVE_API(ret_value) -} +} /* end H5Eclear2() */ /*------------------------------------------------------------------------- - * Function: H5E_clear_entries - * - * Purpose: Private function to clear the error stack entries for the - * specified error stack. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Wednesday, August 6, 2003 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static herr_t -H5E_clear_entries(H5E_t *estack, size_t nentries) -{ - H5E_error_stack_t *error; /* Pointer to error stack entry to clear */ - unsigned u; /* Local index variable */ - herr_t ret_value=SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT(H5E_clear_entries) - - /* Sanity check */ - assert(estack); - assert(estack->nused>=nentries); - - /* Empty the error stack from the top down */ - for(u=0; nentries>0; nentries--,u++) { - error = &(estack->slot[estack->nused-(u+1)]); - - /* Decrement the IDs to indicate that they are no longer used by this stack */ - /* (In reverse order that they were incremented, so that reference counts work well) */ - if(H5I_dec_ref(error->min_num)<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error message") - if(H5I_dec_ref(error->maj_num)<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error message") - if(H5I_dec_ref(error->cls_id)<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error class") - - /* Release strings */ - if(error->func_name) - H5MM_xfree((void*)error->func_name); /* Casting away const OK - QAK */ - if(error->file_name) - H5MM_xfree((void*)error->file_name); /* Casting away const OK - QAK */ - if(error->desc) - H5MM_xfree((void*)error->desc); /* Casting away const OK - QAK */ - } /* end for */ - - /* Decrement number of errors on stack */ - estack->nused-=u; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - - -/*------------------------------------------------------------------------- - * Function: H5E_clear_stack - * - * Purpose: Private function to clear the error stack for the - * specified error stack. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Raymond Lu - * Wednesday, July 16, 2003 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -herr_t -H5E_clear_stack(H5E_t *estack) -{ - herr_t ret_value=SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(H5E_clear_stack, FAIL) - - /* Check for 'default' error stack */ - if(estack==NULL) - if((estack = H5E_get_my_stack())==NULL) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ - HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") - - /* Empty the error stack */ - assert(estack); - if(estack->nused) - if(H5E_clear_entries(estack, estack->nused)<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't clear error stack") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - -/*------------------------------------------------------------------------- - * Function: H5Eprint - * - * Purpose: This function is for backward compatbility. - * Prints the error stack in some default way. This is just a - * convenience function for H5Ewalk() with a function that - * prints error messages. Users are encouraged to write there - * own more specific error handlers. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Raymond Lu - * Sep 16, 2003 - * - * Modifications: - * Albert Cheng, 2000/12/02 - * Show MPI process rank id if applicable. - * Albert Cheng, 2001/07/14 - * Show HDF5 library version information string too. - * - *------------------------------------------------------------------------- - */ -herr_t -H5Eprint(FILE *stream) -{ - H5E_t *estack; /* Error stack to operate on */ - herr_t ret_value=SUCCEED; /* Return value */ - - /* Don't clear the error stack! :-) */ - FUNC_ENTER_API_NOCLEAR(H5Eprint, FAIL) - /*NO TRACE*/ - - if((estack = H5E_get_my_stack())==NULL) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ - HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") - - /* Print error stack */ - if(H5E_print_stack(estack, stream, TRUE)<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTLIST, FAIL, "can't display error stack") - -done: - FUNC_LEAVE_API(ret_value) -} - - -/*------------------------------------------------------------------------- - * Function: H5Eprint_stack + * Function: H5Eprint2 * * Purpose: Prints the error stack in some default way. This is just a * convenience function for H5Ewalk() with a function that @@ -1905,153 +1347,42 @@ done: * Programmer: Robb Matzke * Friday, February 27, 1998 * - * Modifications: - * Albert Cheng, 2000/12/02 - * Show MPI process rank id if applicable. - * Albert Cheng, 2001/07/14 - * Show HDF5 library version information string too. - * - * Raymond Lu, 2003/7/16 - * Print for specified error stack. A line will appear before the error - * messages of each error class. It states the information of library - * name, version number and thread ID. - * *------------------------------------------------------------------------- */ herr_t -H5Eprint_stack(hid_t err_stack, FILE *stream) +H5Eprint2(hid_t err_stack, FILE *stream) { H5E_t *estack; /* Error stack to operate on */ - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ /* Don't clear the error stack! :-) */ - FUNC_ENTER_API_NOCLEAR(H5Eprint_stack, FAIL) + FUNC_ENTER_API_NOCLEAR(H5Eprint2, FAIL) /*NO TRACE*/ /* Need to check for errors */ if(err_stack == H5E_DEFAULT) { - if((estack = H5E_get_my_stack())==NULL) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + if(NULL == (estack = H5E_get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") } /* end if */ else { /* Only clear the error stack if it's not the default stack */ H5E_clear_stack(NULL); - if((estack = H5I_object_verify(err_stack, H5I_ERROR_STACK))==NULL) + if(NULL == (estack = H5I_object_verify(err_stack, H5I_ERROR_STACK))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") } /* end else */ /* Print error stack */ - if(H5E_print_stack(estack, stream, FALSE)<0) + if(H5E_print2(estack, stream, FALSE) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTLIST, FAIL, "can't display error stack") done: FUNC_LEAVE_API(ret_value) -} - - -/*------------------------------------------------------------------------- - * Function: H5E_print_stack - * - * Purpose: Private function to print the error stack in some default - * way. This is just a convenience function for H5Ewalk() and - * H5Ewalk_stack() with a function that prints error messages. - * Users are encouraged to write there own more specific error - * handlers. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Robb Matzke - * Friday, February 27, 1998 - * - * Modifications: - * Albert Cheng, 2000/12/02 - * Show MPI process rank id if applicable. - * Albert Cheng, 2001/07/14 - * Show HDF5 library version information string too. - * - * Raymond Lu, 2003/7/16 - * Print for specified error stack. A line will appear before the error - * messages of each error class. It states the information of library - * name, version number and thread ID. - * - *------------------------------------------------------------------------- - */ -static herr_t -H5E_print_stack(const H5E_t *estack, FILE *stream, hbool_t bk_compatible) -{ - H5E_print_t eprint; /* Callback information to pass to H5E_walk_stack_cb() */ - herr_t ret_value = SUCCEED; - - /* Don't clear the error stack! :-) */ - FUNC_ENTER_NOAPI_NOINIT(H5E_print_stack) - - /* Sanity check */ - assert(estack); - - /* If no stream was given, use stderr */ - if (!stream) - eprint.stream = stderr; - else - eprint.stream = stream; - - /* Reset the original error class information */ - HDmemset(&eprint.cls,0,sizeof(H5E_cls_t)); - - /* Walk the error stack */ - if(bk_compatible) { - if(H5E_walk_stack(estack, H5E_WALK_DOWNWARD, H5E_walk_cb, NULL, TRUE, (void*)&eprint)<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTLIST, FAIL, "can't walk error stack") - } else { - if(H5E_walk_stack(estack, H5E_WALK_DOWNWARD, NULL, H5E_walk_stack_cb, FALSE, (void*)&eprint)<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTLIST, FAIL, "can't walk error stack") - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - - -/*------------------------------------------------------------------------- - * Function: H5Ewalk - * - * Purpose: This function is for backward compatbility. - * Walks the error stack for the current thread and calls some - * function for each error along the way. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Raymond Lu - * Sep 16, 2003 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -herr_t -H5Ewalk(H5E_direction_t direction, H5E_walk_t func, void *client_data) -{ - H5E_t *estack; /* Error stack to operate on */ - herr_t ret_value=SUCCEED; /* Return value */ - - /* Don't clear the error stack! :-) */ - FUNC_ENTER_API_NOCLEAR(H5Ewalk, FAIL) - /*NO TRACE*/ - - if((estack = H5E_get_my_stack())==NULL) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ - HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") - - /* Walk the error stack */ - if(H5E_walk_stack(estack, direction, func, NULL, TRUE, client_data)<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTLIST, FAIL, "can't walk error stack") - -done: - FUNC_LEAVE_API(ret_value) -} +} /* end H5Eprint2() */ /*------------------------------------------------------------------------- - * Function: H5Ewalk_stack + * Function: H5Ewalk2 * * Purpose: Walks the error stack for the current thread and calls some * function for each error along the way. @@ -2061,431 +1392,42 @@ done: * Programmer: Robb Matzke * Friday, February 27, 1998 * - * Modifications: - * - * Raymond Lu - * Wednesday, July 16, 2003 - * Let it walk through specified error stack. - * *------------------------------------------------------------------------- */ herr_t -H5Ewalk_stack(hid_t err_stack, H5E_direction_t direction, H5E_walk_stack_t stack_func, void *client_data) +H5Ewalk2(hid_t err_stack, H5E_direction_t direction, H5E_walk2_t stack_func, void *client_data) { - H5E_t *estack; /* Error stack to operate on */ - herr_t ret_value=SUCCEED; /* Return value */ + H5E_t *estack; /* Error stack to operate on */ + herr_t ret_value = SUCCEED; /* Return value */ /* Don't clear the error stack! :-) */ - FUNC_ENTER_API_NOCLEAR(H5Ewalk_stack, FAIL) + FUNC_ENTER_API_NOCLEAR(H5Ewalk2, FAIL) /*NO TRACE*/ /* Need to check for errors */ if(err_stack == H5E_DEFAULT) { - if((estack = H5E_get_my_stack())==NULL) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + if(NULL == (estack = H5E_get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") } /* end if */ else { /* Only clear the error stack if it's not the default stack */ H5E_clear_stack(NULL); - if((estack = H5I_object_verify(err_stack, H5I_ERROR_STACK))==NULL) + if(NULL == (estack = H5I_object_verify(err_stack, H5I_ERROR_STACK))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") } /* end else */ /* Walk the error stack */ - if(H5E_walk_stack(estack, direction, NULL, stack_func, FALSE, client_data)<0) + if(H5E_walk2(estack, direction, NULL, stack_func, FALSE, client_data) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTLIST, FAIL, "can't walk error stack") done: FUNC_LEAVE_API(ret_value) -} - - -/*------------------------------------------------------------------------- - * Function: H5E_walk_stack - * - * Purpose: Private function for H5Ewalk. - * Walks the error stack, calling the specified function for - * each error on the stack. The DIRECTION argument determines - * whether the stack is walked from the inside out or the - * outside in. The value H5E_WALK_UPWARD means begin with the - * most specific error and end at the API; H5E_WALK_DOWNWARD - * means to start at the API and end at the inner-most function - * where the error was first detected. - * - * The function pointed to by STACK_FUNC will be called for - * each error record in the error stack. It's arguments will - * include an index number (beginning at zero regardless of - * stack traversal direction), an error stack entry, and the - * CLIENT_DATA pointer passed to H5E_print_stack. - * - * The function FUNC is also provided for backward compatibility. - * When BK_COMPATIBLE is set to be TRUE, FUNC is used to be - * compatible with older library. If BK_COMPATIBLE is FALSE, - * STACK_FUNC is used. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Robb Matzke - * Friday, December 12, 1997 - * - * Modifications: - * - * Raymond Lu - * Wednesday, July 16, 2003 - * Let it walk through specified error stack. - * - * Raymond Lu - * Friday, May 12, 2006 - * Added backward compatibility support. FUNC is for older - * library; STACK_FUNC is for new library. - * - *------------------------------------------------------------------------- - */ -static herr_t -H5E_walk_stack(const H5E_t *estack, H5E_direction_t direction, H5E_walk_t func, H5E_walk_stack_t stack_func, - hbool_t bk_compatible, void *client_data) -{ - int i; /* Local index variable */ - herr_t status; /* Status from callback function */ - herr_t ret_value=SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT(H5E_walk_stack) - - /* Sanity check */ - assert (estack); - - /* check args, but rather than failing use some default value */ - if (direction!=H5E_WALK_UPWARD && direction!=H5E_WALK_DOWNWARD) - direction = H5E_WALK_UPWARD; - - /* Walk the stack if a callback function was given */ - if(bk_compatible && func) { - H5E_error_t old_err; - - status = SUCCEED; - if(H5E_WALK_UPWARD == direction) { - for(i = 0; i < (int)estack->nused && status >= 0; i++) { - /*Copy each error record on the stack and pass it to callback function.*/ - old_err.maj_num = estack->slot[i].maj_num; - old_err.min_num = estack->slot[i].min_num; - old_err.func_name = estack->slot[i].func_name; - old_err.file_name = estack->slot[i].file_name; - old_err.desc = estack->slot[i].desc; - old_err.line = estack->slot[i].line; - - status = (func)((unsigned)i, &old_err, client_data); - } /* end for */ - } /* end if */ - else { - H5_CHECK_OVERFLOW(estack->nused - 1, size_t, int); - for(i = (int)(estack->nused - 1); i >= 0 && status >= 0; i--) { - /*Copy each error record on the stack and pass it to callback function.*/ - old_err.maj_num = estack->slot[i].maj_num; - old_err.min_num = estack->slot[i].min_num; - old_err.func_name = estack->slot[i].func_name; - old_err.file_name = estack->slot[i].file_name; - old_err.desc = estack->slot[i].desc; - old_err.line = estack->slot[i].line; - - status = (func)((unsigned)(estack->nused - (size_t)(i + 1)), &old_err, client_data); - } /* end for */ - } /* end else */ - - if(status<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTLIST, FAIL, "can't walk error stack") - } else if(!bk_compatible && stack_func) { - status = SUCCEED; - if(H5E_WALK_UPWARD == direction) { - for(i = 0; i < (int)estack->nused && status >= 0; i++) - status = (stack_func)((unsigned)i, estack->slot+i, client_data); - } /* end if */ - else { - H5_CHECK_OVERFLOW(estack->nused - 1, size_t, int); - for(i = (int)(estack->nused - 1); i >= 0 && status >= 0; i--) - status = (stack_func)((unsigned)(estack->nused-(size_t)(i+1)), estack->slot+i, client_data); - } /* end else */ - - if(status<0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTLIST, FAIL, "can't walk error stack") - } /* end if */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5Ewalk2() */ /*------------------------------------------------------------------------- - * Function: H5E_walk_stack_cb - * - * Purpose: This is a default error stack traversal callback function - * that prints error messages to the specified output stream. - * It is not meant to be called directly but rather as an - * argument to the H5Ewalk_stack() function. This function is - * called also by H5Eprint_stack(). Application writers are - * encouraged to use this function as a model for their own - * error stack walking functions. - * - * N is a counter for how many times this function has been - * called for this particular traversal of the stack. It always - * begins at zero for the first error on the stack (either the - * top or bottom error, or even both, depending on the traversal - * direction and the size of the stack). - * - * ERR_DESC is an error description. It contains all the - * information about a particular error. - * - * CLIENT_DATA is the same pointer that was passed as the - * CLIENT_DATA argument of H5Ewalk(). It is expected to be a - * file pointer (or stderr if null). - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Robb Matzke - * Friday, December 12, 1997 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static herr_t -H5E_walk_stack_cb(unsigned n, const H5E_error_stack_t *err_desc, void *client_data) -{ - H5E_print_t *eprint = (H5E_print_t *)client_data; - FILE *stream; /* I/O stream to print output to */ - H5E_cls_t *cls_ptr; /* Pointer to error class */ - H5E_msg_t *maj_ptr; /* Pointer to major error info */ - H5E_msg_t *min_ptr; /* Pointer to minor error info */ - const char *maj_str = "No major description"; /* Major error description */ - const char *min_str = "No minor description"; /* Minor error description */ - unsigned have_desc=1; /* Flag to indicate whether the error has a "real" description */ - - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5E_walk_stack_cb) - - /* Check arguments */ - assert (err_desc); - - /* If no client data was passed, output to stderr */ - if (!client_data) stream = stderr; - else stream = eprint->stream; - - /* Get descriptions for the major and minor error numbers */ - maj_ptr = H5I_object_verify(err_desc->maj_num, H5I_ERROR_MSG); - min_ptr = H5I_object_verify(err_desc->min_num, H5I_ERROR_MSG); - assert(maj_ptr && min_ptr); - if(maj_ptr->msg) - maj_str = maj_ptr->msg; - if(min_ptr->msg) - min_str = min_ptr->msg; - - /* Get error class info */ - cls_ptr = maj_ptr->cls; - - /* Print error class header if new class */ - if(eprint->cls.lib_name==NULL || HDstrcmp(cls_ptr->lib_name, eprint->cls.lib_name)) { - /* update to the new class information */ - if(cls_ptr->cls_name) eprint->cls.cls_name = cls_ptr->cls_name; - if(cls_ptr->lib_name) eprint->cls.lib_name = cls_ptr->lib_name; - if(cls_ptr->lib_vers) eprint->cls.lib_vers = cls_ptr->lib_vers; - - fprintf (stream, "%s-DIAG: Error detected in %s (%s) ", cls_ptr->cls_name, cls_ptr->lib_name, cls_ptr->lib_vers); - - /* try show the process or thread id in multiple processes cases*/ -#ifdef H5_HAVE_PARALLEL - { int mpi_rank, mpi_initialized; - MPI_Initialized(&mpi_initialized); - if (mpi_initialized){ - MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank); - fprintf (stream, "MPI-process %d", mpi_rank); - }else - fprintf (stream, "thread 0"); - } -#elif defined(H5_HAVE_THREADSAFE) -#ifdef WIN32 - fprintf (stream, "some thread: no way to know the thread number from pthread on windows"); -#else - fprintf (stream, "thread %lu", (unsigned long)pthread_self()); -#endif -#else - fprintf (stream, "thread 0"); -#endif - fprintf (stream, ":\n"); - } - - /* Check for "real" error description - used to format output more nicely */ - if(err_desc->desc==NULL || HDstrlen(err_desc->desc)==0) - have_desc=0; - - /* Print error message */ - fprintf (stream, "%*s#%03u: %s line %u in %s()%s%s\n", - H5E_INDENT, "", n, err_desc->file_name, err_desc->line, - err_desc->func_name, (have_desc ? ": " : ""), - (have_desc ? err_desc->desc : "")); - fprintf (stream, "%*smajor: %s\n", H5E_INDENT*2, "", maj_str); - fprintf (stream, "%*sminor: %s\n", H5E_INDENT*2, "", min_str); - - FUNC_LEAVE_NOAPI(SUCCEED) -} - - -/*------------------------------------------------------------------------- - * Function: H5E_walk_cb - * - * Purpose: This function is for backward compatibility. - * This is a default error stack traversal callback function - * that prints error messages to the specified output stream. - * This function is for backward compatibility with v1.6. - * It is not meant to be called directly but rather as an - * argument to the H5Ewalk() function. This function is called - * also by H5Eprint(). Application writers are encouraged to - * use this function as a model for their own error stack - * walking functions. - * - * N is a counter for how many times this function has been - * called for this particular traversal of the stack. It always - * begins at zero for the first error on the stack (either the - * top or bottom error, or even both, depending on the traversal - * direction and the size of the stack). - * - * ERR_DESC is an error description. It contains all the - * information about a particular error. - * - * CLIENT_DATA is the same pointer that was passed as the - * CLIENT_DATA argument of H5Ewalk(). It is expected to be a - * file pointer (or stderr if null). - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Raymond Lu - * Thursday, May 11, 2006 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static herr_t -H5E_walk_cb(unsigned n, const H5E_error_t *err_desc, void *client_data) -{ - H5E_print_t *eprint = (H5E_print_t *)client_data; - FILE *stream; /* I/O stream to print output to */ - H5E_cls_t *cls_ptr; /* Pointer to error class */ - H5E_msg_t *maj_ptr; /* Pointer to major error info */ - H5E_msg_t *min_ptr; /* Pointer to minor error info */ - const char *maj_str = "No major description"; /* Major error description */ - const char *min_str = "No minor description"; /* Minor error description */ - unsigned have_desc=1; /* Flag to indicate whether the error has a "real" description */ - - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5E_walk_cb) - - /* Check arguments */ - assert (err_desc); - - /* If no client data was passed, output to stderr */ - if (!client_data) stream = stderr; - else stream = eprint->stream; - - /* Get descriptions for the major and minor error numbers */ - maj_ptr = H5I_object_verify(err_desc->maj_num, H5I_ERROR_MSG); - min_ptr = H5I_object_verify(err_desc->min_num, H5I_ERROR_MSG); - assert(maj_ptr && min_ptr); - if(maj_ptr->msg) - maj_str = maj_ptr->msg; - if(min_ptr->msg) - min_str = min_ptr->msg; - - /* Get error class info */ - cls_ptr = maj_ptr->cls; - - /* Print error class header if new class */ - if(eprint->cls.lib_name==NULL || HDstrcmp(cls_ptr->lib_name, eprint->cls.lib_name)) { - /* update to the new class information */ - if(cls_ptr->cls_name) eprint->cls.cls_name = cls_ptr->cls_name; - if(cls_ptr->lib_name) eprint->cls.lib_name = cls_ptr->lib_name; - if(cls_ptr->lib_vers) eprint->cls.lib_vers = cls_ptr->lib_vers; - - fprintf (stream, "%s-DIAG: Error detected in %s (%s) ", cls_ptr->cls_name, cls_ptr->lib_name, cls_ptr->lib_vers); - - /* try show the process or thread id in multiple processes cases*/ -#ifdef H5_HAVE_PARALLEL - { int mpi_rank, mpi_initialized; - MPI_Initialized(&mpi_initialized); - if (mpi_initialized){ - MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank); - fprintf (stream, "MPI-process %d", mpi_rank); - }else - fprintf (stream, "thread 0"); - } -#elif defined(H5_HAVE_THREADSAFE) -#ifdef WIN32 - fprintf (stream, "some thread: no way to know the thread number from pthread on windows"); -#else - fprintf (stream, "thread %lu", (unsigned long)pthread_self()); -#endif -#else - fprintf (stream, "thread 0"); -#endif - fprintf (stream, ":\n"); - } - - /* Check for "real" error description - used to format output more nicely */ - if(err_desc->desc==NULL || HDstrlen(err_desc->desc)==0) - have_desc=0; - - /* Print error message */ - fprintf (stream, "%*s#%03u: %s line %u in %s()%s%s\n", - H5E_INDENT, "", n, err_desc->file_name, err_desc->line, - err_desc->func_name, (have_desc ? ": " : ""), - (have_desc ? err_desc->desc : "")); - fprintf (stream, "%*smajor: %s\n", H5E_INDENT*2, "", maj_str); - fprintf (stream, "%*sminor: %s\n", H5E_INDENT*2, "", min_str); - - FUNC_LEAVE_NOAPI(SUCCEED) -} - - -/*------------------------------------------------------------------------- - * Function: H5Eget_auto - * - * Purpose: This function is for backward compatbility. - * Returns the current settings for the automatic error stack - * traversal function and its data for specific error stack. - * Either (or both) arguments may be null in which case the - * value is not returned. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Raymond Lu - * Sep 16, 2003 - * - *------------------------------------------------------------------------- - */ -herr_t -H5Eget_auto(H5E_auto_t *func, void **client_data) -{ - H5E_t *estack; /* Error stack to operate on */ - H5E_auto_op_t f; /* Error stack function */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_API(H5Eget_auto, FAIL) - H5TRACE2("e", "*x**x", func, client_data); - - /* Retrieve default error stack */ - if(NULL == (estack = H5E_get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ - HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") - - /* Get the automatic error reporting information */ - if(H5E_get_auto_stack(estack, FALSE, &f, client_data) < 0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get automatic error info") - if(func) - *func = f.efunc; - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5Eget_auto() */ - - -/*------------------------------------------------------------------------- - * Function: H5Eget_auto_stack + * Function: H5Eget_auto2 * * Purpose: Returns the current settings for the automatic error stack * traversal function and its data for specific error stack. @@ -2500,13 +1442,13 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Eget_auto_stack(hid_t estack_id, H5E_auto_stack_t *func, void **client_data) +H5Eget_auto2(hid_t estack_id, H5E_auto2_t *func, void **client_data) { H5E_t *estack; /* Error stack to operate on */ H5E_auto_op_t f; /* Error stack function */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API(H5Eget_auto_stack, FAIL) + FUNC_ENTER_API(H5Eget_auto2, FAIL) H5TRACE3("e", "i*x**x", estack_id, func, client_data); if(estack_id == H5E_DEFAULT) { @@ -2518,103 +1460,18 @@ H5Eget_auto_stack(hid_t estack_id, H5E_auto_stack_t *func, void **client_data) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") /* Get the automatic error reporting information */ - if(H5E_get_auto_stack(estack, TRUE, &f, client_data) < 0) + if(H5E_get_auto2(estack, TRUE, &f, client_data) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get automatic error info") if(func) - *func = f.stack_efunc; + *func = f.efunc2; done: FUNC_LEAVE_API(ret_value) -} /* end H5Eget_auto_stack() */ +} /* end H5Eget_auto2() */ /*------------------------------------------------------------------------- - * Function: H5E_get_auto_stack - * - * Purpose: Private function to return the current settings for the - * automatic error stack traversal function and its data - * for specific error stack. Either (or both) arguments may - * be null in which case the value is not returned. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Raymond Lu - * July 18, 2003 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5E_get_auto_stack(const H5E_t *estack, hbool_t new_api, H5E_auto_op_t *func, void **client_data) -{ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5E_get_auto_stack) - - HDassert(estack); - - /* Retrieve the requested information */ - if(func) { - if(new_api) - func->stack_efunc = estack->u.func_stack; - else - func->efunc = estack->u.func; - } /* end if */ - if(client_data) - *client_data = estack->auto_data; - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5E_get_auto_stack() */ - - -/*------------------------------------------------------------------------- - * Function: H5Eset_auto - * - * Purpose: This function is for backward compatbility. - * Turns on or off automatic printing of errors for certain - * error stack. When turned on (non-null FUNC pointer) any - * API function which returns an error indication will first - * call FUNC passing it CLIENT_DATA as an argument. - * - * The default values before this function is called are - * H5Eprint() with client data being the standard error stream, - * stderr. - * - * Automatic stack traversal is always in the H5E_WALK_DOWNWARD - * direction. - * - * See Also: H5Ewalk() - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Raymond Lu - * Sep 16, 2003 - * - *------------------------------------------------------------------------- - */ -herr_t -H5Eset_auto(H5E_auto_t func, void *client_data) -{ - H5E_t *estack; /* Error stack to operate on */ - H5E_auto_op_t f; /* Error stack function */ - herr_t ret_value = SUCCEED; /* Return value */ - - /* Don't clear the error stack! :-) */ - FUNC_ENTER_API_NOCLEAR(H5Eset_auto, FAIL) - H5TRACE2("e", "x*x", func, client_data); - - if(NULL == (estack = H5E_get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ - HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") - - /* Set the automatic error reporting information */ - f.efunc = func; - if(H5E_set_auto_stack(estack, FALSE, &f, client_data) < 0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't set automatic error info") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5Eset_auto() */ - - -/*------------------------------------------------------------------------- - * Function: H5Eset_auto_stack + * Function: H5Eset_auto2 * * Purpose: Turns on or off automatic printing of errors for certain * error stack. When turned on (non-null FUNC pointer) any @@ -2628,8 +1485,6 @@ done: * Automatic stack traversal is always in the H5E_WALK_DOWNWARD * direction. * - * See Also: H5Ewalk() - * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke @@ -2638,14 +1493,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Eset_auto_stack(hid_t estack_id, H5E_auto_stack_t func, void *client_data) +H5Eset_auto2(hid_t estack_id, H5E_auto2_t func, void *client_data) { H5E_t *estack; /* Error stack to operate on */ H5E_auto_op_t f; /* Error stack function */ herr_t ret_value = SUCCEED; /* Return value */ /* Don't clear the error stack! :-) */ - FUNC_ENTER_API_NOCLEAR(H5Eset_auto_stack, FAIL) + FUNC_ENTER_API_NOCLEAR(H5Eset_auto2, FAIL) H5TRACE3("e", "ix*x", estack_id, func, client_data); if(estack_id == H5E_DEFAULT) { @@ -2657,57 +1512,13 @@ H5Eset_auto_stack(hid_t estack_id, H5E_auto_stack_t func, void *client_data) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") /* Set the automatic error reporting information */ - f.stack_efunc = func; - if(H5E_set_auto_stack(estack, TRUE, &f, client_data)<0) + f.efunc2 = func; + if(H5E_set_auto2(estack, TRUE, &f, client_data) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't set automatic error info") done: FUNC_LEAVE_API(ret_value) -} /* end H5Eset_auto_stack() */ - - -/*------------------------------------------------------------------------- - * Function: H5E_set_auto_stack - * - * Purpose: Private function to turn on or off automatic printing of - * errors for certain error stack. When turned on (non-null - * FUNC pointer) any API function which returns an error - * indication will first call FUNC passing it CLIENT_DATA - * as an argument. - * - * The default values before this function is called are - * H5Eprint() with client data being the standard error stream, - * stderr. - * - * Automatic stack traversal is always in the H5E_WALK_DOWNWARD - * direction. - * - * See Also: H5Ewalk() - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Robb Matzke - * Friday, February 27, 1998 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5E_set_auto_stack(H5E_t *estack, hbool_t new_api, H5E_auto_op_t *func, void *client_data) -{ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5E_set_auto_stack) - - HDassert(estack); - - /* Set the automatic error reporting info */ - estack->new_api = new_api; - if(new_api) - estack->u.func_stack = func->stack_efunc; - else - estack->u.func = func->efunc; - estack->auto_data = client_data; - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5E_set_auto_stack() */ +} /* end H5Eset_auto2() */ /*------------------------------------------------------------------------- @@ -2722,14 +1533,12 @@ H5E_set_auto_stack(H5E_t *estack, hbool_t new_api, H5E_auto_op_t *func, void *cl * Programmer: Quincey Koziol * Wednesday, August 6, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t H5E_dump_api_stack(int is_api) { - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5E_dump_api_stack, FAIL) @@ -2739,22 +1548,22 @@ H5E_dump_api_stack(int is_api) assert(estack); if(estack->new_api) { - if (estack->u.func_stack) - (void)((estack->u.func_stack)(H5E_DEFAULT, estack->auto_data)); + if(estack->u.func2) + (void)((estack->u.func2)(H5E_DEFAULT, estack->auto_data)); } /* end if */ else { - if (estack->u.func) + if(estack->u.func) (void)((estack->u.func)(estack->auto_data)); } /* end else */ } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5E_dump_api_stack() */ /*------------------------------------------------------------------------- - * Function: H5Eauto_is_stack + * Function: H5Eauto_is_v2 * * Purpose: Determines if the error auto reporting function for an * error stack conforms to the H5E_auto_stack_t typedef @@ -2766,32 +1575,30 @@ done: * Programmer: Quincey Koziol * Wednesday, September 8, 2004 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t -H5Eauto_is_stack(hid_t estack_id, unsigned *is_stack) +H5Eauto_is_v2(hid_t estack_id, unsigned *is_stack) { H5E_t *estack; /* Error stack to operate on */ - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API(H5Eauto_is_stack, FAIL) + FUNC_ENTER_API(H5Eauto_is_v2, FAIL) H5TRACE2("e", "i*Iu", estack_id, is_stack); if(estack_id == H5E_DEFAULT) { - if((estack = H5E_get_my_stack())==NULL) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + if(NULL == (estack = H5E_get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") } /* end if */ else - if((estack = H5I_object_verify(estack_id, H5I_ERROR_STACK))==NULL) + if(NULL == (estack = H5I_object_verify(estack_id, H5I_ERROR_STACK))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") /* Check if the error stack reporting function is the "newer" stack type */ if(is_stack) - *is_stack=estack->new_api; + *is_stack = estack->new_api; done: FUNC_LEAVE_API(ret_value) -} /* end H5Eauto_is_stack() */ +} /* end H5Eauto_is_v2() */ diff --git a/src/H5Edeprec.c b/src/H5Edeprec.c new file mode 100644 index 0000000..13a2f3d --- /dev/null +++ b/src/H5Edeprec.c @@ -0,0 +1,433 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5Edeprec.c + * April 11 2007 + * Quincey Koziol <koziol@hdfgroup.org> + * + * Purpose: Deprecated functions from the H5E interface. These + * functions are here for compatibility purposes and may be + * removed in the future. Applications should switch to the + * newer APIs. + * + *------------------------------------------------------------------------- + */ + +/****************/ +/* Module Setup */ +/****************/ + +#define H5E_PACKAGE /*suppress error about including H5Epkg */ + +/* Interface initialization */ +#define H5_INTERFACE_INIT_FUNC H5E_init_deprec_interface + + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Epkg.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5MMprivate.h" /* Memory management */ + + +/****************/ +/* Local Macros */ +/****************/ + + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Package Typedefs */ +/********************/ + + +/********************/ +/* Local Prototypes */ +/********************/ + + +/*********************/ +/* Package Variables */ +/*********************/ + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + + + +/*-------------------------------------------------------------------------- +NAME + H5E_init_deprec_interface -- Initialize interface-specific information +USAGE + herr_t H5E_init_deprec_interface() +RETURNS + Non-negative on success/Negative on failure +DESCRIPTION + Initializes any interface-specific data or routines. (Just calls + H5E_init() currently). + +--------------------------------------------------------------------------*/ +static herr_t +H5E_init_deprec_interface(void) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5E_init_deprec_interface) + + FUNC_LEAVE_NOAPI(H5E_init()) +} /* H5E_init_deprec_interface() */ + + +/*------------------------------------------------------------------------- + * Function: H5Eget_major + * + * Purpose: Retrieves a major error message. + * + * Return: Returns message if succeeds. + * otherwise returns NULL. + * + * Programmer: Raymond Lu + * Friday, July 14, 2003 + * + *------------------------------------------------------------------------- + */ +const char * +H5Eget_major(H5E_major_t maj) +{ + H5E_msg_t *msg; /* Pointer to error message */ + ssize_t size = 0; /* Return value */ + H5E_type_t type; + char *msg_str; + char *ret_value = NULL; + + FUNC_ENTER_API_NOCLEAR(H5Eget_major, NULL) + + /* Get the message object */ + if(NULL == (msg = H5I_object_verify(maj, H5I_ERROR_MSG))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a error message ID") + + /* Get the message's text */ + if((size = H5E_get_msg(msg, &type, NULL, (size_t)0)) < 0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "can't get error message text") + + if(type != H5E_MAJOR) + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "Error message isn't a major one") + + /* Don't know who is going to free it */ + msg_str = (char *)H5MM_malloc((size_t)(++size) * sizeof(char)); + + if(H5E_get_msg(msg, NULL, msg_str, (size_t)size) < 0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "can't get error message text") + + ret_value = msg_str; + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Eget_major() */ + + +/*------------------------------------------------------------------------- + * Function: H5Eget_minor + * + * Purpose: Retrieves a minor error message. + * + * Return: Returns message if succeeds. + * otherwise returns NULL. + * + * Programmer: Raymond Lu + * Friday, July 14, 2003 + * + *------------------------------------------------------------------------- + */ +const char * +H5Eget_minor(H5E_minor_t min) +{ + H5E_msg_t *msg; /* Pointer to error message */ + ssize_t size = 0; /* Return value */ + H5E_type_t type; + char *msg_str; + char *ret_value = NULL; + + FUNC_ENTER_API_NOCLEAR(H5Eget_minor, NULL) + + /* Get the message object */ + if(NULL == (msg = H5I_object_verify(min, H5I_ERROR_MSG))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a error message ID") + + /* Get the message's text */ + if((size = H5E_get_msg(msg, &type, NULL, (size_t)0)) < 0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "can't get error message text") + + if(type != H5E_MINOR) + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "Error message isn't a minor one") + + /* Don't know who is going to free it */ + msg_str = (char *)H5MM_malloc((size_t)(++size) * sizeof(char)); + + if(H5E_get_msg(msg, NULL, msg_str, (size_t)size) < 0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "can't get error message text") + + ret_value = msg_str; + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Eget_minor() */ + + +/*------------------------------------------------------------------------- + * Function: H5Epush + * + * Purpose: This function definition is for backward compatibility only. + * It doesn't have error stack and error class as parameters. + * The old definition of major and minor is casted as HID_T + * in H5Epublic.h + * + * Notes: Basically a public API wrapper around the H5E_push2 + * function. For backward compatibility, it maintains the + * same parameter as the old function, in contrary to + * H5Epush2. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Raymond Lu + * Tuesday, Sep 16, 2003 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Epush(const char *file, const char *func, unsigned line, + H5E_major_t maj, H5E_minor_t min, const char *str) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + /* Don't clear the error stack! :-) */ + FUNC_ENTER_API_NOCLEAR(H5Epush, FAIL) + H5TRACE6("e", "*s*sIuii*s", file, func, line, maj, min, str); + + /* Push the error on the default error stack */ + if(H5E_push_stack(NULL, file, func, line, H5E_ERR_CLS_g, maj, min, str) < 0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't push error on stack") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Epush() */ + + +/*------------------------------------------------------------------------- + * Function: H5Eclear + * + * Purpose: This function is for backward compatbility. + * Clears the error stack for the specified error stack. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Raymond Lu + * Wednesday, July 16, 2003 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Eclear(void) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + /* Don't clear the error stack! :-) */ + FUNC_ENTER_API_NOCLEAR(H5Eclear, FAIL) + H5TRACE0("e",""); + + /* Clear the default error stack */ + if(H5E_clear_stack(NULL) < 0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't clear error stack") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Eclear() */ + + +/*------------------------------------------------------------------------- + * Function: H5Eprint + * + * Purpose: This function is for backward compatbility. + * Prints the error stack in some default way. This is just a + * convenience function for H5Ewalk() with a function that + * prints error messages. Users are encouraged to write there + * own more specific error handlers. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Raymond Lu + * Sep 16, 2003 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Eprint(FILE *stream) +{ + H5E_t *estack; /* Error stack to operate on */ + herr_t ret_value = SUCCEED; /* Return value */ + + /* Don't clear the error stack! :-) */ + FUNC_ENTER_API_NOCLEAR(H5Eprint, FAIL) + /*NO TRACE*/ + + if(NULL == (estack = H5E_get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") + + /* Print error stack */ + if(H5E_print2(estack, stream, TRUE) < 0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTLIST, FAIL, "can't display error stack") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Eprint() */ + + +/*------------------------------------------------------------------------- + * Function: H5Ewalk + * + * Purpose: This function is for backward compatbility. + * Walks the error stack for the current thread and calls some + * function for each error along the way. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Raymond Lu + * Sep 16, 2003 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Ewalk(H5E_direction_t direction, H5E_walk_t func, void *client_data) +{ + H5E_t *estack; /* Error stack to operate on */ + herr_t ret_value = SUCCEED; /* Return value */ + + /* Don't clear the error stack! :-) */ + FUNC_ENTER_API_NOCLEAR(H5Ewalk, FAIL) + /*NO TRACE*/ + + if(NULL == (estack = H5E_get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") + + /* Walk the error stack */ + if(H5E_walk2(estack, direction, func, NULL, TRUE, client_data) < 0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTLIST, FAIL, "can't walk error stack") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Ewalk() */ + + +/*------------------------------------------------------------------------- + * Function: H5Eget_auto + * + * Purpose: This function is for backward compatbility. + * Returns the current settings for the automatic error stack + * traversal function and its data for specific error stack. + * Either (or both) arguments may be null in which case the + * value is not returned. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Raymond Lu + * Sep 16, 2003 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Eget_auto(H5E_auto_t *func, void **client_data) +{ + H5E_t *estack; /* Error stack to operate on */ + H5E_auto_op_t f; /* Error stack function */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(H5Eget_auto, FAIL) + H5TRACE2("e", "*x**x", func, client_data); + + /* Retrieve default error stack */ + if(NULL == (estack = H5E_get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") + + /* Get the automatic error reporting information */ + if(H5E_get_auto2(estack, FALSE, &f, client_data) < 0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get automatic error info") + if(func) + *func = f.efunc; + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Eget_auto() */ + + +/*------------------------------------------------------------------------- + * Function: H5Eset_auto + * + * Purpose: This function is for backward compatbility. + * Turns on or off automatic printing of errors for certain + * error stack. When turned on (non-null FUNC pointer) any + * API function which returns an error indication will first + * call FUNC passing it CLIENT_DATA as an argument. + * + * The default values before this function is called are + * H5Eprint() with client data being the standard error stream, + * stderr. + * + * Automatic stack traversal is always in the H5E_WALK_DOWNWARD + * direction. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Raymond Lu + * Sep 16, 2003 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Eset_auto(H5E_auto_t func, void *client_data) +{ + H5E_t *estack; /* Error stack to operate on */ + H5E_auto_op_t f; /* Error stack function */ + herr_t ret_value = SUCCEED; /* Return value */ + + /* Don't clear the error stack! :-) */ + FUNC_ENTER_API_NOCLEAR(H5Eset_auto, FAIL) + H5TRACE2("e", "x*x", func, client_data); + + if(NULL == (estack = H5E_get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") + + /* Set the automatic error reporting information */ + f.efunc = func; + if(H5E_set_auto2(estack, FALSE, &f, client_data) < 0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't set automatic error info") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Eset_auto() */ + diff --git a/src/H5Eint.c b/src/H5Eint.c new file mode 100644 index 0000000..a3568d7 --- /dev/null +++ b/src/H5Eint.c @@ -0,0 +1,859 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5Eint.c + * April 11 2007 + * Quincey Koziol <koziol@hdfgroup.org> + * + * Purpose: General use, "internal" routines for error handling. + * + *------------------------------------------------------------------------- + */ + +/****************/ +/* Module Setup */ +/****************/ + +#define H5E_PACKAGE /*suppress error about including H5Epkg */ + +/* Interface initialization */ +#define H5_INTERFACE_INIT_FUNC H5E_init_int_interface + + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Epkg.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ + + +/****************/ +/* Local Macros */ +/****************/ + + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Package Typedefs */ +/********************/ + + +/********************/ +/* Local Prototypes */ +/********************/ +static herr_t H5E_walk_cb(unsigned n, const H5E_error_t *err_desc, + void *client_data); +static herr_t H5E_walk2_cb(unsigned n, const H5E_error2_t *err_desc, + void *client_data); +static herr_t H5E_clear_entries(H5E_t *estack, size_t nentries); + + +/*********************/ +/* Package Variables */ +/*********************/ + +#ifndef H5_HAVE_THREADSAFE +/* + * The current error stack. + */ +H5E_t H5E_stack_g[1]; +#endif /* H5_HAVE_THREADSAFE */ + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/* HDF5 error class ID */ +hid_t H5E_ERR_CLS_g = FAIL; + +/* + * Predefined errors. These are initialized at runtime in H5E_init_interface() + * in this source file. + */ +/* Include the automatically generated error code definitions */ +#include "H5Edefin.h" + + +/*******************/ +/* Local Variables */ +/*******************/ + +#ifdef H5_HAVE_PARALLEL +/* + * variables used for MPI error reporting + */ +char H5E_mpi_error_str[MPI_MAX_ERROR_STRING]; +int H5E_mpi_error_str_len; +#endif + + + +/*-------------------------------------------------------------------------- +NAME + H5E_init_int_interface -- Initialize interface-specific information +USAGE + herr_t H5E_init_int_interface() +RETURNS + Non-negative on success/Negative on failure +DESCRIPTION + Initializes any interface-specific data or routines. (Just calls + H5E_init() currently). + +--------------------------------------------------------------------------*/ +static herr_t +H5E_init_int_interface(void) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5E_init_int_interface) + + FUNC_LEAVE_NOAPI(H5E_init()) +} /* H5E_init_int_interface() */ + + +/*------------------------------------------------------------------------- + * Function: H5E_get_msg + * + * Purpose: Private function to retrieve an error message. + * + * Return: Non-negative for name length if succeeds(zero means no name); + * otherwise returns negative value. + * + * Programmer: Raymond Lu + * Friday, July 14, 2003 + * + *------------------------------------------------------------------------- + */ +ssize_t +H5E_get_msg(const H5E_msg_t *msg, H5E_type_t *type, char *msg_str, size_t size) +{ + ssize_t len; /* Length of error message */ + + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5E_get_msg) + + /* Check arguments */ + HDassert(msg); + + /* Get the length of the message string */ + len = (ssize_t)HDstrlen(msg->msg); + + /* Copy the message into the user's buffer, if given */ + if(msg_str) { + HDstrncpy(msg_str, msg->msg, MIN((size_t)(len+1), size)); + if((size_t)len >= size) + msg_str[size - 1] = '\0'; + } /* end if */ + + /* Give the message type, if asked */ + if(type) + *type = msg->type; + + /* Set the return value to the full length of the message */ + FUNC_LEAVE_NOAPI(len) +} /* end H5E_get_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5E_walk_cb + * + * Purpose: This function is for backward compatibility. + * This is a default error stack traversal callback function + * that prints error messages to the specified output stream. + * This function is for backward compatibility with v1.6. + * It is not meant to be called directly but rather as an + * argument to the H5Ewalk() function. This function is called + * also by H5Eprint(). Application writers are encouraged to + * use this function as a model for their own error stack + * walking functions. + * + * N is a counter for how many times this function has been + * called for this particular traversal of the stack. It always + * begins at zero for the first error on the stack (either the + * top or bottom error, or even both, depending on the traversal + * direction and the size of the stack). + * + * ERR_DESC is an error description. It contains all the + * information about a particular error. + * + * CLIENT_DATA is the same pointer that was passed as the + * CLIENT_DATA argument of H5Ewalk(). It is expected to be a + * file pointer (or stderr if null). + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Raymond Lu + * Thursday, May 11, 2006 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5E_walk_cb(unsigned n, const H5E_error_t *err_desc, void *client_data) +{ + H5E_print_t *eprint = (H5E_print_t *)client_data; + FILE *stream; /* I/O stream to print output to */ + H5E_cls_t *cls_ptr; /* Pointer to error class */ + H5E_msg_t *maj_ptr; /* Pointer to major error info */ + H5E_msg_t *min_ptr; /* Pointer to minor error info */ + const char *maj_str = "No major description"; /* Major error description */ + const char *min_str = "No minor description"; /* Minor error description */ + unsigned have_desc = 1; /* Flag to indicate whether the error has a "real" description */ + + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5E_walk_cb) + + /* Check arguments */ + HDassert(err_desc); + + /* If no client data was passed, output to stderr */ + if(!client_data) + stream = stderr; + else + stream = eprint->stream; + + /* Get descriptions for the major and minor error numbers */ + maj_ptr = H5I_object_verify(err_desc->maj_num, H5I_ERROR_MSG); + min_ptr = H5I_object_verify(err_desc->min_num, H5I_ERROR_MSG); + HDassert(maj_ptr && min_ptr); + if(maj_ptr->msg) + maj_str = maj_ptr->msg; + if(min_ptr->msg) + min_str = min_ptr->msg; + + /* Get error class info */ + cls_ptr = maj_ptr->cls; + + /* Print error class header if new class */ + if(eprint->cls.lib_name == NULL || HDstrcmp(cls_ptr->lib_name, eprint->cls.lib_name)) { + /* update to the new class information */ + if(cls_ptr->cls_name) + eprint->cls.cls_name = cls_ptr->cls_name; + if(cls_ptr->lib_name) + eprint->cls.lib_name = cls_ptr->lib_name; + if(cls_ptr->lib_vers) + eprint->cls.lib_vers = cls_ptr->lib_vers; + + fprintf(stream, "%s-DIAG: Error detected in %s (%s) ", cls_ptr->cls_name, cls_ptr->lib_name, cls_ptr->lib_vers); + + /* try show the process or thread id in multiple processes cases*/ +#ifdef H5_HAVE_PARALLEL + { + int mpi_rank, mpi_initialized; + + MPI_Initialized(&mpi_initialized); + if(mpi_initialized) { + MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); + fprintf (stream, "MPI-process %d", mpi_rank); + } /* end if */ + else + fprintf(stream, "thread 0"); + } /* end block */ +#elif defined(H5_HAVE_THREADSAFE) +#ifdef WIN32 + fprintf(stream, "some thread: no way to know the thread number from pthread on windows"); +#else + fprintf(stream, "thread %lu", (unsigned long)pthread_self()); +#endif +#else + fprintf(stream, "thread 0"); +#endif + fprintf(stream, ":\n"); + } /* end if */ + + /* Check for "real" error description - used to format output more nicely */ + if(err_desc->desc == NULL || HDstrlen(err_desc->desc) == 0) + have_desc=0; + + /* Print error message */ + fprintf(stream, "%*s#%03u: %s line %u in %s()%s%s\n", + H5E_INDENT, "", n, err_desc->file_name, err_desc->line, + err_desc->func_name, (have_desc ? ": " : ""), + (have_desc ? err_desc->desc : "")); + fprintf(stream, "%*smajor: %s\n", (H5E_INDENT * 2), "", maj_str); + fprintf(stream, "%*sminor: %s\n", (H5E_INDENT * 2), "", min_str); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5E_walk_cb() */ + + +/*------------------------------------------------------------------------- + * Function: H5E_walk2_cb + * + * Purpose: This is a default error stack traversal callback function + * that prints error messages to the specified output stream. + * It is not meant to be called directly but rather as an + * argument to the H5Ewalk2() function. This function is + * called also by H5Eprint2(). Application writers are + * encouraged to use this function as a model for their own + * error stack walking functions. + * + * N is a counter for how many times this function has been + * called for this particular traversal of the stack. It always + * begins at zero for the first error on the stack (either the + * top or bottom error, or even both, depending on the traversal + * direction and the size of the stack). + * + * ERR_DESC is an error description. It contains all the + * information about a particular error. + * + * CLIENT_DATA is the same pointer that was passed as the + * CLIENT_DATA argument of H5Ewalk(). It is expected to be a + * file pointer (or stderr if null). + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Robb Matzke + * Friday, December 12, 1997 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5E_walk2_cb(unsigned n, const H5E_error2_t *err_desc, void *client_data) +{ + H5E_print_t *eprint = (H5E_print_t *)client_data; + FILE *stream; /* I/O stream to print output to */ + H5E_cls_t *cls_ptr; /* Pointer to error class */ + H5E_msg_t *maj_ptr; /* Pointer to major error info */ + H5E_msg_t *min_ptr; /* Pointer to minor error info */ + const char *maj_str = "No major description"; /* Major error description */ + const char *min_str = "No minor description"; /* Minor error description */ + unsigned have_desc = 1; /* Flag to indicate whether the error has a "real" description */ + + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5E_walk2_cb) + + /* Check arguments */ + HDassert(err_desc); + + /* If no client data was passed, output to stderr */ + if(!client_data) + stream = stderr; + else + stream = eprint->stream; + + /* Get descriptions for the major and minor error numbers */ + maj_ptr = H5I_object_verify(err_desc->maj_num, H5I_ERROR_MSG); + min_ptr = H5I_object_verify(err_desc->min_num, H5I_ERROR_MSG); + HDassert(maj_ptr && min_ptr); + if(maj_ptr->msg) + maj_str = maj_ptr->msg; + if(min_ptr->msg) + min_str = min_ptr->msg; + + /* Get error class info */ + cls_ptr = maj_ptr->cls; + + /* Print error class header if new class */ + if(eprint->cls.lib_name == NULL || HDstrcmp(cls_ptr->lib_name, eprint->cls.lib_name)) { + /* update to the new class information */ + if(cls_ptr->cls_name) + eprint->cls.cls_name = cls_ptr->cls_name; + if(cls_ptr->lib_name) + eprint->cls.lib_name = cls_ptr->lib_name; + if(cls_ptr->lib_vers) + eprint->cls.lib_vers = cls_ptr->lib_vers; + + fprintf(stream, "%s-DIAG: Error detected in %s (%s) ", cls_ptr->cls_name, cls_ptr->lib_name, cls_ptr->lib_vers); + + /* try show the process or thread id in multiple processes cases*/ +#ifdef H5_HAVE_PARALLEL + { + int mpi_rank, mpi_initialized; + + MPI_Initialized(&mpi_initialized); + if(mpi_initialized) { + MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); + fprintf(stream, "MPI-process %d", mpi_rank); + } /* end if */ + else + fprintf(stream, "thread 0"); + } /* end block */ +#elif defined(H5_HAVE_THREADSAFE) +#ifdef WIN32 + fprintf(stream, "some thread: no way to know the thread number from pthread on windows"); +#else + fprintf(stream, "thread %lu", (unsigned long)pthread_self()); +#endif +#else + fprintf(stream, "thread 0"); +#endif + fprintf(stream, ":\n"); + } /* end if */ + + /* Check for "real" error description - used to format output more nicely */ + if(err_desc->desc == NULL || HDstrlen(err_desc->desc) == 0) + have_desc = 0; + + /* Print error message */ + fprintf(stream, "%*s#%03u: %s line %u in %s()%s%s\n", + H5E_INDENT, "", n, err_desc->file_name, err_desc->line, + err_desc->func_name, (have_desc ? ": " : ""), + (have_desc ? err_desc->desc : "")); + fprintf(stream, "%*smajor: %s\n", (H5E_INDENT * 2), "", maj_str); + fprintf(stream, "%*sminor: %s\n", (H5E_INDENT * 2), "", min_str); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5E_walk2_cb() */ + + +/*------------------------------------------------------------------------- + * Function: H5E_print2 + * + * Purpose: Private function to print the error stack in some default + * way. This is just a convenience function for H5Ewalk() and + * H5Ewalk2() with a function that prints error messages. + * Users are encouraged to write there own more specific error + * handlers. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Robb Matzke + * Friday, February 27, 1998 + * + *------------------------------------------------------------------------- + */ +herr_t +H5E_print2(const H5E_t *estack, FILE *stream, hbool_t bk_compatible) +{ + H5E_print_t eprint; /* Callback information to pass to H5E_walk2() */ + herr_t ret_value = SUCCEED; + + /* Don't clear the error stack! :-) */ + FUNC_ENTER_NOAPI_NOINIT(H5E_print2) + + /* Sanity check */ + HDassert(estack); + + /* If no stream was given, use stderr */ + if(!stream) + eprint.stream = stderr; + else + eprint.stream = stream; + + /* Reset the original error class information */ + HDmemset(&eprint.cls, 0, sizeof(H5E_cls_t)); + + /* Walk the error stack */ + if(bk_compatible) { + if(H5E_walk2(estack, H5E_WALK_DOWNWARD, H5E_walk_cb, NULL, TRUE, (void*)&eprint) < 0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTLIST, FAIL, "can't walk error stack") + } /* end if */ + else { + if(H5E_walk2(estack, H5E_WALK_DOWNWARD, NULL, H5E_walk2_cb, FALSE, (void*)&eprint) < 0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTLIST, FAIL, "can't walk error stack") + } /* end else */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5E_print2() */ + + +/*------------------------------------------------------------------------- + * Function: H5E_walk2 + * + * Purpose: Private function for H5Ewalk. + * Walks the error stack, calling the specified function for + * each error on the stack. The DIRECTION argument determines + * whether the stack is walked from the inside out or the + * outside in. The value H5E_WALK_UPWARD means begin with the + * most specific error and end at the API; H5E_WALK_DOWNWARD + * means to start at the API and end at the inner-most function + * where the error was first detected. + * + * The function pointed to by STACK_FUNC will be called for + * each error record in the error stack. It's arguments will + * include an index number (beginning at zero regardless of + * stack traversal direction), an error stack entry, and the + * CLIENT_DATA pointer passed to H5E_print2. + * + * The function FUNC is also provided for backward compatibility. + * When BK_COMPATIBLE is set to be TRUE, FUNC is used to be + * compatible with older library. If BK_COMPATIBLE is FALSE, + * STACK_FUNC is used. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Robb Matzke + * Friday, December 12, 1997 + * + *------------------------------------------------------------------------- + */ +herr_t +H5E_walk2(const H5E_t *estack, H5E_direction_t direction, H5E_walk_t func, H5E_walk2_t stack_func, + hbool_t bk_compatible, void *client_data) +{ + int i; /* Local index variable */ + herr_t status; /* Status from callback function */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5E_walk2) + + /* Sanity check */ + HDassert(estack); + + /* check args, but rather than failing use some default value */ + if(direction != H5E_WALK_UPWARD && direction != H5E_WALK_DOWNWARD) + direction = H5E_WALK_UPWARD; + + /* Walk the stack if a callback function was given */ + if(bk_compatible && func) { + H5E_error_t old_err; + + status = SUCCEED; + if(H5E_WALK_UPWARD == direction) { + for(i = 0; i < (int)estack->nused && status >= 0; i++) { + /* Point to each error record on the stack and pass it to callback function.*/ + old_err.maj_num = estack->slot[i].maj_num; + old_err.min_num = estack->slot[i].min_num; + old_err.func_name = estack->slot[i].func_name; + old_err.file_name = estack->slot[i].file_name; + old_err.desc = estack->slot[i].desc; + old_err.line = estack->slot[i].line; + + status = (func)((unsigned)i, &old_err, client_data); + } /* end for */ + } /* end if */ + else { + H5_CHECK_OVERFLOW(estack->nused - 1, size_t, int); + for(i = (int)(estack->nused - 1); i >= 0 && status >= 0; i--) { + /* Point to each error record on the stack and pass it to callback function.*/ + old_err.maj_num = estack->slot[i].maj_num; + old_err.min_num = estack->slot[i].min_num; + old_err.func_name = estack->slot[i].func_name; + old_err.file_name = estack->slot[i].file_name; + old_err.desc = estack->slot[i].desc; + old_err.line = estack->slot[i].line; + + status = (func)((unsigned)(estack->nused - (size_t)(i + 1)), &old_err, client_data); + } /* end for */ + } /* end else */ + + if(status < 0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTLIST, FAIL, "can't walk error stack") + } /* end if */ + else if(!bk_compatible && stack_func) { + status = SUCCEED; + if(H5E_WALK_UPWARD == direction) { + for(i = 0; i < (int)estack->nused && status >= 0; i++) + status = (stack_func)((unsigned)i, estack->slot + i, client_data); + } /* end if */ + else { + H5_CHECK_OVERFLOW(estack->nused - 1, size_t, int); + for(i = (int)(estack->nused - 1); i >= 0 && status >= 0; i--) + status = (stack_func)((unsigned)(estack->nused-(size_t)(i + 1)), estack->slot + i, client_data); + } /* end else */ + + if(status < 0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTLIST, FAIL, "can't walk error stack") + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5E_walk2() */ + + +/*------------------------------------------------------------------------- + * Function: H5E_get_auto2 + * + * Purpose: Private function to return the current settings for the + * automatic error stack traversal function and its data + * for specific error stack. Either (or both) arguments may + * be null in which case the value is not returned. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Raymond Lu + * July 18, 2003 + * + *------------------------------------------------------------------------- + */ +herr_t +H5E_get_auto2(const H5E_t *estack, hbool_t new_api, H5E_auto_op_t *func, void **client_data) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5E_get_auto2) + + HDassert(estack); + + /* Retrieve the requested information */ + if(func) { + if(new_api) + func->efunc2 = estack->u.func2; + else + func->efunc = estack->u.func; + } /* end if */ + if(client_data) + *client_data = estack->auto_data; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5E_get_auto2() */ + + +/*------------------------------------------------------------------------- + * Function: H5E_set_auto2 + * + * Purpose: Private function to turn on or off automatic printing of + * errors for certain error stack. When turned on (non-null + * FUNC pointer) any API function which returns an error + * indication will first call FUNC passing it CLIENT_DATA + * as an argument. + * + * The default values before this function is called are + * H5Eprint() with client data being the standard error stream, + * stderr. + * + * Automatic stack traversal is always in the H5E_WALK_DOWNWARD + * direction. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Robb Matzke + * Friday, February 27, 1998 + * + *------------------------------------------------------------------------- + */ +herr_t +H5E_set_auto2(H5E_t *estack, hbool_t new_api, H5E_auto_op_t *func, void *client_data) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5E_set_auto2) + + HDassert(estack); + + /* Set the automatic error reporting info */ + estack->new_api = new_api; + if(new_api) + estack->u.func2 = func->efunc2; + else + estack->u.func = func->efunc; + estack->auto_data = client_data; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5E_set_auto2() */ + + +/*------------------------------------------------------------------------- + * Function: H5E_push_stack + * + * Purpose: Pushes a new error record onto error stack for the current + * thread. The error has major and minor IDs MAJ_ID and + * MIN_ID, the name of a function where the error was detected, + * the name of the file where the error was detected, the + * line within that file, and an error description string. The + * function name, file name, and error description strings must + * be statically allocated (the FUNC_ENTER() macro takes care of + * the function name and file name automatically, but the + * programmer is responsible for the description string). + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Robb Matzke + * Friday, December 12, 1997 + * + *------------------------------------------------------------------------- + */ +herr_t +H5E_push_stack(H5E_t *estack, const char *file, const char *func, unsigned line, + hid_t cls_id, hid_t maj_id, hid_t min_id, const char *desc) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + /* + * WARNING: We cannot call HERROR() from within this function or else we + * could enter infinite recursion. Furthermore, we also cannot + * call any other HDF5 macro or function which might call + * HERROR(). HERROR() is called by HRETURN_ERROR() which could + * be called by FUNC_ENTER(). + */ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5E_push_stack) + + /* Sanity check */ + HDassert(cls_id > 0); + HDassert(maj_id > 0); + HDassert(min_id > 0); + + /* Check for 'default' error stack */ + if(estack == NULL) + if(NULL == (estack = H5E_get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + HGOTO_DONE(FAIL) + + /* + * Don't fail if arguments are bad. Instead, substitute some default + * value. + */ + if(!func) + func = "Unknown_Function"; + if(!file) + file = "Unknown_File"; + if(!desc) + desc = "No description given"; + + /* + * Push the error if there's room. Otherwise just forget it. + */ + HDassert(estack); + + if(estack->nused < H5E_NSLOTS) { + /* Increment the IDs to indicate that they are used in this stack */ + if(H5I_inc_ref(cls_id) < 0) + HGOTO_DONE(FAIL) + estack->slot[estack->nused].cls_id = cls_id; + if(H5I_inc_ref(maj_id) < 0) + HGOTO_DONE(FAIL) + estack->slot[estack->nused].maj_num = maj_id; + if(H5I_inc_ref(min_id) < 0) + HGOTO_DONE(FAIL) + estack->slot[estack->nused].min_num = min_id; + if(NULL == (estack->slot[estack->nused].func_name = H5MM_xstrdup(func))) + HGOTO_DONE(FAIL) + if(NULL == (estack->slot[estack->nused].file_name = H5MM_xstrdup(file))) + HGOTO_DONE(FAIL) + estack->slot[estack->nused].line = line; + if(NULL == (estack->slot[estack->nused].desc = H5MM_xstrdup(desc))) + HGOTO_DONE(FAIL) + estack->nused++; + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5E_push_stack() */ + + +/*------------------------------------------------------------------------- + * Function: H5E_clear_entries + * + * Purpose: Private function to clear the error stack entries for the + * specified error stack. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Wednesday, August 6, 2003 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5E_clear_entries(H5E_t *estack, size_t nentries) +{ + H5E_error2_t *error; /* Pointer to error stack entry to clear */ + unsigned u; /* Local index variable */ + herr_t ret_value=SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5E_clear_entries) + + /* Sanity check */ + HDassert(estack); + HDassert(estack->nused >= nentries); + + /* Empty the error stack from the top down */ + for(u = 0; nentries > 0; nentries--, u++) { + error = &(estack->slot[estack->nused - (u + 1)]); + + /* Decrement the IDs to indicate that they are no longer used by this stack */ + /* (In reverse order that they were incremented, so that reference counts work well) */ + if(H5I_dec_ref(error->min_num) < 0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error message") + if(H5I_dec_ref(error->maj_num) < 0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error message") + if(H5I_dec_ref(error->cls_id) < 0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error class") + + /* Release strings */ + if(error->func_name) + H5MM_xfree((void *)error->func_name); /* Casting away const OK - QAK */ + if(error->file_name) + H5MM_xfree((void *)error->file_name); /* Casting away const OK - QAK */ + if(error->desc) + H5MM_xfree((void *)error->desc); /* Casting away const OK - QAK */ + } /* end for */ + + /* Decrement number of errors on stack */ + estack->nused -= u; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5E_clear_entries() */ + + +/*------------------------------------------------------------------------- + * Function: H5E_clear_stack + * + * Purpose: Private function to clear the error stack for the + * specified error stack. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Raymond Lu + * Wednesday, July 16, 2003 + * + *------------------------------------------------------------------------- + */ +herr_t +H5E_clear_stack(H5E_t *estack) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5E_clear_stack, FAIL) + + /* Check for 'default' error stack */ + if(estack == NULL) + if(NULL == (estack = H5E_get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") + + /* Empty the error stack */ + HDassert(estack); + if(estack->nused) + if(H5E_clear_entries(estack, estack->nused) < 0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't clear error stack") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5E_clear_stack() */ + + +/*------------------------------------------------------------------------- + * Function: H5E_pop + * + * Purpose: Private function to delete some error messages from the top + * of error stack. + * + * Return: Non-negative value on success/Negative on failure + * + * Programmer: Raymond Lu + * Friday, July 16, 2003 + * + *------------------------------------------------------------------------- + */ +herr_t +H5E_pop(H5E_t *estack, size_t count) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5E_pop) + + /* Sanity check */ + HDassert(estack); + HDassert(estack->nused >= count); + + /* Remove the entries from the error stack */ + if(H5E_clear_entries(estack, count) < 0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTRELEASE, FAIL, "can't remove errors from stack") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5E_pop() */ + diff --git a/src/H5Epkg.h b/src/H5Epkg.h new file mode 100644 index 0000000..5e36b38 --- /dev/null +++ b/src/H5Epkg.h @@ -0,0 +1,105 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol <koziol@hdfgroup.org> + * Wednesday, April 11, 2007 + * + * Purpose: This file contains declarations which are visible only within + * the H5E package. Source files outside the H5E package should + * include H5Eprivate.h instead. + */ +#ifndef H5E_PACKAGE +#error "Do not include this file outside the H5E package!" +#endif + +#ifndef _H5Epkg_H +#define _H5Epkg_H + +/* Get package's private header */ +#include "H5Eprivate.h" + +/* Other private headers needed by this file */ + + +/**************************/ +/* Package Private Macros */ +/**************************/ + +/* Amount to indent each error */ +#define H5E_INDENT 2 + +#ifdef H5_HAVE_THREADSAFE +/* + * The per-thread error stack. pthread_once() initializes a special + * key that will be used by all threads to create a stack specific to + * each thread individually. The association of stacks to threads will + * be handled by the pthread library. + * + * In order for this macro to work, H5E_get_my_stack() must be preceeded + * by "H5E_t *estack =". + */ +#define H5E_get_my_stack() H5E_get_stack() +#else /* H5_HAVE_THREADSAFE */ +/* + * The current error stack. + */ +#define H5E_get_my_stack() (H5E_stack_g + 0) +#endif /* H5_HAVE_THREADSAFE */ + + +/****************************/ +/* Package Private Typedefs */ +/****************************/ + +/* Some syntactic sugar to make the compiler happy with two different kinds of callbacks */ +typedef union { + H5E_auto_t efunc; /* Old-style callback, NO error stack param. */ + H5E_auto2_t efunc2; /* New-style callback, with error stack param. */ +} H5E_auto_op_t; + + +/*****************************/ +/* Package Private Variables */ +/*****************************/ + +#ifndef H5_HAVE_THREADSAFE +/* + * The current error stack. + */ +H5_DLLVAR H5E_t H5E_stack_g[1]; +#endif /* H5_HAVE_THREADSAFE */ + + +/******************************/ +/* Package Private Prototypes */ +/******************************/ +#ifdef H5_HAVE_THREADSAFE +H5_DLL H5E_t *H5E_get_stack(void); +#endif /* H5_HAVE_THREADSAFE */ +H5_DLL ssize_t H5E_get_msg(const H5E_msg_t *msg_ptr, H5E_type_t *type, + char *msg, size_t size); +H5_DLL herr_t H5E_print2(const H5E_t *estack, FILE *stream, hbool_t bk_compat); +H5_DLL herr_t H5E_walk2(const H5E_t *estack, H5E_direction_t direction, + H5E_walk_t func, H5E_walk2_t stack_func, hbool_t bk_compatible, + void *client_data); +H5_DLL herr_t H5E_get_auto2(const H5E_t *estack, hbool_t new_api, + H5E_auto_op_t *func, void **client_data); +H5_DLL herr_t H5E_set_auto2(H5E_t *estack, hbool_t new_api, + H5E_auto_op_t *func, void *client_data); +H5_DLL herr_t H5E_pop(H5E_t *err_stack, size_t count); + +#endif /* _H5HFpkg_H */ + diff --git a/src/H5Eprivate.h b/src/H5Eprivate.h index 09b7e2b..9d444bc 100644 --- a/src/H5Eprivate.h +++ b/src/H5Eprivate.h @@ -25,7 +25,6 @@ #include "H5private.h" #define H5E_NSLOTS 32 /*number of slots in an error stack */ -#define H5E_RESERVED_ATOMS 0 /* Error class */ typedef struct H5E_cls_t { @@ -44,11 +43,11 @@ typedef struct H5E_msg_t { /* Error stack */ typedef struct H5E_t { size_t nused; /* Num slots currently used in stack */ - H5E_error_stack_t slot[H5E_NSLOTS]; /* Array of error records */ + H5E_error2_t slot[H5E_NSLOTS]; /* Array of error records */ hbool_t new_api; /* Indicate that the function pointer is for the new (stack) API or the old */ union { - H5E_auto_t func; /* Function for 'automatic' error reporting */ - H5E_auto_stack_t func_stack; /* Function for 'automatic' error reporting */ + H5E_auto_t func; /* Function for 'automatic' error reporting */ + H5E_auto2_t func2; /* Function for 'automatic' error reporting with error stacks */ } u; void *auto_data; /* Callback data for 'automatic error reporting */ } H5E_t; @@ -59,10 +58,6 @@ typedef struct H5E_print_t { H5E_cls_t cls; } H5E_print_t; -/* HDF5 error class */ -#define H5E_CLS_NAME "HDF5" -#define H5E_CLS_LIB_NAME "HDF5" - /* * HERROR macro, used to facilitate error reporting between a FUNC_ENTER() * and a FUNC_LEAVE() within a function body. The arguments are the major @@ -88,7 +83,7 @@ typedef struct H5E_print_t { * without jumping to any labels) */ #define HDONE_ERROR(maj, min, ret_val, str) { \ - HCOMMON_ERROR (maj, min, str); \ + HCOMMON_ERROR(maj, min, str); \ ret_value = ret_val; \ } @@ -100,8 +95,8 @@ typedef struct H5E_print_t { * control branches to the `done' label. */ #define HGOTO_ERROR(maj, min, ret_val, str) { \ - HCOMMON_ERROR (maj, min, str); \ - HGOTO_DONE (ret_val) \ + HCOMMON_ERROR(maj, min, str); \ + HGOTO_DONE(ret_val) \ } /* @@ -113,11 +108,11 @@ typedef struct H5E_print_t { #define HGOTO_DONE(ret_val) {ret_value = ret_val; goto done;} /* Library-private functions defined in H5E package */ -H5_DLL herr_t H5E_init(void); -H5_DLL herr_t H5E_push_stack(H5E_t *estack, const char *file, const char *func, unsigned line, +H5_DLL herr_t H5E_init(void); +H5_DLL herr_t H5E_push_stack(H5E_t *estack, const char *file, const char *func, unsigned line, hid_t cls_id, hid_t maj_id, hid_t min_id, const char *desc); -H5_DLL herr_t H5E_clear_stack(H5E_t *estack); -H5_DLL herr_t H5E_dump_api_stack(int is_api); +H5_DLL herr_t H5E_clear_stack(H5E_t *estack); +H5_DLL herr_t H5E_dump_api_stack(int is_api); /* * Macros handling system error messages as described in C standard. @@ -127,14 +122,14 @@ H5_DLL herr_t H5E_dump_api_stack(int is_api); /* Retrieve the error code description string and push it onto the error * stack. */ -#define HSYS_ERROR(errnum){ \ +#define HSYS_ERROR(errnum) { \ HERROR(H5E_INTERNAL, H5E_SYSERRSTR, HDstrerror(errnum)); \ } -#define HSYS_DONE_ERROR(majorcode, minorcode, retcode, str){ \ +#define HSYS_DONE_ERROR(majorcode, minorcode, retcode, str) { \ HSYS_ERROR(errno); \ HDONE_ERROR(majorcode, minorcode, retcode, str); \ } -#define HSYS_GOTO_ERROR(majorcode, minorcode, retcode, str){ \ +#define HSYS_GOTO_ERROR(majorcode, minorcode, retcode, str) { \ HSYS_ERROR(errno); \ HGOTO_ERROR(majorcode, minorcode, retcode, str); \ } @@ -159,6 +154,7 @@ extern int H5E_mpi_error_str_len; HMPI_ERROR(mpierr); \ HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, retcode, str); \ } -#endif +#endif /* H5_HAVE_PARALLEL */ + +#endif /* _H5Eprivate_H */ -#endif diff --git a/src/H5Epublic.h b/src/H5Epublic.h index 6591cd6..ce68b71 100644 --- a/src/H5Epublic.h +++ b/src/H5Epublic.h @@ -49,7 +49,7 @@ typedef struct H5E_error_t { } H5E_error_t; /* Information about an error; element of error stack */ -typedef struct H5E_error_stack_t { +typedef struct H5E_error2_t { hid_t cls_id; /*class ID */ hid_t maj_num; /*major error ID */ hid_t min_num; /*minor error number */ @@ -57,7 +57,7 @@ typedef struct H5E_error_stack_t { const char *func_name; /*function in which error occurred */ const char *file_name; /*file in which error occurred */ const char *desc; /*optional supplied description */ -} H5E_error_stack_t; +} H5E_error2_t; /* When this header is included from a private header, don't make calls to H5open() */ #undef H5OPEN @@ -93,52 +93,51 @@ H5_DLLVAR hid_t H5E_ERR_CLS_g; * purpose. */ #define H5E_BEGIN_TRY { \ - unsigned H5E_saved_is_stack; \ + unsigned H5E_saved_is_v2; \ union { \ - H5E_auto_stack_t stack_efunc; \ H5E_auto_t efunc; \ + H5E_auto2_t efunc2; \ } H5E_saved; \ void *H5E_saved_edata; \ \ - (void)H5Eauto_is_stack(H5E_DEFAULT, &H5E_saved_is_stack); \ - if(H5E_saved_is_stack) { \ - (void)H5Eget_auto_stack(H5E_DEFAULT, &H5E_saved.stack_efunc, &H5E_saved_edata); \ - (void)H5Eset_auto_stack(H5E_DEFAULT, NULL, NULL); \ + (void)H5Eauto_is_v2(H5E_DEFAULT, &H5E_saved_is_v2); \ + if(H5E_saved_is_v2) { \ + (void)H5Eget_auto2(H5E_DEFAULT, &H5E_saved.efunc2, &H5E_saved_edata); \ + (void)H5Eset_auto2(H5E_DEFAULT, NULL, NULL); \ } else { \ (void)H5Eget_auto(&H5E_saved.efunc, &H5E_saved_edata); \ (void)H5Eset_auto(NULL, NULL); \ } #define H5E_END_TRY \ - if(H5E_saved_is_stack) { \ - (void)H5Eset_auto_stack(H5E_DEFAULT, H5E_saved.stack_efunc, H5E_saved_edata); \ - } else { \ + if(H5E_saved_is_v2) \ + (void)H5Eset_auto2(H5E_DEFAULT, H5E_saved.efunc2, H5E_saved_edata); \ + else \ (void)H5Eset_auto(H5E_saved.efunc, H5E_saved_edata); \ - } \ } /* * Public API Convenience Macros for Error reporting - Documented */ /* Use the Standard C __FILE__ & __LINE__ macros instead of typing them in */ -#define H5Epush_sim(func,cls,maj,min,str) H5Epush_stack(H5E_DEFAULT,__FILE__,func,__LINE__,cls,maj,min,str) +#define H5Epush_sim(func, cls, maj, min, str) H5Epush2(H5E_DEFAULT, __FILE__, func, __LINE__, cls, maj, min, str) /* * Public API Convenience Macros for Error reporting - Undocumented */ /* Use the Standard C __FILE__ & __LINE__ macros instead of typing them in */ /* And return after pushing error onto stack */ -#define H5Epush_ret(func,cls,maj,min,str,ret) { \ - H5Epush_stack(H5E_DEFAULT,__FILE__,func,__LINE__,cls,maj,min,str); \ - return(ret); \ +#define H5Epush_ret(func, cls, maj, min, str, ret) { \ + H5Epush2(H5E_DEFAULT, __FILE__, func, __LINE__, cls, maj, min, str); \ + return(ret); \ } /* Use the Standard C __FILE__ & __LINE__ macros instead of typing them in * And goto a label after pushing error onto stack. */ -#define H5Epush_goto(func,cls,maj,min,str,label) { \ - H5Epush_stack(H5E_DEFAULT,__FILE__,func,__LINE__,cls,maj,min,str); \ - goto label; \ +#define H5Epush_goto(func, cls, maj, min, str, label) { \ + H5Epush2(H5E_DEFAULT, __FILE__, func, __LINE__, cls, maj, min, str); \ + goto label; \ } /* Error stack traversal direction */ @@ -153,49 +152,56 @@ extern "C" { #endif /* Error stack traversal callback function pointers */ -typedef herr_t (*H5E_walk_t)(unsigned n, const H5E_error_t *err_desc, void *client_data); -typedef herr_t (*H5E_walk_stack_t)(unsigned n, const H5E_error_stack_t *err_desc, void *client_data); +typedef herr_t (*H5E_walk_t)(unsigned n, const H5E_error_t *err_desc, + void *client_data); +typedef herr_t (*H5E_walk2_t)(unsigned n, const H5E_error2_t *err_desc, + void *client_data); typedef herr_t (*H5E_auto_t)(void *client_data); -typedef herr_t (*H5E_auto_stack_t)(hid_t estack, void *client_data); +typedef herr_t (*H5E_auto2_t)(hid_t estack, void *client_data); /* Public API functions */ -H5_DLL hid_t H5Eregister_class(const char *cls_name, const char *lib_name, const char *version); +H5_DLL hid_t H5Eregister_class(const char *cls_name, const char *lib_name, + const char *version); H5_DLL herr_t H5Eunregister_class(hid_t class_id); H5_DLL herr_t H5Eclose_msg(hid_t err_id); H5_DLL hid_t H5Ecreate_msg(hid_t cls, H5E_type_t msg_type, const char *msg); H5_DLL hid_t H5Eget_current_stack(void); H5_DLL herr_t H5Eclose_stack(hid_t stack_id); H5_DLL ssize_t H5Eget_class_name(hid_t class_id, char *name, size_t size); -H5_DLL ssize_t H5Eget_msg(hid_t msg_id, H5E_type_t *type, char *msg, size_t size); +H5_DLL ssize_t H5Eget_msg(hid_t msg_id, H5E_type_t *type, char *msg, + size_t size); H5_DLL ssize_t H5Eget_num(hid_t error_stack_id); H5_DLL herr_t H5Eset_current_stack(hid_t err_stack_id); H5_DLL herr_t H5Epop(hid_t err_stack, size_t count); -H5_DLL herr_t H5Eauto_is_stack(hid_t err_stack, unsigned *is_stack); +H5_DLL herr_t H5Eauto_is_v2(hid_t err_stack, unsigned *is_stack); /* These old APIs are kept for backward compatibility. They don't have * the error stack in the parameters. */ H5_DLL herr_t H5Epush(const char *file, const char *func, unsigned line, - H5E_major_t maj, H5E_minor_t min, const char *str); -H5_DLL herr_t H5Eprint(FILE *stream); -H5_DLL herr_t H5Ewalk(H5E_direction_t direction, H5E_walk_t func, - void *client_data); -H5_DLL herr_t H5Eget_auto(H5E_auto_t *func, void **client_data); -H5_DLL herr_t H5Eset_auto(H5E_auto_t func, void *client_data); -H5_DLL herr_t H5Eclear(void); -H5_DLL const char * H5Eget_major(H5E_major_t maj); -H5_DLL const char * H5Eget_minor(H5E_minor_t min); + H5E_major_t maj, H5E_minor_t min, const char *str); +H5_DLL herr_t H5Eprint(FILE *stream); +H5_DLL herr_t H5Ewalk(H5E_direction_t direction, H5E_walk_t func, + void *client_data); +H5_DLL herr_t H5Eget_auto(H5E_auto_t *func, void **client_data); +H5_DLL herr_t H5Eset_auto(H5E_auto_t func, void *client_data); +H5_DLL herr_t H5Eclear(void); +H5_DLL const char *H5Eget_major(H5E_major_t maj); +H5_DLL const char *H5Eget_minor(H5E_minor_t min); /* New APIs function the same as the old ones above, with the error stack * in the parameters */ -H5_DLL herr_t H5Epush_stack(hid_t err_stack, const char *file, const char *func, unsigned line, - hid_t cls_id, hid_t maj_id, hid_t min_id, const char *msg, ...); -H5_DLL herr_t H5Eprint_stack(hid_t err_stack, FILE *stream); -H5_DLL herr_t H5Ewalk_stack(hid_t err_stack, H5E_direction_t direction, H5E_walk_stack_t func, - void *client_data); -H5_DLL herr_t H5Eget_auto_stack(hid_t estack_id, H5E_auto_stack_t *func, void **client_data); -H5_DLL herr_t H5Eset_auto_stack(hid_t estack_id, H5E_auto_stack_t func, void *client_data); -H5_DLL herr_t H5Eclear_stack(hid_t err_stack); +H5_DLL herr_t H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line, + hid_t cls_id, hid_t maj_id, hid_t min_id, const char *msg, ...); +H5_DLL herr_t H5Eprint2(hid_t err_stack, FILE *stream); +H5_DLL herr_t H5Ewalk2(hid_t err_stack, H5E_direction_t direction, H5E_walk2_t func, + void *client_data); +H5_DLL herr_t H5Eget_auto2(hid_t estack_id, H5E_auto2_t *func, void **client_data); +H5_DLL herr_t H5Eset_auto2(hid_t estack_id, H5E_auto2_t func, void *client_data); +H5_DLL herr_t H5Eclear2(hid_t err_stack); + #ifdef __cplusplus } #endif -#endif + +#endif /* end _H5Epublic_H */ + diff --git a/src/H5FDmulti.c b/src/H5FDmulti.c index bd1adbb..8c25a62 100644 --- a/src/H5FDmulti.c +++ b/src/H5FDmulti.c @@ -32,7 +32,7 @@ /*lint --emacro( {534, 830}, H5P_DEFAULT, H5P_FILE_ACCESS, H5P_DATASET_XFER) */ /*lint --emacro( {534, 830}, H5F_ACC_DEBUG, H5F_ACC_RDWR) */ /*lint --emacro( {534, 830}, H5FD_MULTI) */ -/*lint -esym( 534, H5Eclear_stack, H5Epush_stack) */ +/*lint -esym( 534, H5Eclear2, H5Epush2) */ #include "hdf5.h" @@ -235,7 +235,7 @@ hid_t H5FD_multi_init(void) { /* Clear the error stack */ - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); if (H5I_VFL!=H5Iget_type(H5FD_MULTI_g)) { H5FD_MULTI_g = H5FDregister(&H5FD_multi_g); @@ -304,7 +304,7 @@ H5Pset_fapl_split(hid_t fapl, const char *meta_ext, hid_t meta_plist_id, /*NO TRACE*/ /* Clear the error stack */ - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); /* Initialize */ ALL_MEMBERS(mt) { @@ -448,7 +448,7 @@ H5Pset_fapl_multi(hid_t fapl_id, const H5FD_mem_t *memb_map, /*NO TRACE*/ /* Clear the error stack */ - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); /* Check arguments and supply default values */ if(H5I_GENPROP_LST != H5Iget_type(fapl_id) || @@ -549,7 +549,7 @@ H5Pget_fapl_multi(hid_t fapl_id, H5FD_mem_t *memb_map/*out*/, /*NO TRACE*/ /* Clear the error stack */ - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); if(H5I_GENPROP_LST != H5Iget_type(fapl_id) || TRUE != H5Pisa_class(fapl_id, H5P_FILE_ACCESS)) @@ -616,7 +616,7 @@ H5Pset_dxpl_multi(hid_t dxpl_id, const hid_t *memb_dxpl) /*NO TRACE*/ /* Clear the error stack */ - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); /* Check arguments */ if (TRUE!=H5Pisa_class(dxpl_id, H5P_DATASET_XFER)) @@ -668,7 +668,7 @@ H5Pget_dxpl_multi(hid_t dxpl_id, hid_t *memb_dxpl/*out*/) /*NO TRACE*/ /* Clear the error stack */ - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); if (TRUE!=H5Pisa_class(dxpl_id, H5P_DATASET_XFER)) H5Epush_ret(func, H5E_ERR_CLS, H5E_PLIST, H5E_BADTYPE, "not a file access property list", -1) @@ -715,7 +715,7 @@ H5FD_multi_sb_size(H5FD_t *_file) hsize_t nbytes = 8; /*size of header*/ /* Clear the error stack */ - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); /* How many unique files? */ UNIQUE_MEMBERS(file->fa.memb_map, mt) { @@ -773,7 +773,7 @@ H5FD_multi_sb_encode(H5FD_t *_file, char *name/*out*/, static const char *func="H5FD_multi_sb_encode"; /* Function Name for error reporting */ /* Clear the error stack */ - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); /* Name and version number */ strncpy(name, "NCSAmulti", (size_t)8); @@ -860,7 +860,7 @@ H5FD_multi_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf) static const char *func="H5FD_multi_sb_decode"; /* Function Name for error reporting */ /* Clear the error stack */ - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); /* Make sure the name/version number is correct */ if (strcmp(name, "NCSAmult")) @@ -1004,7 +1004,7 @@ H5FD_multi_fapl_get(H5FD_t *_file) H5FD_multi_t *file = (H5FD_multi_t*)_file; /* Clear the error stack */ - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); return H5FD_multi_fapl_copy(&(file->fa)); } @@ -1037,7 +1037,7 @@ H5FD_multi_fapl_copy(const void *_old_fa) assert(new_fa); /* Clear the error stack */ - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); memcpy(new_fa, old_fa, sizeof(H5FD_multi_fapl_t)); ALL_MEMBERS(mt) { @@ -1087,7 +1087,7 @@ H5FD_multi_fapl_free(void *_fa) static const char *func="H5FD_multi_fapl_free"; /* Function Name for error reporting */ /* Clear the error stack */ - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); ALL_MEMBERS(mt) { if (fa->memb_fapl[mt]>=0) @@ -1129,7 +1129,7 @@ H5FD_multi_dxpl_copy(const void *_old_dx) assert(new_dx); /* Clear the error stack */ - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); memcpy(new_dx, old_dx, sizeof(H5FD_multi_dxpl_t)); ALL_MEMBERS(mt) { @@ -1173,7 +1173,7 @@ H5FD_multi_dxpl_free(void *_dx) static const char *func="H5FD_multi_dxpl_free"; /* Function Name for error reporting */ /* Clear the error stack */ - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); ALL_MEMBERS(mt) { if (dx->memb_dxpl[mt]>=0) @@ -1215,7 +1215,7 @@ H5FD_multi_open(const char *name, unsigned flags, hid_t fapl_id, static const char *func="H5FD_multi_open"; /* Function Name for error reporting */ /* Clear the error stack */ - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); /* Check arguments */ if (!name || !*name) @@ -1310,7 +1310,7 @@ H5FD_multi_close(H5FD_t *_file) static const char *func="H5FD_multi_close"; /* Function Name for error reporting */ /* Clear the error stack */ - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); /* Close as many members as possible */ ALL_MEMBERS(mt) { @@ -1376,7 +1376,7 @@ H5FD_multi_cmp(const H5FD_t *_f1, const H5FD_t *_f2) int cmp=0; /* Clear the error stack */ - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); ALL_MEMBERS(mt) { out_mt = mt; @@ -1460,7 +1460,7 @@ H5FD_multi_get_eoa(const H5FD_t *_file, H5FD_mem_t type) static const char *func="H5FD_multi_eof"; /* Function Name for error reporting */ /* Clear the error stack */ - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); /* The library used to have EOA for the whole file. But it's * taken out because it makes little sense for MULTI files. @@ -1551,7 +1551,7 @@ H5FD_multi_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t eoa) static const char *func="H5FD_multi_set_eoa"; /* Function Name for error reporting */ /* Clear the error stack */ - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); H5E_BEGIN_TRY { status = H5FDset_eoa(file->memb[type], type, eoa); @@ -1595,7 +1595,7 @@ H5FD_multi_get_eof(const H5FD_t *_file) static const char *func="H5FD_multi_eof"; /* Function Name for error reporting */ /* Clear the error stack */ - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); UNIQUE_MEMBERS(file->fa.memb_map, mt) { if (file->memb[mt]) { @@ -1742,7 +1742,7 @@ H5FD_multi_free(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsi H5FD_mem_t mmt; /* Clear the error stack */ - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); mmt = file->fa.memb_map[type]; if (H5FD_MEM_DEFAULT==mmt) mmt = type; @@ -1782,7 +1782,7 @@ H5FD_multi_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, siz haddr_t start_addr=0; /* Clear the error stack */ - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); /* Get the data transfer properties */ if (H5P_FILE_ACCESS_DEFAULT!=dxpl_id && H5FD_MULTI==H5Pget_driver(dxpl_id)) { @@ -1837,7 +1837,7 @@ H5FD_multi_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, si haddr_t start_addr=0; /* Clear the error stack */ - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); /* Get the data transfer properties */ if (H5P_FILE_ACCESS_DEFAULT!=dxpl_id && H5FD_MULTI==H5Pget_driver(dxpl_id)) { @@ -1921,7 +1921,7 @@ H5FD_multi_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing) #endif /* Clear the error stack */ - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); /* Flush each file */ for (mt=H5FD_MEM_SUPER; mt<H5FD_MEM_NTYPES; mt=(H5FD_mem_t)(mt+1)) { @@ -1959,7 +1959,7 @@ static int compute_next(H5FD_multi_t *file) { /* Clear the error stack */ - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); ALL_MEMBERS(mt) { file->memb_next[mt] = HADDR_UNDEF; @@ -2006,7 +2006,7 @@ open_members(H5FD_multi_t *file) static const char *func="(H5FD_multi)open_members"; /* Function Name for error reporting */ /* Clear the error stack */ - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); UNIQUE_MEMBERS(file->fa.memb_map, mt) { if (file->memb[mt]) continue; /*already open*/ diff --git a/src/H5FDstdio.c b/src/H5FDstdio.c index 7498ae7..6f1b204 100644 --- a/src/H5FDstdio.c +++ b/src/H5FDstdio.c @@ -32,7 +32,7 @@ /* Disable certain warnings in PC-Lint: */ /*lint --emacro( {534, 830}, H5P_FILE_ACCESS) */ /*lint --emacro( {534, 830}, H5F_ACC_RDWR, H5F_ACC_EXCL) */ -/*lint -esym( 534, H5Eclear_stack, H5Epush_stack) */ +/*lint -esym( 534, H5Eclear2, H5Epush2) */ #include "hdf5.h" @@ -222,7 +222,7 @@ hid_t H5FD_stdio_init(void) { /* Clear the error stack */ - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); if (H5I_VFL!=H5Iget_type(H5FD_STDIO_g)) H5FD_STDIO_g = H5FDregister(&H5FD_stdio_g); @@ -278,7 +278,7 @@ H5Pset_fapl_stdio(hid_t fapl_id) /*NO TRACE*/ /* Clear the error stack */ - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); if(0 == H5Pisa_class(fapl_id, H5P_FILE_ACCESS)) H5Epush_ret(func, H5E_ERR_CLS, H5E_PLIST, H5E_BADTYPE, "not a file access property list", -1) @@ -338,7 +338,7 @@ H5FD_stdio_open( const char *name, unsigned flags, hid_t fapl_id, fapl_id=fapl_id; /* Clear the error stack */ - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); /* Check arguments */ if (!name || !*name) @@ -434,7 +434,7 @@ H5FD_stdio_close(H5FD_t *_file) static const char *func="H5FD_stdio_close"; /* Function Name for error reporting */ /* Clear the error stack */ - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); if (fclose(file->fp) < 0) H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_CLOSEERROR, "fclose failed", -1) @@ -471,7 +471,7 @@ H5FD_stdio_cmp(const H5FD_t *_f1, const H5FD_t *_f2) const H5FD_stdio_t *f2 = (const H5FD_stdio_t*)_f2; /* Clear the error stack */ - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); #ifdef WIN32 if (f1->fileindexhi < f2->fileindexhi) return -1; @@ -568,7 +568,7 @@ H5FD_stdio_alloc(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxp dxpl_id = dxpl_id; /* Clear the error stack */ - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); /* Compute the address for the block to allocate */ addr = file->eoa; @@ -624,7 +624,7 @@ H5FD_stdio_get_eoa(const H5FD_t *_file, H5FD_mem_t /*unused*/ type) const H5FD_stdio_t *file = (const H5FD_stdio_t *)_file; /* Clear the error stack */ - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); /* Shut compiler up */ type = type; @@ -661,7 +661,7 @@ H5FD_stdio_set_eoa(H5FD_t *_file, H5FD_mem_t /*unused*/ type, haddr_t addr) H5FD_stdio_t *file = (H5FD_stdio_t*)_file; /* Clear the error stack */ - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); /* Shut compiler up */ type = type; @@ -699,7 +699,7 @@ H5FD_stdio_get_eof(const H5FD_t *_file) const H5FD_stdio_t *file = (const H5FD_stdio_t *)_file; /* Clear the error stack */ - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); return(MAX(file->eof, file->eoa)); } @@ -729,7 +729,7 @@ H5FD_stdio_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle) fapl=fapl; /* Clear the error stack */ - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); *file_handle = &(file->fp); if(*file_handle==NULL) @@ -775,7 +775,7 @@ H5FD_stdio_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, siz dxpl_id=dxpl_id; /* Clear the error stack */ - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); /* Check for overflow */ if (HADDR_UNDEF==addr) @@ -877,7 +877,7 @@ H5FD_stdio_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, type=type; /* Clear the error stack */ - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); /* Check for overflow conditions */ if (HADDR_UNDEF==addr) @@ -958,7 +958,7 @@ H5FD_stdio_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing) dxpl_id=dxpl_id; /* Clear the error stack */ - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); /* Only try to flush the file if we have write access */ if(file->write_access) { diff --git a/src/H5trace.c b/src/H5trace.c index bc3f154..77e1984 100644 --- a/src/H5trace.c +++ b/src/H5trace.c @@ -554,16 +554,16 @@ H5_trace (const double *returning, const char *func, const char *type, ...) break; case 'e': - if (ptr) { - if (vp) { - fprintf (out, "0x%lx", (unsigned long)vp); - } else { + if(ptr) { + if(vp) + fprintf(out, "0x%lx", (unsigned long)vp); + else fprintf(out, "NULL"); - } - } else { - H5E_error_stack_t *error = va_arg (ap, H5E_error_stack_t*); /*lint !e64 Type mismatch not really occuring */ - fprintf (out, "0x%lx", (unsigned long)error); - } + } /* end if */ + else { + H5E_error2_t *error = va_arg(ap, H5E_error2_t *); /*lint !e64 Type mismatch not really occuring */ + fprintf(out, "0x%lx", (unsigned long)error); + } /* end else */ break; case 't': diff --git a/src/Makefile.am b/src/Makefile.am index 7a2f3df..b658771 100755 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -47,7 +47,7 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5B2.c H5B2cache.c H5B2dbg.c H5B2int.c H5B2stat.c H5B2test.c \ H5C.c H5CS.c H5D.c H5Dcompact.c H5Dcontig.c H5Ddeprec.c \ H5Defl.c H5Dio.c H5Distore.c H5Dmpio.c H5Doh.c H5Dselect.c H5Dtest.c \ - H5E.c \ + H5E.c H5Edeprec.c H5Eint.c \ H5F.c H5Fdbg.c H5Ffake.c H5Fmount.c H5Fsfile.c H5Fsuper.c H5Ftest.c \ H5FD.c H5FDcore.c \ H5FDdirect.c H5FDfamily.c H5FDlog.c H5FDmpi.c H5FDmpio.c \ diff --git a/src/Makefile.in b/src/Makefile.in index 017283b..d561838 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -84,7 +84,7 @@ am_libhdf5_la_OBJECTS = H5.lo H5checksum.lo H5dbg.lo H5system.lo \ H5B2.lo H5B2cache.lo H5B2dbg.lo H5B2int.lo H5B2stat.lo \ H5B2test.lo H5C.lo H5CS.lo H5D.lo H5Dcompact.lo H5Dcontig.lo \ H5Ddeprec.lo H5Defl.lo H5Dio.lo H5Distore.lo H5Dmpio.lo H5Doh.lo \ - H5Dselect.lo H5Dtest.lo H5E.lo H5F.lo H5Fdbg.lo H5Ffake.lo \ + H5Dselect.lo H5Dtest.lo H5E.lo H5Edeprec.lo H5Eint.lo H5F.lo H5Fdbg.lo H5Ffake.lo \ H5Fmount.lo H5Fsfile.lo H5Fsuper.lo H5Ftest.lo H5FD.lo \ H5FDcore.lo H5FDdirect.lo H5FDfamily.lo H5FDlog.lo H5FDmpi.lo \ H5FDmpio.lo H5FDmpiposix.lo H5FDmulti.lo H5FDsec2.lo \ @@ -396,7 +396,7 @@ libhdf5_la_SOURCES = H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5B2.c H5B2cache.c H5B2dbg.c H5B2int.c H5B2stat.c H5B2test.c \ H5C.c H5CS.c H5D.c H5Dcompact.c H5Dcontig.c H5Ddeprec.c \ H5Defl.c H5Dio.c H5Distore.c H5Dmpio.c H5Doh.c H5Dselect.c H5Dtest.c \ - H5E.c \ + H5E.c H5Edeprec.c H5Eint.c \ H5F.c H5Fdbg.c H5Ffake.c H5Fmount.c H5Fsfile.c H5Fsuper.c H5Ftest.c \ H5FD.c H5FDcore.c \ H5FDdirect.c H5FDfamily.c H5FDlog.c H5FDmpi.c H5FDmpio.c \ @@ -593,6 +593,8 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Dselect.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Dtest.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5E.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Edeprec.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Eint.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5F.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5FD.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5FDcore.Plo@am__quote@ |