Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add posix_errno to H5E_error2_t struct #34

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/H5E.c
Original file line number Diff line number Diff line change
Expand Up @@ -1357,7 +1357,7 @@ H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line, hid
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")

/* Push the error on the stack */
if (H5E__push_stack(estack, file, func, line, cls_id, maj_id, min_id, tmp) < 0)
if (H5E__push_stack(estack, file, func, line, cls_id, maj_id, min_id, tmp, 0) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't push error on stack")

done:
Expand Down
2 changes: 1 addition & 1 deletion src/H5Edeprec.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ H5Epush1(const char *file, const char *func, unsigned line, H5E_major_t maj, H5E
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)
if (H5E__push_stack(NULL, file, func, line, H5E_ERR_CLS_g, maj, min, str, 0) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't push error on stack")

done:
Expand Down
7 changes: 4 additions & 3 deletions src/H5Eint.c
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ H5E__set_auto(H5E_t *estack, const H5E_auto_op_t *op, void *client_data)
*-------------------------------------------------------------------------
*/
herr_t
H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned line, hid_t cls_id, hid_t maj_id,
H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned line, hid_t cls_id, int posix_errno, hid_t maj_id,
hid_t min_id, const char *fmt, ...)
{
va_list ap; /* Varargs info */
Expand Down Expand Up @@ -684,7 +684,7 @@ H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned lin
HGOTO_DONE(FAIL)

/* Push the error on the stack */
if (H5E__push_stack(estack, file, func, line, cls_id, maj_id, min_id, tmp) < 0)
if (H5E__push_stack(estack, file, func, line, cls_id, maj_id, min_id, tmp, posix_errno) < 0)
HGOTO_DONE(FAIL)

done:
Expand Down Expand Up @@ -721,7 +721,7 @@ H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned lin
*/
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)
hid_t min_id, const char *desc, int posix_errno)
{
herr_t ret_value = SUCCEED; /* Return value */

Expand Down Expand Up @@ -779,6 +779,7 @@ H5E__push_stack(H5E_t *estack, const char *file, const char *func, unsigned line
estack->slot[estack->nused].line = line;
if (NULL == (estack->slot[estack->nused].desc = H5MM_xstrdup(desc)))
HGOTO_DONE(FAIL)
estack->slot[estack->nused].posix_errno = posix_errno;
estack->nused++;
} /* end if */

Expand Down
2 changes: 1 addition & 1 deletion src/H5Epkg.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ H5_DLL herr_t H5E__term_deprec_interface(void);
H5_DLL H5E_t *H5E__get_stack(void);
#endif /* H5_HAVE_THREADSAFE */
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);
hid_t maj_id, hid_t min_id, const char *desc, int posix_errno);
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__print(const H5E_t *estack, FILE *stream, hbool_t bk_compat);
H5_DLL herr_t H5E__walk(const H5E_t *estack, H5E_direction_t direction, const H5E_walk_op_t *op,
Expand Down
24 changes: 17 additions & 7 deletions src/H5Eprivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ typedef struct H5E_t H5E_t;
* error number, the minor error number, and a description of the error.
*/
#define HERROR(maj_id, min_id, ...) \
H5E_printf_stack(NULL, __FILE__, FUNC, __LINE__, H5E_ERR_CLS_g, maj_id, min_id, __VA_ARGS__)
H5E_printf_stack(NULL, __FILE__, FUNC, __LINE__, H5E_ERR_CLS_g, 0, maj_id, min_id, __VA_ARGS__)

#define HSYS_ERROR(maj_id, min_id, posix_errno, ...) \
H5E_printf_stack(NULL, __FILE__, FUNC, __LINE__, H5E_ERR_CLS_g, posix_errno, maj_id, min_id, __VA_ARGS__)

/*
* HCOMMON_ERROR macro, used by HDONE_ERROR and HGOTO_ERROR
Expand All @@ -42,6 +45,11 @@ typedef struct H5E_t H5E_t;
err_occurred = TRUE; \
err_occurred = err_occurred; /* Shut GCC warnings up! */

#define HSYS_COMMON_ERROR(maj, min, posix_errno, ...) \
HSYS_ERROR(maj, min, posix_errno, __VA_ARGS__); \
err_occurred = TRUE; \
err_occurred = err_occurred; /* Shut GCC warnings up! */

/*
* HDONE_ERROR macro, used to facilitate error reporting between a
* FUNC_ENTER() and a FUNC_LEAVE() within a function body, but _AFTER_ the
Expand Down Expand Up @@ -114,14 +122,16 @@ typedef struct H5E_t H5E_t;
#define HSYS_DONE_ERROR(majorcode, minorcode, retcode, str) \
{ \
int myerrno = errno; \
HDONE_ERROR(majorcode, minorcode, retcode, "%s, errno = %d, error message = '%s'", str, myerrno, \
HDstrerror(myerrno)); \
HSYS_COMMON_ERROR(majorcode, minorcode, myerrno, "%s, errno = %d, error message = '%s'", str, \
myerrno, HDstrerror(myerrno)); \
ret_value = ret_val; \
}
#define HSYS_GOTO_ERROR(majorcode, minorcode, retcode, str) \
{ \
int myerrno = errno; \
HGOTO_ERROR(majorcode, minorcode, retcode, "%s, errno = %d, error message = '%s'", str, myerrno, \
HDstrerror(myerrno)); \
HSYS_COMMON_ERROR(majorcode, minorcode, myerrno, "%s, errno = %d, error message = '%s'", str, \
myerrno, HDstrerror(myerrno)); \
HGOTO_DONE(retcode) \
}

#ifdef H5_HAVE_PARALLEL
Expand Down Expand Up @@ -160,7 +170,7 @@ extern int H5E_mpi_error_str_len;
* and an optional set of arguments for the printf format arguments.
*/
#define H5E_PRINTF(...) \
H5E_printf_stack(NULL, __FILE__, FUNC, __LINE__, H5E_ERR_CLS_g, H5_MY_PKG_ERR, __VA_ARGS__)
H5E_printf_stack(NULL, __FILE__, FUNC, __LINE__, H5E_ERR_CLS_g, 0, H5_MY_PKG_ERR, __VA_ARGS__)

/*
* H5_LEAVE macro, used to facilitate control flow between a
Expand Down Expand Up @@ -199,7 +209,7 @@ catch_except:;
/* Library-private functions defined in H5E package */
H5_DLL herr_t H5E_init(void);
H5_DLL herr_t H5E_printf_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 *fmt, ...) H5_ATTR_FORMAT(printf, 8, 9);
int posix_errno, hid_t maj_id, hid_t min_id, const char *fmt, ...) H5_ATTR_FORMAT(printf, 9, 10);
H5_DLL herr_t H5E_clear_stack(H5E_t *estack);
H5_DLL herr_t H5E_dump_api_stack(hbool_t is_api);

Expand Down
1 change: 1 addition & 0 deletions src/H5Epublic.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ typedef struct H5E_error2_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 */
int posix_errno;/*system errno, or 0 if not applicable */
} H5E_error2_t;

/* When this header is included from a private header, don't make calls to H5open() */
Expand Down