-
-
Notifications
You must be signed in to change notification settings - Fork 265
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
Avoid popping API context when one wasn't pushed #848
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2082,13 +2082,17 @@ H5_DLL herr_t H5CX_pop(hbool_t update_dxpl_props); | |
/* Push the API context */ \ | ||
if (H5CX_push() < 0) \ | ||
HGOTO_ERROR(H5E_FUNC, H5E_CANTSET, err, "can't set API context") \ | ||
else \ | ||
api_ctx_pushed = TRUE; \ | ||
\ | ||
BEGIN_MPE_LOG | ||
|
||
/* Use this macro for all "normal" API functions */ | ||
#define FUNC_ENTER_API(err) \ | ||
{ \ | ||
{ \ | ||
hbool_t api_ctx_pushed = FALSE; \ | ||
\ | ||
FUNC_ENTER_API_COMMON \ | ||
FUNC_ENTER_API_INIT(err); \ | ||
FUNC_ENTER_API_PUSH(err); \ | ||
|
@@ -2103,6 +2107,8 @@ H5_DLL herr_t H5CX_pop(hbool_t update_dxpl_props); | |
#define FUNC_ENTER_API_NOCLEAR(err) \ | ||
{ \ | ||
{ \ | ||
hbool_t api_ctx_pushed = FALSE; \ | ||
\ | ||
FUNC_ENTER_API_COMMON \ | ||
FUNC_ENTER_API_INIT(err); \ | ||
FUNC_ENTER_API_PUSH(err); \ | ||
|
@@ -2369,14 +2375,17 @@ H5_DLL herr_t H5CX_pop(hbool_t update_dxpl_props); | |
H5_API_SET_CANCEL | ||
|
||
#define FUNC_LEAVE_API_COMMON(ret_value) \ | ||
; \ | ||
} /*end scope from end of FUNC_ENTER*/ \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't belong here, as FUNC_ENTER_API_COMMON doesn't leave the trailing opening brace, it's the individual FUNC_ENTER_ macros that do. Including the brace here can mess up the takedown ordering inside the FUNC_LEAVE_ macros, so the changes here move back to duplicating the closing brace in each FUNC_LEAVE_ macro rather than trying to keep it in a common place. |
||
FINISH_MPE_LOG \ | ||
H5TRACE_RETURN(ret_value); | ||
|
||
#define FUNC_LEAVE_API(ret_value) \ | ||
; \ | ||
} /*end scope from end of FUNC_ENTER*/ \ | ||
FUNC_LEAVE_API_COMMON(ret_value); \ | ||
(void)H5CX_pop(TRUE); \ | ||
if (api_ctx_pushed) { \ | ||
(void)H5CX_pop(TRUE); \ | ||
api_ctx_pushed = FALSE; \ | ||
} \ | ||
H5_POP_FUNC \ | ||
if (err_occurred) \ | ||
(void)H5E_dump_api_stack(TRUE); \ | ||
|
@@ -2387,6 +2396,8 @@ H5_DLL herr_t H5CX_pop(hbool_t update_dxpl_props); | |
|
||
/* Use this macro to match the FUNC_ENTER_API_NOINIT macro */ | ||
#define FUNC_LEAVE_API_NOINIT(ret_value) \ | ||
; \ | ||
} /*end scope from end of FUNC_ENTER*/ \ | ||
FUNC_LEAVE_API_COMMON(ret_value); \ | ||
H5_POP_FUNC \ | ||
if (err_occurred) \ | ||
|
@@ -2399,6 +2410,8 @@ H5_DLL herr_t H5CX_pop(hbool_t update_dxpl_props); | |
|
||
/* Use this macro to match the FUNC_ENTER_API_NOINIT_NOERR_NOFS macro */ | ||
#define FUNC_LEAVE_API_NOFS(ret_value) \ | ||
; \ | ||
} /*end scope from end of FUNC_ENTER*/ \ | ||
FUNC_LEAVE_API_COMMON(ret_value); \ | ||
FUNC_LEAVE_API_THREADSAFE \ | ||
return (ret_value); \ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I'd like to have this variable restricted to the scope of FUNC_ENTER_API_PUSH, GCC gives false positives about possible use of an uninitialized variable unless it's at this broader scope. I suspect a ton of macro refactoring would be needed to straighten GCC's situation out.