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

Another round of fixing -Wextra-semi-stmt warnings #3264

Merged
merged 15 commits into from
Jul 24, 2023
3 changes: 0 additions & 3 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,7 @@ StatementMacros:
- H5_GCC_DIAG_OFF
- H5_GCC_DIAG_ON
- H5_LEAVE
- HDONE_ERROR
- HERROR
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this macro meant to be removed from StatementMacros even though this PR converts it to a statement like macro?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this macro meant to be removed from StatementMacros

Yes.

even though this PR converts it to a statement like macro?

This PR does some of that and some of the opposite. In the case of HERROR it was changed here to require a trailing semi-colon.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok I was misinterpreting the purpose of StatementMacros. If my understanding is correct, does that mean HDONE_ERROR and HGOTO_DONE_TAG should also be removed from this file based on the changes in this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For HGOTO_DONE_TAG, yes, you are correct. Fixed.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For HGOTO_DONE_TAG, yes, you are correct. Fixed.

For my own education, what's different here between HGOTO_DONE_TAG/HERROR and HDONE_ERROR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, you are correct. I had double checked the 3 I did in the one commit, but HDONE_ERROR was in a different commit. It should also be removed from the StatementMacros list... will do that now...

(They all use the do-while(0) idiom, and such while statements have to have a trailing semicolon (which is not part of the macro) and so they are basically macros that behave like functions. Thus none of them should be in the StatementMacros list.)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, thanks for the clarification!

- HGOTO_DONE
- HGOTO_DONE_TAG
- HGOTO_ERROR
- HMPI_DONE_ERROR
- HMPI_ERROR
Expand Down
14 changes: 8 additions & 6 deletions examples/ph5example.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,25 @@
/* Define some handy debugging shorthands, routines, ... */
/* debugging tools */
#define MESG(x) \
if (verbose) \
printf("%s\n", x);
do { \
if (verbose) \
printf("%s\n", x); \
} while (0)

#define MPI_BANNER(mesg) \
{ \
do { \
printf("--------------------------------\n"); \
printf("Proc %d: ", mpi_rank); \
printf("*** %s\n", mesg); \
printf("--------------------------------\n"); \
}
} while (0)

#define SYNC(comm) \
{ \
do { \
MPI_BANNER("doing a SYNC"); \
MPI_Barrier(comm); \
MPI_BANNER("SYNC DONE"); \
}
} while (0)
/* End of Define some handy debugging shorthands, routines, ... */

/* Constants definitions */
Expand Down
16 changes: 8 additions & 8 deletions src/H5A.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ H5A__create_common(H5VL_object_t *vol_obj, H5VL_loc_params_t *loc_params, const
/* Cleanup on failure */
if (H5I_INVALID_HID == ret_value)
if (attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0)
HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute")
HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute");

FUNC_LEAVE_NOAPI(ret_value)
} /* H5A__create_common() */
Expand Down Expand Up @@ -278,7 +278,7 @@ H5Acreate_async(const char *app_file, const char *app_func, unsigned app_line, h
H5ARG_TRACE10(__func__, "*s*sIui*siiiii", app_file, app_func, app_line, loc_id, attr_name, type_id, space_id, acpl_id, aapl_id, es_id)) < 0) {
/* clang-format on */
if (H5I_dec_app_ref(ret_value) < 0)
HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on attribute ID")
HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on attribute ID");
HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert token into event set")
} /* end if */

Expand Down Expand Up @@ -427,7 +427,7 @@ H5Acreate_by_name_async(const char *app_file, const char *app_func, unsigned app
H5ARG_TRACE12(__func__, "*s*sIui*s*siiiiii", app_file, app_func, app_line, loc_id, obj_name, attr_name, type_id, space_id, acpl_id, aapl_id, lapl_id, es_id)) < 0) {
/* clang-format on */
if (H5I_dec_app_ref(ret_value) < 0)
HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on attribute ID")
HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on attribute ID");
HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert token into event set")
} /* end if */

Expand Down Expand Up @@ -471,7 +471,7 @@ H5A__open_common(H5VL_object_t *vol_obj, H5VL_loc_params_t *loc_params, const ch
/* Cleanup on failure */
if (H5I_INVALID_HID == ret_value)
if (attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0)
HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute")
HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute");

FUNC_LEAVE_NOAPI(ret_value)
} /* H5A__open_common() */
Expand Down Expand Up @@ -590,7 +590,7 @@ H5Aopen_async(const char *app_file, const char *app_func, unsigned app_line, hid
H5ARG_TRACE7(__func__, "*s*sIui*sii", app_file, app_func, app_line, loc_id, attr_name, aapl_id, es_id)) < 0) {
/* clang-format on */
if (H5I_dec_app_ref(ret_value) < 0)
HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on attribute ID")
HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on attribute ID");
HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert token into event set")
} /* end if */

Expand Down Expand Up @@ -721,7 +721,7 @@ H5Aopen_by_name_async(const char *app_file, const char *app_func, unsigned app_l
H5ARG_TRACE9(__func__, "*s*sIui*s*siii", app_file, app_func, app_line, loc_id, obj_name, attr_name, aapl_id, lapl_id, es_id)) < 0) {
/* clang-format on */
if (H5I_dec_app_ref(ret_value) < 0)
HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on attribute ID")
HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on attribute ID");
HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert token into event set")
} /* end if */

Expand Down Expand Up @@ -861,7 +861,7 @@ H5Aopen_by_idx_async(const char *app_file, const char *app_func, unsigned app_li
H5ARG_TRACE11(__func__, "*s*sIui*sIiIohiii", app_file, app_func, app_line, loc_id, obj_name, idx_type, order, n, aapl_id, lapl_id, es_id)) < 0) {
/* clang-format on */
if (H5I_dec_app_ref(ret_value) < 0)
HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on attribute ID")
HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on attribute ID");
HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert token into event set")
} /* end if */

Expand Down Expand Up @@ -2288,7 +2288,7 @@ H5Aclose_async(const char *app_file, const char *app_func, unsigned app_line, hi

done:
if (connector && H5VL_conn_dec_rc(connector) < 0)
HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "can't decrement ref count on connector")
HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "can't decrement ref count on connector");

FUNC_LEAVE_API(ret_value)
} /* H5Aclose_async() */
Expand Down
40 changes: 20 additions & 20 deletions src/H5AC.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr, H5AC_cache_image_co
/* If currently logging, generate a message */
if (f->shared->cache->log_info->logging)
if (H5C_log_write_create_cache_msg(f->shared->cache, ret_value) < 0)
HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");

#ifdef H5_HAVE_PARALLEL
/* if there is a failure, try to tidy up the auxiliary structure */
Expand Down Expand Up @@ -533,7 +533,7 @@ H5AC_evict(H5F_t *f)
/* If currently logging, generate a message */
if (f->shared->cache->log_info->logging)
if (H5C_log_write_evict_cache_msg(f->shared->cache, ret_value) < 0)
HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");

FUNC_LEAVE_NOAPI(ret_value)
} /* H5AC_evict() */
Expand Down Expand Up @@ -571,7 +571,7 @@ H5AC_expunge_entry(H5F_t *f, const H5AC_class_t *type, haddr_t addr, unsigned fl
/* If currently logging, generate a message */
if (f->shared->cache->log_info->logging)
if (H5C_log_write_expunge_entry_msg(f->shared->cache, addr, type->id, ret_value) < 0)
HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");

FUNC_LEAVE_NOAPI(ret_value)
} /* H5AC_expunge_entry() */
Expand Down Expand Up @@ -623,7 +623,7 @@ H5AC_flush(H5F_t *f)
/* If currently logging, generate a message */
if (f->shared->cache->log_info->logging)
if (H5C_log_write_flush_cache_msg(f->shared->cache, ret_value) < 0)
HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");

FUNC_LEAVE_NOAPI(ret_value)
} /* H5AC_flush() */
Expand Down Expand Up @@ -754,7 +754,7 @@ H5AC_insert_entry(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing,
if (f->shared->cache->log_info->logging)
if (H5C_log_write_insert_entry_msg(f->shared->cache, addr, type->id, flags,
((H5C_cache_entry_t *)thing)->size, ret_value) < 0)
HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");

FUNC_LEAVE_NOAPI(ret_value)
} /* H5AC_insert_entry() */
Expand Down Expand Up @@ -835,7 +835,7 @@ H5AC_mark_entry_dirty(void *thing)
if (cache_ptr != NULL && cache_ptr->log_info != NULL)
if (cache_ptr->log_info->logging)
if (H5C_log_write_mark_entry_dirty_msg(cache_ptr, entry_ptr, ret_value) < 0)
HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");

FUNC_LEAVE_NOAPI(ret_value)
} /* H5AC_mark_entry_dirty() */
Expand Down Expand Up @@ -885,7 +885,7 @@ H5AC_mark_entry_clean(void *thing)
if (cache_ptr != NULL && cache_ptr->log_info != NULL)
if (cache_ptr->log_info->logging)
if (H5C_log_write_mark_entry_clean_msg(cache_ptr, entry_ptr, ret_value) < 0)
HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");

FUNC_LEAVE_NOAPI(ret_value)
} /* H5AC_mark_entry_clean() */
Expand Down Expand Up @@ -924,7 +924,7 @@ H5AC_mark_entry_unserialized(void *thing)
if (cache_ptr != NULL && cache_ptr->log_info != NULL)
if (cache_ptr->log_info->logging)
if (H5C_log_write_mark_unserialized_entry_msg(cache_ptr, entry_ptr, ret_value) < 0)
HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");

FUNC_LEAVE_NOAPI(ret_value)
} /* H5AC_mark_entry_unserialized() */
Expand Down Expand Up @@ -962,7 +962,7 @@ H5AC_mark_entry_serialized(void *thing)
if (cache_ptr != NULL && cache_ptr->log_info != NULL)
if (cache_ptr->log_info->logging)
if (H5C_log_write_mark_serialized_entry_msg(cache_ptr, entry_ptr, ret_value) < 0)
HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");

FUNC_LEAVE_NOAPI(ret_value)
} /* H5AC_mark_entry_serialized() */
Expand Down Expand Up @@ -1016,7 +1016,7 @@ H5AC_move_entry(H5F_t *f, const H5AC_class_t *type, haddr_t old_addr, haddr_t ne
/* If currently logging, generate a message */
if (f->shared->cache->log_info->logging)
if (H5C_log_write_move_entry_msg(f->shared->cache, old_addr, new_addr, type->id, ret_value) < 0)
HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");

FUNC_LEAVE_NOAPI(ret_value)
} /* H5AC_move_entry() */
Expand Down Expand Up @@ -1056,7 +1056,7 @@ H5AC_pin_protected_entry(void *thing)
if (cache_ptr != NULL && cache_ptr->log_info != NULL)
if (cache_ptr->log_info->logging)
if (H5C_log_write_pin_entry_msg(cache_ptr, entry_ptr, ret_value) < 0)
HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");

FUNC_LEAVE_NOAPI(ret_value)
} /* H5AC_pin_protected_entry() */
Expand Down Expand Up @@ -1213,7 +1213,7 @@ H5AC_create_flush_dependency(void *parent_thing, void *child_thing)
if (cache_ptr->log_info->logging)
if (H5C_log_write_create_fd_msg(cache_ptr, (H5AC_info_t *)parent_thing,
(H5AC_info_t *)child_thing, ret_value) < 0)
HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");

FUNC_LEAVE_NOAPI(ret_value)
} /* H5AC_create_flush_dependency() */
Expand Down Expand Up @@ -1287,7 +1287,7 @@ H5AC_protect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *udata, unsi
if (f->shared->cache->log_info->logging)
if (H5C_log_write_protect_entry_msg(f->shared->cache, (H5AC_info_t *)thing, type->id, flags,
fake_ret_value) < 0)
HDONE_ERROR(H5E_CACHE, H5E_LOGGING, NULL, "unable to emit log message")
HDONE_ERROR(H5E_CACHE, H5E_LOGGING, NULL, "unable to emit log message");
}

FUNC_LEAVE_NOAPI(ret_value)
Expand Down Expand Up @@ -1381,7 +1381,7 @@ H5AC_resize_entry(void *thing, size_t new_size)
if (cache_ptr != NULL && cache_ptr->log_info != NULL)
if (cache_ptr->log_info->logging)
if (H5C_log_write_resize_entry_msg(cache_ptr, entry_ptr, new_size, ret_value) < 0)
HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");

FUNC_LEAVE_NOAPI(ret_value)
} /* H5AC_resize_entry() */
Expand Down Expand Up @@ -1421,7 +1421,7 @@ H5AC_unpin_entry(void *thing)
if (cache_ptr != NULL && cache_ptr->log_info != NULL)
if (cache_ptr->log_info->logging)
if (H5C_log_write_unpin_entry_msg(cache_ptr, entry_ptr, ret_value) < 0)
HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");

FUNC_LEAVE_NOAPI(ret_value)
} /* H5AC_unpin_entry() */
Expand Down Expand Up @@ -1462,7 +1462,7 @@ H5AC_destroy_flush_dependency(void *parent_thing, void *child_thing)
if (cache_ptr->log_info->logging)
if (H5C_log_write_destroy_fd_msg(cache_ptr, (H5AC_info_t *)parent_thing,
(H5AC_info_t *)child_thing, ret_value) < 0)
HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");

FUNC_LEAVE_NOAPI(ret_value)
} /* H5AC_destroy_flush_dependency() */
Expand Down Expand Up @@ -1553,7 +1553,7 @@ H5AC_unprotect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing, un
/* If we fail to log the deleted entry, push an error but still
* participate in a possible sync point ahead
*/
HDONE_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "H5AC__log_deleted_entry() failed")
HDONE_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "H5AC__log_deleted_entry() failed");
}
}
} /* end if */
Expand All @@ -1573,7 +1573,7 @@ H5AC_unprotect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing, un
/* If currently logging, generate a message */
if (f->shared->cache->log_info->logging)
if (H5C_log_write_unprotect_entry_msg(f->shared->cache, addr, type->id, flags, ret_value) < 0)
HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");

FUNC_LEAVE_NOAPI(ret_value)
} /* H5AC_unprotect() */
Expand Down Expand Up @@ -1828,7 +1828,7 @@ H5AC_set_cache_auto_resize_config(H5AC_t *cache_ptr, const H5AC_cache_config_t *
/* If currently logging, generate a message */
if (cache_ptr->log_info->logging)
if (H5C_log_write_set_cache_config_msg(cache_ptr, config_ptr, ret_value) < 0)
HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");

FUNC_LEAVE_NOAPI(ret_value)
} /* H5AC_set_cache_auto_resize_config() */
Expand Down Expand Up @@ -2532,7 +2532,7 @@ H5AC_remove_entry(void *_entry)
if (cache != NULL && cache->log_info != NULL)
if (cache->log_info->logging)
if (H5C_log_write_remove_entry_msg(cache, entry, ret_value) < 0)
HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");

FUNC_LEAVE_NOAPI(ret_value)
} /* H5AC_remove_entry() */
Expand Down
Loading