[svn-r13648] Description:

Rename new error handling API routines from H5E<foo>_stack() to
H5E<foo>2().

Tested on:
    Mac OS X/32 10.4.9 (amazon)
    FreeBSD/32 6.2 (duty)
    FreeBSD/64 6.2 (liberty)
This commit is contained in:
Quincey Koziol 2007-04-11 20:59:45 -05:00
parent de71a7fe74
commit d6bb18abbc
35 changed files with 2035 additions and 1841 deletions

View File

@ -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

View File

@ -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" );
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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) {

View File

@ -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 */

1671
src/H5E.c

File diff suppressed because it is too large Load Diff

433
src/H5Edeprec.c Normal file
View File

@ -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() */

859
src/H5Eint.c Normal file
View File

@ -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() */

105
src/H5Epkg.h Normal file
View File

@ -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 */

View File

@ -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

View File

@ -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 */

View File

@ -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*/

View File

@ -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) {

View File

@ -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':

View File

@ -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 \

View File

@ -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@

View File

@ -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;

View File

@ -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;

View File

@ -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*/

View File

@ -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)

View File

@ -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);

View File

@ -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();

View File

@ -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;}
/*

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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)

View File

@ -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);
}

View File

@ -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. */
}

View File

@ -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;
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);
if (how_much <= 0) {
/* nothing to copy */
return(where);
}
from = where;
to = 0;
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;
}
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);
return (where + how_much);
}

View File

@ -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);
}

View File

@ -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

View File

@ -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))

View File

@ -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();

View File

@ -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();