diff options
-rw-r--r-- | MANIFEST | 3 | ||||
-rw-r--r-- | c++/src/H5Exception.cpp | 22 | ||||
-rw-r--r-- | c++/src/H5Exception.h | 6 | ||||
-rw-r--r-- | fortran/src/H5Ef.c | 10 | ||||
-rw-r--r-- | perform/overhead.c | 4 | ||||
-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 | ||||
-rw-r--r-- | test/dtransform.c | 8 | ||||
-rw-r--r-- | test/enum.c | 2 | ||||
-rw-r--r-- | test/error_test.c | 249 | ||||
-rw-r--r-- | test/fheap.c | 6 | ||||
-rw-r--r-- | test/flush2.c | 14 | ||||
-rw-r--r-- | test/gheap.c | 14 | ||||
-rw-r--r-- | test/h5test.h | 6 | ||||
-rw-r--r-- | test/lheap.c | 14 | ||||
-rw-r--r-- | test/ohdr.c | 34 | ||||
-rw-r--r-- | test/testhdf5.h | 14 | ||||
-rw-r--r-- | tools/h5dump/h5dump.c | 8 | ||||
-rw-r--r-- | tools/h5jam/h5jam.c | 32 | ||||
-rw-r--r-- | tools/h5jam/h5unjam.c | 64 | ||||
-rw-r--r-- | tools/h5jam/tellub.c | 7 | ||||
-rw-r--r-- | tools/h5ls/h5ls.c | 2 | ||||
-rw-r--r-- | tools/lib/h5diff.c | 3 | ||||
-rw-r--r-- | tools/misc/h5mkgrp.c | 2 | ||||
-rw-r--r-- | tools/misc/h5stat.c | 2 |
35 files changed, 2039 insertions, 1845 deletions
@@ -468,7 +468,10 @@ ./src/H5Dtest.c ./src/H5E.c ./src/H5Edefin.h +./src/H5Edeprec.c ./src/H5Einit.h +./src/H5Eint.c +./src/H5Epkg.h ./src/H5Eprivate.h ./src/H5Epubgen.h ./src/H5Epublic.h diff --git a/c++/src/H5Exception.cpp b/c++/src/H5Exception.cpp index 8040004..556bf21 100644 --- a/c++/src/H5Exception.cpp +++ b/c++/src/H5Exception.cpp @@ -141,11 +141,11 @@ H5std_string Exception::getMinorString( hid_t err_minor ) const /// handlers // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Exception::setAutoPrint( H5E_auto_stack_t& func, void* client_data ) +void Exception::setAutoPrint( H5E_auto2_t& func, void* client_data ) { // calls the C API routine H5Eset_auto to set the auto printing to // the specified function. - herr_t ret_value = H5Eset_auto_stack( H5E_DEFAULT, func, client_data ); + herr_t ret_value = H5Eset_auto2( H5E_DEFAULT, func, client_data ); if( ret_value < 0 ) throw Exception( "Exception::setAutoPrint", "H5Eset_auto failed" ); } @@ -159,7 +159,7 @@ void Exception::dontPrint() { // calls the C API routine H5Eset_auto with NULL parameters to turn // off the automatic error printing. - herr_t ret_value = H5Eset_auto_stack( H5E_DEFAULT, NULL, NULL ); + herr_t ret_value = H5Eset_auto2( H5E_DEFAULT, NULL, NULL ); if( ret_value < 0 ) throw Exception( "Exception::dontPrint", "H5Eset_auto failed" ); } @@ -174,11 +174,11 @@ void Exception::dontPrint() /// the error function // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Exception::getAutoPrint( H5E_auto_stack_t& func, void** client_data ) +void Exception::getAutoPrint( H5E_auto2_t& func, void** client_data ) { // calls the C API routine H5Eget_auto to get the current setting of // the automatic error printing - herr_t ret_value = H5Eget_auto_stack( H5E_DEFAULT, &func, client_data ); + herr_t ret_value = H5Eget_auto2( H5E_DEFAULT, &func, client_data ); if( ret_value < 0 ) throw Exception( "Exception::getAutoPrint", "H5Eget_auto failed" ); } @@ -194,7 +194,7 @@ void Exception::getAutoPrint( H5E_auto_stack_t& func, void** client_data ) void Exception::clearErrorStack() { // calls the C API routine H5Eclear to clear the error stack - herr_t ret_value = H5Eclear_stack(H5E_DEFAULT); + herr_t ret_value = H5Eclear2(H5E_DEFAULT); if( ret_value < 0 ) throw Exception( "Exception::clearErrorStack", "H5Eclear failed" ); } @@ -228,7 +228,7 @@ void Exception::clearErrorStack() ///\par /// Data structure to describe the error: ///\code -/// 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 @@ -236,14 +236,14 @@ void Exception::clearErrorStack() /// const char *file_name; //file in which error occurred /// unsigned line; //line in file where error occurs /// const char *desc; //optional supplied description -/// } H5E_error_stack_t; +/// } H5E_error2_t; ///\endcode // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Exception::walkErrorStack( H5E_direction_t direction, H5E_walk_stack_t func, void* client_data ) +void Exception::walkErrorStack( H5E_direction_t direction, H5E_walk2_t func, void* client_data ) { // calls the C API routine H5Ewalk to walk the error stack - herr_t ret_value = H5Ewalk_stack( H5E_DEFAULT, direction, func, client_data ); + herr_t ret_value = H5Ewalk2( H5E_DEFAULT, direction, func, client_data ); if( ret_value < 0 ) throw Exception( "Exception::walkErrorStack", "H5Ewalk failed" ); } @@ -302,7 +302,7 @@ const char* Exception::getCFuncName() const //-------------------------------------------------------------------------- void Exception::printError( FILE* stream ) const { - herr_t ret_value = H5Eprint_stack( H5E_DEFAULT, stream ); // print to stderr + herr_t ret_value = H5Eprint2( H5E_DEFAULT, stream ); // print to stderr if( ret_value < 0 ) throw Exception( "Exception::printError", "H5Eprint failed" ); } diff --git a/c++/src/H5Exception.h b/c++/src/H5Exception.h index 0f2a317..902a2d7 100644 --- a/c++/src/H5Exception.h +++ b/c++/src/H5Exception.h @@ -49,14 +49,14 @@ class H5_DLLCPP Exception { const char* getCFuncName() const; // function name as a char string // Turns on the automatic error printing. - static void setAutoPrint( H5E_auto_stack_t& func, void* client_data); + static void setAutoPrint( H5E_auto2_t& func, void* client_data); // Turns off the automatic error printing. static void dontPrint(); // Retrieves the current settings for the automatic error stack // traversal function and its data. - static void getAutoPrint( H5E_auto_stack_t& func, void** client_data); + static void getAutoPrint( H5E_auto2_t& func, void** client_data); // Clears the error stack for the current thread. static void clearErrorStack(); @@ -64,7 +64,7 @@ class H5_DLLCPP Exception { // Walks the error stack for the current thread, calling the // specified function. static void walkErrorStack( H5E_direction_t direction, - H5E_walk_stack_t func, void* client_data); + H5E_walk2_t func, void* client_data); // Prints the error stack in a default manner. virtual void printError( FILE* stream = NULL ) const; diff --git a/fortran/src/H5Ef.c b/fortran/src/H5Ef.c index 0cc08e2..612e894 100644 --- a/fortran/src/H5Ef.c +++ b/fortran/src/H5Ef.c @@ -38,7 +38,7 @@ nh5eclear_c( ) /* * Call H5Eclear function. */ - status = H5Eclear_stack(H5E_DEFAULT); + status = H5Eclear2(H5E_DEFAULT); if(status < 0) return ret_val; ret_val = 0; return ret_val; @@ -72,7 +72,7 @@ nh5eprint_c1(_fcd name, int_f* namelen) /* * Call H5Eprint function. */ - status = H5Eprint_stack(H5E_DEFAULT, file); + status = H5Eprint2(H5E_DEFAULT, file); if (status >=0 ) ret_val = 0; fclose(file); @@ -102,7 +102,7 @@ nh5eprint_c2() /* * Call H5Eprint function. */ - status = H5Eprint_stack(H5E_DEFAULT, NULL); + status = H5Eprint2(H5E_DEFAULT, NULL); if(status >= 0) ret_val = 0; return ret_val; } @@ -192,9 +192,9 @@ nh5eset_auto_c(int_f* printflag) herr_t status = -1; if (*printflag == 1) - status = H5Eset_auto_stack(H5E_DEFAULT, (H5E_auto_stack_t)H5Eprint, stderr); + status = H5Eset_auto2(H5E_DEFAULT, (H5E_auto2_t)H5Eprint, stderr); if (*printflag == 0) - status = H5Eset_auto_stack(H5E_DEFAULT, NULL,NULL); + status = H5Eset_auto2(H5E_DEFAULT, NULL,NULL); if (status >= 0) ret_val = 0; return ret_val; } diff --git a/perform/overhead.c b/perform/overhead.c index 21ff1a9..45dbe9a 100644 --- a/perform/overhead.c +++ b/perform/overhead.c @@ -166,7 +166,7 @@ static herr_t display_error_cb (hid_t estack, void UNUSED *client_data) { puts ("*FAILED*"); - H5Eprint_stack(estack, stdout); + H5Eprint2(estack, stdout); return 0; } @@ -372,7 +372,7 @@ main(int argc, char *argv[]) int i, j, nerrors=0; /* Default split ratios */ - H5Eset_auto_stack(H5E_DEFAULT, display_error_cb, NULL); + H5Eset_auto2(H5E_DEFAULT, display_error_cb, NULL); if ((xfer=H5Pcreate(H5P_DATASET_XFER))<0) goto error; if (H5Pget_btree_ratios(xfer, splits+0, splits+1, splits+2)<0) { @@ -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@ diff --git a/test/dtransform.c b/test/dtransform.c index 094f993..3b53aed 100644 --- a/test/dtransform.c +++ b/test/dtransform.c @@ -569,16 +569,16 @@ error: int test_set(void) { hid_t dxpl_id; - H5E_auto_stack_t func; + H5E_auto2_t func; const char* str = "(9/5.0)*x + 32"; char* ptrgetTest = malloc(strlen(str)+1); if((dxpl_id = H5Pcreate(H5P_DATASET_XFER))<0) TEST_ERROR; /* Test get before set */ - H5Eget_auto_stack(H5E_DEFAULT,&func,NULL); + H5Eget_auto2(H5E_DEFAULT,&func,NULL); - H5Eset_auto_stack(H5E_DEFAULT, NULL, NULL); + H5Eset_auto2(H5E_DEFAULT, NULL, NULL); TESTING("H5Pget_data_transform (get before set)") if(H5Pget_data_transform(dxpl_id, ptrgetTest, strlen(str)+1) < 0) { @@ -620,7 +620,7 @@ int test_set(void) TESTING("H5Pset_data_transform (set with invalid transform 8)") INVALID_SET_TEST("(9/5)*x + x^2"); - H5Eset_auto_stack(H5E_DEFAULT, func, NULL); + H5Eset_auto2(H5E_DEFAULT, func, NULL); return 0; diff --git a/test/enum.c b/test/enum.c index ae746c4..7574e40 100644 --- a/test/enum.c +++ b/test/enum.c @@ -401,7 +401,7 @@ test_value_dsnt_exist(void) TESTING("for non-existing name and value"); /* Turn off error reporting since we expect failure in this test */ - if (H5Eset_auto_stack(H5E_DEFAULT, NULL, NULL) < 0) goto error; + if (H5Eset_auto2(H5E_DEFAULT, NULL, NULL) < 0) goto error; if ((datatype_id = H5Tenum_create(H5T_NATIVE_INT))< 0) goto error; diff --git a/test/error_test.c b/test/error_test.c index e8ccacf..7850ff1 100644 --- a/test/error_test.c +++ b/test/error_test.c @@ -77,7 +77,8 @@ hid_t ERR_MIN_GETNUM; #define LONG_DESC_SIZE 8192 -herr_t custom_print_cb(unsigned n, const H5E_error_stack_t *err_desc, void* client_data); +herr_t custom_print_cb(unsigned n, const H5E_error2_t *err_desc, + void *client_data); /*------------------------------------------------------------------------- @@ -92,9 +93,6 @@ herr_t custom_print_cb(unsigned n, const H5E_error_stack_t *err_desc, void* clie * Programmer: Raymond Lu * July 10, 2003 * - * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t @@ -103,8 +101,8 @@ test_error(hid_t file) hid_t dataset, space; hid_t estack_id; hsize_t dims[2]; - const char *FUNC_test_error="test_error"; - H5E_auto_stack_t old_func; + const char *FUNC_test_error = "test_error"; + H5E_auto2_t old_func; void *old_data; TESTING("error API based on data I/O"); @@ -120,53 +118,52 @@ test_error(hid_t file) } H5E_END_TRY; /* Create the dataset */ - if ((dataset = H5Dcreate(file, DSET_NAME, H5T_STD_I32BE, space, - H5P_DEFAULT))<0) { - H5Epush_stack(H5E_DEFAULT, __FILE__, FUNC_test_error, __LINE__, ERR_CLS, ERR_MAJ_IO, ERR_MIN_CREATE, + if((dataset = H5Dcreate(file, DSET_NAME, H5T_STD_I32BE, space, H5P_DEFAULT)) < 0) { + H5Epush2(H5E_DEFAULT, __FILE__, FUNC_test_error, __LINE__, ERR_CLS, ERR_MAJ_IO, ERR_MIN_CREATE, "H5Dcreate failed"); goto error; - } + } /* end if */ /* Test enabling and disabling default printing */ - if (H5Eget_auto_stack(H5E_DEFAULT, &old_func, &old_data)<0) + if(H5Eget_auto2(H5E_DEFAULT, &old_func, &old_data) < 0) TEST_ERROR; - if (old_data != NULL) + if(old_data != NULL) TEST_ERROR; - if (old_func != (H5E_auto_stack_t)H5Eprint_stack) + if(old_func != (H5E_auto2_t)H5Eprint2) TEST_ERROR; - if(H5Eset_auto_stack(H5E_DEFAULT, NULL, NULL)<0) + if(H5Eset_auto2(H5E_DEFAULT, NULL, NULL) < 0) TEST_ERROR; /* Make H5Dwrite fail, verify default print is disabled */ - if (H5Dwrite(FAKE_ID, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, ipoints2)>=0) { - H5Epush_stack(H5E_DEFAULT, __FILE__, FUNC_test_error, __LINE__, ERR_CLS, ERR_MAJ_IO, ERR_MIN_WRITE, + if(H5Dwrite(FAKE_ID, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, ipoints2) >= 0) { + H5Epush2(H5E_DEFAULT, __FILE__, FUNC_test_error, __LINE__, ERR_CLS, ERR_MAJ_IO, ERR_MIN_WRITE, "H5Dwrite shouldn't succeed"); goto error; - } + } /* end if */ - if(H5Eset_auto_stack(H5E_DEFAULT, old_func, old_data)<0) + if(H5Eset_auto2(H5E_DEFAULT, old_func, old_data) < 0) TEST_ERROR; /* Test saving and restoring the current error stack */ - if (H5Dwrite(FAKE_ID, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, ipoints2)<0) { - H5Epush_stack(H5E_DEFAULT, __FILE__, FUNC_test_error, __LINE__, ERR_CLS, ERR_MAJ_IO, ERR_MIN_WRITE, + if(H5Dwrite(FAKE_ID, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, ipoints2) < 0) { + H5Epush2(H5E_DEFAULT, __FILE__, FUNC_test_error, __LINE__, ERR_CLS, ERR_MAJ_IO, ERR_MIN_WRITE, "H5Dwrite failed as supposed to"); estack_id = H5Eget_current_stack(); H5Dclose(dataset); H5Sclose(space); H5Eset_current_stack(estack_id); goto error; - } + } /* end if */ /* In case program comes to this point, close dataset */ - if(H5Dclose(dataset)<0) TEST_ERROR; + if(H5Dclose(dataset) < 0) TEST_ERROR; TEST_ERROR; error: return -1; -} +} /* end test_error() */ /*------------------------------------------------------------------------- @@ -181,62 +178,59 @@ test_error(hid_t file) * Programmer: Raymond Lu * July 10, 2003 * - * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t init_error(void) { ssize_t cls_size = (ssize_t)HDstrlen(ERR_CLS_NAME)+1; - char *cls_name = HDmalloc(strlen(ERR_CLS_NAME)+1); + char *cls_name = HDmalloc(HDstrlen(ERR_CLS_NAME)+1); ssize_t msg_size = (ssize_t)HDstrlen(ERR_MIN_SUBROUTINE_MSG) + 1; char *msg = HDmalloc(HDstrlen(ERR_MIN_SUBROUTINE_MSG)+1); H5E_type_t *msg_type= HDmalloc(sizeof(H5E_type_t)); - if((ERR_CLS = H5Eregister_class(ERR_CLS_NAME, PROG_NAME, PROG_VERS))<0) + if((ERR_CLS = H5Eregister_class(ERR_CLS_NAME, PROG_NAME, PROG_VERS)) < 0) TEST_ERROR; if(cls_size != H5Eget_class_name(ERR_CLS, cls_name, (size_t)cls_size) + 1) TEST_ERROR; - if(strcmp(ERR_CLS_NAME, cls_name)) + if(HDstrcmp(ERR_CLS_NAME, cls_name)) TEST_ERROR; - if((ERR_MAJ_TEST = H5Ecreate_msg(ERR_CLS, H5E_MAJOR, ERR_MAJ_TEST_MSG))<0) + if((ERR_MAJ_TEST = H5Ecreate_msg(ERR_CLS, H5E_MAJOR, ERR_MAJ_TEST_MSG)) < 0) TEST_ERROR; - if((ERR_MAJ_IO = H5Ecreate_msg(ERR_CLS, H5E_MAJOR, ERR_MAJ_IO_MSG))<0) + if((ERR_MAJ_IO = H5Ecreate_msg(ERR_CLS, H5E_MAJOR, ERR_MAJ_IO_MSG)) < 0) TEST_ERROR; - if((ERR_MAJ_API = H5Ecreate_msg(ERR_CLS, H5E_MAJOR, ERR_MAJ_API_MSG))<0) + if((ERR_MAJ_API = H5Ecreate_msg(ERR_CLS, H5E_MAJOR, ERR_MAJ_API_MSG)) < 0) TEST_ERROR; - if((ERR_MIN_SUBROUTINE = H5Ecreate_msg(ERR_CLS, H5E_MINOR, ERR_MIN_SUBROUTINE_MSG))<0) + if((ERR_MIN_SUBROUTINE = H5Ecreate_msg(ERR_CLS, H5E_MINOR, ERR_MIN_SUBROUTINE_MSG)) < 0) TEST_ERROR; - if((ERR_MIN_ERRSTACK = H5Ecreate_msg(ERR_CLS, H5E_MINOR, ERR_MIN_ERRSTACK_MSG))<0) + if((ERR_MIN_ERRSTACK = H5Ecreate_msg(ERR_CLS, H5E_MINOR, ERR_MIN_ERRSTACK_MSG)) < 0) TEST_ERROR; - if((ERR_MIN_CREATE = H5Ecreate_msg(ERR_CLS, H5E_MINOR, ERR_MIN_CREATE_MSG))<0) + if((ERR_MIN_CREATE = H5Ecreate_msg(ERR_CLS, H5E_MINOR, ERR_MIN_CREATE_MSG)) < 0) TEST_ERROR; - if((ERR_MIN_WRITE = H5Ecreate_msg(ERR_CLS, H5E_MINOR, ERR_MIN_WRITE_MSG))<0) + if((ERR_MIN_WRITE = H5Ecreate_msg(ERR_CLS, H5E_MINOR, ERR_MIN_WRITE_MSG)) < 0) TEST_ERROR; - if((ERR_MIN_GETNUM = H5Ecreate_msg(ERR_CLS, H5E_MINOR, ERR_MIN_GETNUM_MSG))<0) + if((ERR_MIN_GETNUM = H5Ecreate_msg(ERR_CLS, H5E_MINOR, ERR_MIN_GETNUM_MSG)) < 0) TEST_ERROR; if(msg_size != H5Eget_msg(ERR_MIN_SUBROUTINE, msg_type, msg, (size_t)msg_size) + 1) TEST_ERROR; if(*msg_type != H5E_MINOR) TEST_ERROR; - if(strcmp(msg, ERR_MIN_SUBROUTINE_MSG)) + if(HDstrcmp(msg, ERR_MIN_SUBROUTINE_MSG)) TEST_ERROR; - free(cls_name); - free(msg); - free(msg_type); + HDfree(cls_name); + HDfree(msg); + HDfree(msg_type); return 0; - error: +error: return -1; -} +} /* end init_error() */ /*------------------------------------------------------------------------- @@ -251,42 +245,40 @@ init_error(void) * Programmer: Raymond Lu * July 14, 2003 * - * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t error_stack(void) { int err_num; - const char *FUNC_error_stack="error_stack"; + const char *FUNC_error_stack = "error_stack"; - if((err_num = H5Eget_num(H5E_DEFAULT))<0) + if((err_num = H5Eget_num(H5E_DEFAULT)) < 0) TEST_ERROR; if(err_num) TEST_ERROR; - if((ERR_STACK = H5Eget_current_stack())<0) + if((ERR_STACK = H5Eget_current_stack()) < 0) TEST_ERROR; /* Make it push error, force this function to fail */ - if((err_num = H5Eget_num(ERR_STACK))==0) { - H5Epush_stack(ERR_STACK, __FILE__, FUNC_error_stack, __LINE__, ERR_CLS, ERR_MAJ_API, ERR_MIN_GETNUM, + if((err_num = H5Eget_num(ERR_STACK)) == 0) { + H5Epush2(ERR_STACK, __FILE__, FUNC_error_stack, __LINE__, ERR_CLS, ERR_MAJ_API, ERR_MIN_GETNUM, "Get number test failed, returned %d", err_num); goto error; - } + } /* end if */ /* In case program falls through here, close the stack and let it fail. */ - if(H5Eclose_stack(ERR_STACK)<0) + if(H5Eclose_stack(ERR_STACK) < 0) TEST_ERROR; return -1; - error: +error: return -1; -} +} /* end error_stack() */ + /*------------------------------------------------------------------------- * Function: long_desc_cb * @@ -299,21 +291,18 @@ error_stack(void) * Programmer: Quincey Koziol * January 19, 2005 * - * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t -long_desc_cb(unsigned UNUSED n, const H5E_error_stack_t *err_desc, void* client_data) +long_desc_cb(unsigned UNUSED n, const H5E_error2_t *err_desc, void *client_data) { - char *real_desc = (char *)client_data; + char *real_desc = (char *)client_data; - if(err_desc->desc!=NULL && HDstrcmp(err_desc->desc,real_desc)==0) + if(err_desc->desc != NULL && HDstrcmp(err_desc->desc, real_desc) == 0) return(0); else return(-1); -} +} /* end long_desc_cb() */ /*------------------------------------------------------------------------- @@ -328,53 +317,54 @@ long_desc_cb(unsigned UNUSED n, const H5E_error_stack_t *err_desc, void* client_ * Programmer: Quincey Koziol * January 19, 2005 * - * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t test_long_desc(void) { - const char *format="Testing very long description string, %s"; + const char *format = "Testing very long description string, %s"; char *long_desc = NULL; char *full_desc = NULL; size_t u; - const char *test_FUNC="test_long_desc"; + const char *test_FUNC = "test_long_desc"; /* Allocate space for the error description info */ - if((long_desc=HDmalloc(LONG_DESC_SIZE))==NULL) TEST_ERROR; - if((full_desc=HDmalloc(LONG_DESC_SIZE+128))==NULL) TEST_ERROR; + if(NULL == (long_desc = HDmalloc(LONG_DESC_SIZE))) TEST_ERROR; + if(NULL == (full_desc = HDmalloc(LONG_DESC_SIZE + 128))) TEST_ERROR; /* Create the long part of the error description */ - for(u=0; u<LONG_DESC_SIZE; u++) - long_desc[u]='A'+(u%26); - long_desc[LONG_DESC_SIZE-1]='\0'; + for(u = 0; u < LONG_DESC_SIZE; u++) + long_desc[u] = 'A' + (u % 26); + long_desc[LONG_DESC_SIZE - 1] = '\0'; /* Clear the default error stack */ - if(H5Eclear_stack(H5E_DEFAULT)<0) TEST_ERROR; + if(H5Eclear2(H5E_DEFAULT) < 0) TEST_ERROR; /* Push an error with a long description */ - if(H5Epush_stack(H5E_DEFAULT, __FILE__, test_FUNC, __LINE__, ERR_CLS, ERR_MAJ_TEST, ERR_MIN_SUBROUTINE, format, long_desc)<0) TEST_ERROR; + if(H5Epush2(H5E_DEFAULT, __FILE__, test_FUNC, __LINE__, ERR_CLS, ERR_MAJ_TEST, ERR_MIN_SUBROUTINE, format, long_desc) < 0) TEST_ERROR; /* Create the string that should be in the description */ - HDsnprintf(full_desc,LONG_DESC_SIZE+128,format,long_desc); + HDsnprintf(full_desc, LONG_DESC_SIZE + 128, format, long_desc); /* Make certain that the description is correct */ - if(H5Ewalk_stack(H5E_DEFAULT, H5E_WALK_UPWARD, long_desc_cb, full_desc)<0) TEST_ERROR; + if(H5Ewalk2(H5E_DEFAULT, H5E_WALK_UPWARD, long_desc_cb, full_desc) < 0) TEST_ERROR; /* Clear the default error stack again */ - if(H5Eclear_stack(H5E_DEFAULT)<0) TEST_ERROR; + if(H5Eclear2(H5E_DEFAULT) < 0) TEST_ERROR; HDfree(long_desc); HDfree(full_desc); + return(0); error: - if(long_desc) HDfree(long_desc); - if(full_desc) HDfree(full_desc); + if(long_desc) + HDfree(long_desc); + if(full_desc) + HDfree(full_desc); + return(-1); -} +} /* end test_long_desc() */ /*------------------------------------------------------------------------- @@ -389,9 +379,6 @@ error: * Programmer: Raymond Lu * July 17, 2003 * - * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t @@ -399,20 +386,21 @@ dump_error(hid_t estack) { /* Print errors in library default way */ fprintf(stderr, "********* Print error stack in HDF5 default way *********\n"); - if(H5Eprint_stack(estack, stderr)<0) + if(H5Eprint2(estack, stderr) < 0) TEST_ERROR; /* Customized way to print errors */ fprintf(stderr, "\n********* Print error stack in customized way *********\n"); - if(H5Ewalk_stack(estack, H5E_WALK_UPWARD, custom_print_cb, stderr)<0) + if(H5Ewalk2(estack, H5E_WALK_UPWARD, custom_print_cb, stderr) < 0) TEST_ERROR; return 0; - error: +error: return -1; -} +} /* end dump_error() */ + /*------------------------------------------------------------------------- * Function: custom_print_cb * @@ -425,13 +413,10 @@ dump_error(hid_t estack) * Programmer: Raymond Lu * July 17, 2003 * - * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t -custom_print_cb(unsigned n, const H5E_error_stack_t *err_desc, void* client_data) +custom_print_cb(unsigned n, const H5E_error2_t *err_desc, void* client_data) { FILE *stream = (FILE *)client_data; char maj[MSG_SIZE]; @@ -440,27 +425,27 @@ custom_print_cb(unsigned n, const H5E_error_stack_t *err_desc, void* client_data const int indent = 4; /* Get descriptions for the major and minor error numbers */ - if(H5Eget_class_name(err_desc->cls_id, cls, MSG_SIZE)<0) + if(H5Eget_class_name(err_desc->cls_id, cls, MSG_SIZE) < 0) TEST_ERROR; - if(H5Eget_msg(err_desc->maj_num, NULL, maj, MSG_SIZE)<0) + if(H5Eget_msg(err_desc->maj_num, NULL, maj, MSG_SIZE) < 0) TEST_ERROR; - if(H5Eget_msg(err_desc->min_num, NULL, min, MSG_SIZE)<0) + if(H5Eget_msg(err_desc->min_num, NULL, min, MSG_SIZE) < 0) TEST_ERROR; - fprintf (stream, "%*serror #%03d: %s in %s(): line %u\n", + fprintf(stream, "%*serror #%03d: %s in %s(): line %u\n", indent, "", n, err_desc->file_name, err_desc->func_name, err_desc->line); - fprintf (stream, "%*sclass: %s\n", indent*2, "", cls); - fprintf (stream, "%*smajor: %s\n", indent*2, "", maj); - fprintf (stream, "%*sminor: %s\n", indent*2, "", min); + fprintf(stream, "%*sclass: %s\n", indent * 2, "", cls); + fprintf(stream, "%*smajor: %s\n", indent * 2, "", maj); + fprintf(stream, "%*sminor: %s\n", indent * 2, "", min); return 0; - error: +error: return -1; -} +} /* end custom_print_cb() */ /*------------------------------------------------------------------------- @@ -475,32 +460,29 @@ custom_print_cb(unsigned n, const H5E_error_stack_t *err_desc, void* client_data * Programmer: Raymond Lu * July 10, 2003 * - * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t close_error(void) { /* Close major errors, let H5Eunregister_class close minor errors */ - if(H5Eclose_msg(ERR_MAJ_TEST)<0) - TEST_ERROR ; + if(H5Eclose_msg(ERR_MAJ_TEST) < 0) + TEST_ERROR; - if(H5Eclose_msg(ERR_MAJ_IO)<0) - TEST_ERROR ; + if(H5Eclose_msg(ERR_MAJ_IO) < 0) + TEST_ERROR; - if(H5Eclose_msg(ERR_MAJ_API)<0) - TEST_ERROR ; + if(H5Eclose_msg(ERR_MAJ_API) < 0) + TEST_ERROR; - if(H5Eunregister_class(ERR_CLS)<0) - TEST_ERROR ; + if(H5Eunregister_class(ERR_CLS) < 0) + TEST_ERROR; return 0; - error: +error: return -1; -} +} /* end close_error() */ /*------------------------------------------------------------------------- @@ -511,8 +493,6 @@ close_error(void) * Programmer: Raymond Lu * July 10, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ int @@ -521,25 +501,25 @@ main(void) hid_t file, fapl; hid_t estack_id; char filename[1024]; - const char *FUNC_main="main"; + const char *FUNC_main = "main"; fprintf(stderr, " This program tests the Error API. There're supposed to be some error messages\n"); /* Initialize errors */ - if(init_error()<0) - TEST_ERROR ; + if(init_error() < 0) + TEST_ERROR; fapl = h5_fileaccess(); h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) - TEST_ERROR ; + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR; /* Test error stack */ - if(error_stack()<0) { + if(error_stack() < 0) { /* Push an error onto error stack */ - if(H5Epush_stack(ERR_STACK, __FILE__, FUNC_main, __LINE__, ERR_CLS, ERR_MAJ_TEST, ERR_MIN_ERRSTACK, - "Error stack test failed")<0) TEST_ERROR; + if(H5Epush2(ERR_STACK, __FILE__, FUNC_main, __LINE__, ERR_CLS, ERR_MAJ_TEST, ERR_MIN_ERRSTACK, + "Error stack test failed") < 0) TEST_ERROR; /* Delete an error from the top of error stack */ H5Epop(ERR_STACK, 1); @@ -548,36 +528,37 @@ main(void) dump_error(ERR_STACK); /* Empty error stack */ - H5Eclear_stack(ERR_STACK); + H5Eclear2(ERR_STACK); /* Close error stack */ H5Eclose_stack(ERR_STACK); - } + } /* end if */ /* Test error API */ - if(test_error(file)<0) { - H5Epush_stack(H5E_DEFAULT, __FILE__, FUNC_main, __LINE__, ERR_CLS, ERR_MAJ_TEST, ERR_MIN_SUBROUTINE, + if(test_error(file) < 0) { + H5Epush2(H5E_DEFAULT, __FILE__, FUNC_main, __LINE__, ERR_CLS, ERR_MAJ_TEST, ERR_MIN_SUBROUTINE, "Error test failed, %s", "it's wrong"); estack_id = H5Eget_current_stack(); - H5Eprint_stack(estack_id, stderr); + H5Eprint2(estack_id, stderr); H5Eclose_stack(estack_id); - } + } /* end if */ /* Test pushing a very long error description */ - if(test_long_desc()<0) TEST_ERROR; + if(test_long_desc() < 0) TEST_ERROR; - if (H5Fclose(file)<0) TEST_ERROR ; + if(H5Fclose(file) < 0) TEST_ERROR; h5_cleanup(FILENAME, fapl); /* Close error information */ - if(close_error()<0) - TEST_ERROR ; + if(close_error() < 0) + TEST_ERROR; printf("All error API tests passed.\n"); return 0; - error: +error: printf("***** ERROR TEST FAILED! *****\n"); return 1; } #endif /*H5_WANT_H5_V1_6_COMPAT*/ + diff --git a/test/fheap.c b/test/fheap.c index b3f6986..68ef1a5 100644 --- a/test/fheap.c +++ b/test/fheap.c @@ -2814,7 +2814,7 @@ test_man_insert_weird(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpa } H5E_END_TRY; if(ret >= 0) TEST_ERROR - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); /* Insert a 1-sized object into heap (should be a 'tiny' object) */ if(add_obj(fh, dxpl, (size_t)10, (size_t)1, &state, NULL)) @@ -5952,7 +5952,7 @@ HDfprintf(stderr, "Random # seed was: %lu\n", seed); } H5E_END_TRY; if(ret >= 0) TEST_ERROR - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); /* Try reading bogus heap ID from heap w/objects */ H5E_BEGIN_TRY { @@ -5960,7 +5960,7 @@ HDfprintf(stderr, "Random # seed was: %lu\n", seed); } H5E_END_TRY; if(ret >= 0) TEST_ERROR - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); /* Close the fractal heap */ if(H5HF_close(fh, dxpl) < 0) diff --git a/test/flush2.c b/test/flush2.c index 2b8cf7a..f8d8aa8 100644 --- a/test/flush2.c +++ b/test/flush2.c @@ -161,7 +161,7 @@ int main(void) { hid_t fapl; - H5E_auto_stack_t func; + H5E_auto2_t func; char name[1024]; const char *envval = NULL; @@ -189,8 +189,8 @@ main(void) /* Check the case where the file was not flushed. This should give an error * so we turn off the error stack temporarily */ TESTING("H5Fflush (part2 without flush)"); - H5Eget_auto_stack(H5E_DEFAULT,&func,NULL); - H5Eset_auto_stack(H5E_DEFAULT, NULL, NULL); + H5Eget_auto2(H5E_DEFAULT,&func,NULL); + H5Eset_auto2(H5E_DEFAULT, NULL, NULL); h5_fixname(FILENAME[1], fapl, name, sizeof name); if(check_file(name, fapl, FALSE)) @@ -206,13 +206,13 @@ main(void) goto error; #endif } - H5Eset_auto_stack(H5E_DEFAULT, func, NULL); + H5Eset_auto2(H5E_DEFAULT, func, NULL); /* Check the case where the file was flushed, but more data was added afterward. This should give an error * so we turn off the error stack temporarily */ TESTING("H5Fflush (part2 with flush and later addition)"); - H5Eget_auto_stack(H5E_DEFAULT,&func,NULL); - H5Eset_auto_stack(H5E_DEFAULT, NULL, NULL); + H5Eget_auto2(H5E_DEFAULT,&func,NULL); + H5Eset_auto2(H5E_DEFAULT, NULL, NULL); h5_fixname(FILENAME[2], fapl, name, sizeof name); if(check_file(name, fapl, TRUE)) @@ -229,7 +229,7 @@ main(void) #endif } - H5Eset_auto_stack(H5E_DEFAULT, func, NULL); + H5Eset_auto2(H5E_DEFAULT, func, NULL); h5_cleanup(FILENAME, fapl); diff --git a/test/gheap.c b/test/gheap.c index d10e553..6dbd8a3 100644 --- a/test/gheap.c +++ b/test/gheap.c @@ -90,7 +90,7 @@ test_1 (hid_t fapl) for (i=0; i<1024; i++) { size = i+1; memset (out, 'A'+i%26, size); - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); status = H5HG_insert (f, H5P_DATASET_XFER_DEFAULT, size, out, obj+i); if (status<0) { H5_FAILED(); @@ -109,7 +109,7 @@ test_1 (hid_t fapl) for (i=0; i<1024; i++) { size = i+1; memset (out, 'A'+i%26, size); - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); if (NULL==H5HG_read (f, H5P_DATASET_XFER_DEFAULT, obj+i, in, NULL)) { H5_FAILED(); puts(" Unable to read object"); @@ -182,7 +182,7 @@ test_2 (hid_t fapl) for (i=0; i<1024; i++) { size = 1024-i; memset (out, 'A'+i%26, size); - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); if (H5HG_insert (f, H5P_DATASET_XFER_DEFAULT, size, out, obj+i)<0) { H5_FAILED(); puts(" Unable to insert object into global heap"); @@ -196,7 +196,7 @@ test_2 (hid_t fapl) for (i=0; i<1024; i++) { size = 1024-i; memset (out, 'A'+i%26, size); - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); if (NULL==H5HG_read (f, H5P_DATASET_XFER_DEFAULT, obj+i, in, NULL)) { H5_FAILED(); puts(" Unable to read object"); @@ -267,7 +267,7 @@ test_3 (hid_t fapl) for (i=0; i<1024; i++) { size = i%30+100; memset (out, 'A'+i%26, size); - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); status = H5HG_insert (f, H5P_DATASET_XFER_DEFAULT, size, out, obj+i); if (status<0) { H5_FAILED(); @@ -346,7 +346,7 @@ test_4 (hid_t fapl) /* Insert */ size = i%30+100; memset (out, 'A'+i%26, size); - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); status = H5HG_insert (f, H5P_DATASET_XFER_DEFAULT, size, out, obj+i); if (status<0) { H5_FAILED(); @@ -360,7 +360,7 @@ test_4 (hid_t fapl) * remove B, insert D, E, F; remove E; etc. */ if (1==i%3) { - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); status = H5HG_remove (f, H5P_DATASET_XFER_DEFAULT, obj+i-1); if (status<0) { H5_FAILED(); diff --git a/test/h5test.h b/test/h5test.h index 8c10faf..4add74c 100644 --- a/test/h5test.h +++ b/test/h5test.h @@ -104,9 +104,9 @@ extern MPI_Info h5_io_info_g; /* MPI INFO object for IO */ #define H5_WARNING() {puts("*WARNING*");fflush(stdout);} #define SKIPPED() {puts(" -SKIP-");fflush(stdout);} #define TEST_ERROR {H5_FAILED(); AT(); goto error;} -#define STACK_ERROR {H5Eprint_stack(H5E_DEFAULT, stdout); goto error;} -#define FAIL_STACK_ERROR {H5_FAILED(); AT(); \ - H5Eprint_stack(H5E_DEFAULT, stdout); goto error;} +#define STACK_ERROR {H5Eprint2(H5E_DEFAULT, stdout); goto error;} +#define FAIL_STACK_ERROR {H5_FAILED(); AT(); H5Eprint2(H5E_DEFAULT, stdout); \ + goto error;} #define FAIL_PUTS_ERROR(s) {H5_FAILED(); AT(); puts(s); goto error;} /* diff --git a/test/lheap.c b/test/lheap.c index 437f635..8f496f4 100644 --- a/test/lheap.c +++ b/test/lheap.c @@ -78,12 +78,12 @@ main(void) goto error; if(NULL == (f = H5I_object(file))) { H5_FAILED(); - H5Eprint_stack(H5E_DEFAULT, stdout); + H5Eprint2(H5E_DEFAULT, stdout); goto error; } if(H5HL_create(f, H5P_DATASET_XFER_DEFAULT, (size_t)0, &heap_addr/*out*/) < 0) { H5_FAILED(); - H5Eprint_stack(H5E_DEFAULT, stdout); + H5Eprint2(H5E_DEFAULT, stdout); goto error; } for(i = 0; i < NOBJS; i++) { @@ -94,7 +94,7 @@ main(void) if ((size_t)(-1)==(obj[i]=H5HL_insert(f, H5P_DATASET_XFER_DEFAULT, heap_addr, strlen(buf)+1, buf))) { H5_FAILED(); - H5Eprint_stack(H5E_DEFAULT, stdout); + H5Eprint2(H5E_DEFAULT, stdout); goto error; } } @@ -115,7 +115,7 @@ main(void) if ((file=H5Fopen(filename, H5F_ACC_RDONLY, fapl))<0) goto error; if (NULL==(f=H5I_object(file))) { H5_FAILED(); - H5Eprint_stack(H5E_DEFAULT, stdout); + H5Eprint2(H5E_DEFAULT, stdout); goto error; } for (i=0; i<NOBJS; i++) { @@ -127,13 +127,13 @@ main(void) if (NULL == (heap = H5HL_protect(f, H5P_DATASET_XFER_DEFAULT, heap_addr))) { H5_FAILED(); - H5Eprint_stack(H5E_DEFAULT, stdout); + H5Eprint2(H5E_DEFAULT, stdout); goto error; } if (NULL == (s = H5HL_offset_into(f, heap, obj[i]))) { H5_FAILED(); - H5Eprint_stack(H5E_DEFAULT, stdout); + H5Eprint2(H5E_DEFAULT, stdout); goto error; } @@ -147,7 +147,7 @@ main(void) if (H5HL_unprotect(f, H5P_DATASET_XFER_DEFAULT, heap, heap_addr, H5AC__NO_FLAGS_SET) < 0) { H5_FAILED(); - H5Eprint_stack(H5E_DEFAULT, stdout); + H5Eprint2(H5E_DEFAULT, stdout); goto error; } } diff --git a/test/ohdr.c b/test/ohdr.c index 24fcd6e..43cc78e 100644 --- a/test/ohdr.c +++ b/test/ohdr.c @@ -76,7 +76,7 @@ main(void) if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) goto error; if (NULL==(f=H5I_object(file))) { - H5Eprint_stack(H5E_DEFAULT, stdout); + H5Eprint2(H5E_DEFAULT, stdout); goto error; } @@ -88,7 +88,7 @@ main(void) HDmemset(&oh_loc, 0, sizeof(oh_loc)); if(H5O_create(f, H5P_DATASET_XFER_DEFAULT, (size_t)64, H5P_GROUP_CREATE_DEFAULT, &oh_loc/*out*/)<0) { H5_FAILED(); - H5Eprint_stack(H5E_DEFAULT, stdout); + H5Eprint2(H5E_DEFAULT, stdout); goto error; } PASSED(); @@ -98,17 +98,17 @@ main(void) time_new = 11111111; if(H5O_msg_create(&oh_loc, H5O_MTIME_NEW_ID, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT) < 0) { H5_FAILED(); - H5Eprint_stack(H5E_DEFAULT, stdout); + H5Eprint2(H5E_DEFAULT, stdout); goto error; } if (H5AC_flush(f, H5P_DATASET_XFER_DEFAULT, TRUE)<0) { H5_FAILED(); - H5Eprint_stack(H5E_DEFAULT, stdout); + H5Eprint2(H5E_DEFAULT, stdout); goto error; } if(NULL == H5O_msg_read(&oh_loc, H5O_MTIME_NEW_ID, &ro, H5P_DATASET_XFER_DEFAULT)) { H5_FAILED(); - H5Eprint_stack(H5E_DEFAULT, stdout); + H5Eprint2(H5E_DEFAULT, stdout); goto error; } if (ro!=time_new) { @@ -126,17 +126,17 @@ main(void) time_new = 33333333; if (H5O_msg_write(&oh_loc, H5O_MTIME_NEW_ID, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT)<0) { H5_FAILED(); - H5Eprint_stack(H5E_DEFAULT, stdout); + H5Eprint2(H5E_DEFAULT, stdout); goto error; } if (H5AC_flush(f, H5P_DATASET_XFER_DEFAULT, TRUE)<0) { H5_FAILED(); - H5Eprint_stack(H5E_DEFAULT, stdout); + H5Eprint2(H5E_DEFAULT, stdout); goto error; } if(NULL == H5O_msg_read(&oh_loc, H5O_MTIME_NEW_ID, &ro, H5P_DATASET_XFER_DEFAULT)) { H5_FAILED(); - H5Eprint_stack(H5E_DEFAULT, stdout); + H5Eprint2(H5E_DEFAULT, stdout); goto error; } if (ro!=time_new) { @@ -161,13 +161,13 @@ main(void) time_new = (i+1)*1000+1; if(H5O_msg_create(&oh_loc, H5O_MTIME_ID, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT) < 0) { H5_FAILED(); - H5Eprint_stack(H5E_DEFAULT, stdout); + H5Eprint2(H5E_DEFAULT, stdout); goto error; } } if (H5AC_flush(f, H5P_DATASET_XFER_DEFAULT, TRUE)<0) { H5_FAILED(); - H5Eprint_stack(H5E_DEFAULT, stdout); + H5Eprint2(H5E_DEFAULT, stdout); goto error; } PASSED(); @@ -181,12 +181,12 @@ main(void) time_new = (i + 1) * 1000 + 10; if(H5O_msg_create(&oh_loc, H5O_MTIME_NEW_ID, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT) < 0) { H5_FAILED(); - H5Eprint_stack(H5E_DEFAULT, stdout); + H5Eprint2(H5E_DEFAULT, stdout); goto error; } if (H5AC_flush(f, H5P_DATASET_XFER_DEFAULT, TRUE)<0) { H5_FAILED(); - H5Eprint_stack(H5E_DEFAULT, stdout); + H5Eprint2(H5E_DEFAULT, stdout); goto error; } } @@ -198,24 +198,24 @@ main(void) TESTING("message deletion"); if (H5O_msg_remove(&oh_loc, H5O_MTIME_NEW_ID, H5O_ALL, TRUE, H5P_DATASET_XFER_DEFAULT)<0) { H5_FAILED(); - H5Eprint_stack(H5E_DEFAULT, stdout); + H5Eprint2(H5E_DEFAULT, stdout); goto error; } if (H5O_msg_remove(&oh_loc, H5O_MTIME_ID, H5O_ALL, TRUE, H5P_DATASET_XFER_DEFAULT)<0) { H5_FAILED(); - H5Eprint_stack(H5E_DEFAULT, stdout); + H5Eprint2(H5E_DEFAULT, stdout); goto error; } if(H5O_msg_read(&oh_loc, H5O_MTIME_NEW_ID, &ro, H5P_DATASET_XFER_DEFAULT)) { H5_FAILED(); puts(" H5O_msg_read() should have failed but didn't"); - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); goto error; } if(H5O_msg_read(&oh_loc, H5O_MTIME_ID, &ro, H5P_DATASET_XFER_DEFAULT)) { H5_FAILED(); puts(" H5O_msg_read() should have failed but didn't"); - H5Eclear_stack(H5E_DEFAULT); + H5Eclear2(H5E_DEFAULT); goto error; } PASSED(); @@ -225,7 +225,7 @@ main(void) TESTING("object header closing"); if (H5O_close(&oh_loc)<0) { H5_FAILED(); - H5Eprint_stack(H5E_DEFAULT, stdout); + H5Eprint2(H5E_DEFAULT, stdout); goto error; } if (H5Fclose(file)<0) goto error; diff --git a/test/testhdf5.h b/test/testhdf5.h index 97e6263..8817725 100644 --- a/test/testhdf5.h +++ b/test/testhdf5.h @@ -40,7 +40,7 @@ if ((ret) == (val)) { \ TestErrPrintf("*** UNEXPECTED RETURN from %s is %ld at line %4d " \ "in %s\n", where, (long)(ret), (int)__LINE__, __FILE__); \ - H5Eprint_stack(H5E_DEFAULT, stdout); \ + H5Eprint2(H5E_DEFAULT, stdout); \ } \ } while(0) @@ -52,7 +52,7 @@ if ((ret)<0) { \ TestErrPrintf ("*** UNEXPECTED RETURN from %s is %ld line %4d in %s\n", \ (where), (long)(ret), (int)__LINE__, __FILE__); \ - H5Eprint_stack(H5E_DEFAULT, stdout); \ + H5Eprint2(H5E_DEFAULT, stdout); \ } \ } @@ -64,7 +64,7 @@ if (!(ret)) { \ TestErrPrintf ("*** UNEXPECTED RETURN from %s is NULL line %4d in %s\n", \ (where), (int)__LINE__, __FILE__); \ - H5Eprint_stack(H5E_DEFAULT, stdout); \ + H5Eprint2(H5E_DEFAULT, stdout); \ } \ } @@ -77,7 +77,7 @@ if ((x) != (val)) { \ TestErrPrintf("*** UNEXPECTED VALUE from %s should be %ld, but is %ld at line %4d " \ "in %s\n", (where), (long)(val), (long)(x), (int)__LINE__, __FILE__); \ - H5Eprint_stack(H5E_DEFAULT, stdout); \ + H5Eprint2(H5E_DEFAULT, stdout); \ } \ } while(0) @@ -90,7 +90,7 @@ if (HDstrcmp(x, val)) { \ TestErrPrintf("*** UNEXPECTED VALUE from %s should be %s, but is %s at line %4d " \ "in %s\n", where, val, x, (int)__LINE__, __FILE__); \ - H5Eprint_stack(H5E_DEFAULT, stdout); \ + H5Eprint2(H5E_DEFAULT, stdout); \ } \ } while(0) @@ -101,11 +101,11 @@ "%ld\n", func, (int)__LINE__, __FILE__, (long)(ret)); \ } \ if (GetTestVerbosity()>=VERBO_HI) \ - H5Eprint_stack(H5E_DEFAULT, stdout); \ + H5Eprint2(H5E_DEFAULT, stdout); \ if ((ret) == FAIL) { \ TestErrPrintf("*** UNEXPECTED RETURN from %s is %ld at line %4d " \ "in %s\n", func, (long)(ret), (int)__LINE__, __FILE__); \ - H5Eprint_stack(H5E_DEFAULT, stdout); \ + H5Eprint2(H5E_DEFAULT, stdout); \ } \ } while(0) diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index 555334a..317cdab 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -3722,7 +3722,7 @@ main(int argc, const char *argv[]) hid_t fid, gid; char *fname = NULL; void *edata; - H5E_auto_stack_t func; + H5E_auto2_t func; find_objs_t info; struct handler_t *hand; int i; @@ -3732,8 +3732,8 @@ main(int argc, const char *argv[]) dump_function_table = &ddl_function_table; /* Disable error reporting */ - H5Eget_auto_stack(H5E_DEFAULT, &func, &edata); - H5Eset_auto_stack(H5E_DEFAULT, NULL, NULL); + H5Eget_auto2(H5E_DEFAULT, &func, &edata); + H5Eset_auto2(H5E_DEFAULT, NULL, NULL); /* Initialize h5tools lib */ h5tools_init(); @@ -3925,7 +3925,7 @@ done: /* To Do: clean up XML table */ - H5Eset_auto_stack(H5E_DEFAULT, func, edata); + H5Eset_auto2(H5E_DEFAULT, func, edata); leave(d_status); } diff --git a/tools/h5jam/h5jam.c b/tools/h5jam/h5jam.c index 559054e..120cde4 100644 --- a/tools/h5jam/h5jam.c +++ b/tools/h5jam/h5jam.c @@ -159,7 +159,7 @@ main (int argc, const char *argv[]) int h5fid; int ofid; void *edata; - H5E_auto_stack_t func; + H5E_auto2_t func; hid_t ifile; hid_t plist; herr_t status; @@ -175,8 +175,8 @@ main (int argc, const char *argv[]) int res; /* Disable error reporting */ - H5Eget_auto_stack (H5E_DEFAULT, &func, &edata); - H5Eset_auto_stack (H5E_DEFAULT, NULL, NULL); + H5Eget_auto2(H5E_DEFAULT, &func, &edata); + H5Eset_auto2(H5E_DEFAULT, NULL, NULL); parse_command_line (argc, argv); @@ -517,22 +517,22 @@ compute_user_block_size (hsize_t ublock_size) * Returns the size of the padded file. */ hsize_t -write_pad (int ofile, hsize_t where) +write_pad(int ofile, hsize_t where) { - unsigned int i; - char buf[1]; - hsize_t psize; + unsigned int i; + char buf[1]; + hsize_t psize; - buf[0] = '\0'; + buf[0] = '\0'; - HDlseek (ofile, (off_t) where, SEEK_SET); + HDlseek(ofile, (off_t) where, SEEK_SET); - psize = compute_user_block_size (where); - psize -= where; + psize = compute_user_block_size (where); + psize -= where; - for (i = 0; i < psize; i++) - { - HDwrite (ofile, buf, 1); - } - return (where + psize); /* the new size of the file. */ + for(i = 0; i < psize; i++) + HDwrite (ofile, buf, 1); + + return(where + psize); /* the new size of the file. */ } + diff --git a/tools/h5jam/h5unjam.c b/tools/h5jam/h5unjam.c index 25559e3..0edc980 100644 --- a/tools/h5jam/h5unjam.c +++ b/tools/h5jam/h5unjam.c @@ -162,7 +162,7 @@ main(int argc, const char *argv[]) int ufid; int h5fid; void *edata; - H5E_auto_stack_t func; + H5E_auto2_t func; hid_t ifile; off_t fsize; hsize_t usize; @@ -173,8 +173,8 @@ main(int argc, const char *argv[]) struct stat sbuf; /* Disable error reporting */ - H5Eget_auto_stack(H5E_DEFAULT, &func, &edata); - H5Eset_auto_stack(H5E_DEFAULT, NULL, NULL); + H5Eget_auto2(H5E_DEFAULT, &func, &edata); + H5Eset_auto2(H5E_DEFAULT, NULL, NULL); parse_command_line(argc, argv); @@ -286,33 +286,33 @@ main(int argc, const char *argv[]) * Returns the size of the output file. */ hsize_t -copy_to_file( int infid, int ofid, ssize_t where, ssize_t how_much ) { - char buf[1024]; - off_t to; - off_t from; - ssize_t nchars = -1; - - - if (how_much <= 0) { - /* nothing to copy */ - return(where); - } - from = where; - to = 0; - - while( how_much > 0) { - HDlseek(infid,from,SEEK_SET); - if (how_much > 512) { - nchars = HDread(infid,buf,(unsigned)512); - } else { - nchars = HDread(infid,buf,(unsigned)how_much); - } - HDlseek(ofid,to,SEEK_SET); - HDwrite(ofid,buf,(unsigned)nchars); - how_much -= nchars; - from += nchars; - to += nchars; - } - - return (where+how_much); +copy_to_file( int infid, int ofid, ssize_t where, ssize_t how_much ) +{ + char buf[1024]; + off_t to; + off_t from; + ssize_t nchars = -1; + + /* nothing to copy */ + if(how_much <= 0) + return(where); + + from = where; + to = 0; + + while( how_much > 0) { + HDlseek(infid,from,SEEK_SET); + if (how_much > 512) + nchars = HDread(infid,buf,(unsigned)512); + else + nchars = HDread(infid,buf,(unsigned)how_much); + HDlseek(ofid,to,SEEK_SET); + HDwrite(ofid,buf,(unsigned)nchars); + how_much -= nchars; + from += nchars; + to += nchars; + } + + return (where + how_much); } + diff --git a/tools/h5jam/tellub.c b/tools/h5jam/tellub.c index e71d4ba..a5d8bbd 100644 --- a/tools/h5jam/tellub.c +++ b/tools/h5jam/tellub.c @@ -128,7 +128,7 @@ main (int argc, const char *argv[]) { char *ifname; void *edata; - H5E_auto_stack_t func; + H5E_auto2_t func; hid_t ifile; hsize_t usize; htri_t testval; @@ -136,8 +136,8 @@ main (int argc, const char *argv[]) hid_t plist; /* Disable error reporting */ - H5Eget_auto_stack(H5E_DEFAULT, &func, &edata); - H5Eset_auto_stack(H5E_DEFAULT, NULL, NULL); + H5Eget_auto2(H5E_DEFAULT, &func, &edata); + H5Eset_auto2(H5E_DEFAULT, NULL, NULL); parse_command_line (argc, argv); @@ -188,3 +188,4 @@ main (int argc, const char *argv[]) return (EXIT_SUCCESS); } + diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c index 6d0da89..d19f200 100644 --- a/tools/h5ls/h5ls.c +++ b/tools/h5ls/h5ls.c @@ -2274,7 +2274,7 @@ main (int argc, const char *argv[]) } /* Turn off HDF5's automatic error printing unless you're debugging h5ls */ - if (!show_errors_g) H5Eset_auto_stack(H5E_DEFAULT, NULL, NULL); + if (!show_errors_g) H5Eset_auto2(H5E_DEFAULT, NULL, NULL); /* Each remaining argument is an hdf5 file followed by an optional slash diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c index 205f45f..4b354b6 100644 --- a/tools/lib/h5diff.c +++ b/tools/lib/h5diff.c @@ -1143,7 +1143,8 @@ hsize_t diff (hid_t file1_id, /* If one or both of these links isn't an external link, we can only * compare information from H5Lget_info since we don't have a query * function registered for them. - /* If the link classes or the buffer length are not the + * + * If the link classes or the buffer length are not the * same, the links are "different" */ if((li1.type != li2.type) || (li1.u.val_size != li2.u.val_size)) diff --git a/tools/misc/h5mkgrp.c b/tools/misc/h5mkgrp.c index f2fecbd..c39d07b 100644 --- a/tools/misc/h5mkgrp.c +++ b/tools/misc/h5mkgrp.c @@ -213,7 +213,7 @@ main(int argc, const char *argv[]) size_t curr_group; /* Current group to create */ /* Disable the HDF5 library's error reporting */ - H5Eset_auto_stack(H5E_DEFAULT, NULL, NULL); + H5Eset_auto2(H5E_DEFAULT, NULL, NULL); /* Initialize h5tools lib */ h5tools_init(); diff --git a/tools/misc/h5stat.c b/tools/misc/h5stat.c index 8db92c1..93871bd 100644 --- a/tools/misc/h5stat.c +++ b/tools/misc/h5stat.c @@ -1201,7 +1201,7 @@ main(int argc, const char *argv[]) int i; /* Disable error reporting */ - H5Eset_auto_stack(H5E_DEFAULT, NULL, NULL); + H5Eset_auto2(H5E_DEFAULT, NULL, NULL); /* Initialize h5tools lib */ h5tools_init(); |