Skip to content

Commit

Permalink
Add 'warning density' computation to the warnhist script (HDFGroup#3910)
Browse files Browse the repository at this point in the history
* Add 'warning density' computation to the warnhist script, along with several
cleanups to it.   Add "--enable-show-all-warnings" configure (and CMake)
option to disable compiler diagnostic suppression (and therefore show all the
otherwise suppressed compiler diagnostics), disabled by default.  Clean up
a buncn of misc. warnings.

Signed-off-by: Quincey Koziol <qkoziol@amazon.com>
  • Loading branch information
qkoziol authored and brtnfld committed Dec 31, 2023
1 parent dddbebd commit 67bef18
Show file tree
Hide file tree
Showing 18 changed files with 414 additions and 136 deletions.
301 changes: 269 additions & 32 deletions bin/warnhist

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions config/cmake/ConfigureChecks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,17 @@ if (HDF5_ENABLE_CODESTACK)
endif ()
MARK_AS_ADVANCED (HDF5_ENABLE_CODESTACK)

# ----------------------------------------------------------------------
# Check if they would like to show all warnings (not suppressed internally)
#-----------------------------------------------------------------------------
option (HDF5_SHOW_ALL_WARNINGS "Show all warnings (not suppressed internally)." OFF)
mark_as_advanced (HDF5_SHOW_ALL_WARNINGS)
if (HDF5_SHOW_ALL_WARNINGS)
message (STATUS "....All warnings will be displayed")
set (${HDF_PREFIX}_SHOW_ALL_WARNINGS 1)
endif ()
MARK_AS_ADVANCED (HDF5_SHOW_ALL_WARNINGS)

# ----------------------------------------------------------------------
# Check if they would like to use file locking by default
#-----------------------------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions config/cmake/H5pubconf.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,9 @@
/* Check exception handling functions during data conversions */
#cmakedefine H5_WANT_DCONV_EXCEPTION @H5_WANT_DCONV_EXCEPTION@

/* Define if showing all compiler warnings are desired (i.e. don't suppress them internally) */
#cmakedefine H5_SHOW_ALL_WARNINGS @H5_SHOW_ALL_WARNINGS@

/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
#if !defined(__APPLE__)
Expand Down
39 changes: 39 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2321,6 +2321,45 @@ case "X-$DEV_WARNINGS" in
;;
esac

## ----------------------------------------------------------------------
## Check if they would like suppessed compiler diagnostics displayed
## (i.e. not suppressed)
##
## NOTE: Compiler diagnostics (i.e. warnings) are suppressed for some
## "noisy" warnings that are harmless (in the opinion of the primary
## HDF5 development team), but this option is provided to allow
## developers to see those warnings.
##
AC_MSG_CHECKING([whether showing all compiler warnings is enabled])
AC_ARG_ENABLE([show-all-warnings],
[AS_HELP_STRING([--enable-show-all-warnings],
[Enable showing all compiler warnings (for developer debugging).
[default=no]
])],
[SHOW_ALL_WARNINGS=$enableval])

## Set the default level.
if test "X-$SHOW_ALL_WARNINGS" = X- ; then
SHOW_ALL_WARNINGS=no
fi

## Allow this variable to be substituted in
## other files (src/libhdf5.settings.in, etc.)
AC_SUBST([SHOW_ALL_WARNINGS])

case "X-$SHOW_ALL_WARNINGS" in
X-yes)
AC_MSG_RESULT([yes])
AC_DEFINE([SHOW_ALL_WARNINGS], [1], [Define if showing all warnings is desired (i.e. not suppressed internally with H5_DIAG_OFF)])
;;
X-no)
AC_MSG_RESULT([no])
;;
*)
AC_MSG_ERROR([Unrecognized value: $SHOW_ALL_WARNINGS])
;;
esac

## ----------------------------------------------------------------------
## Check if the compiler should use profiling flags/settings
##
Expand Down
4 changes: 2 additions & 2 deletions fortran/src/H5config_f.inc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
#endif

! Define if on APPLE
#cmakedefine01 H5_HAVE_DARWIN
#if H5_HAVE_DARWIN == 0
#cmakedefine01 CMAKE_H5_HAVE_DARWIN
#if CMAKE_H5_HAVE_DARWIN == 0
#undef H5_HAVE_DARWIN
#else
#define H5_HAVE_DARWIN
Expand Down
1 change: 1 addition & 0 deletions release_docs/INSTALL_CMake.txt
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,7 @@ ALLOW_UNSUPPORTED "Allow unsupported combinations of configure opti
HDF5_EXTERNAL_LIB_PREFIX "Use prefix for custom library naming." ""
HDF5_DISABLE_COMPILER_WARNINGS "Disable compiler warnings" OFF
HDF5_ENABLE_ALL_WARNINGS "Enable all warnings" OFF
HDF5_SHOW_ALL_WARNINGS "Show all warnings (i.e. not suppress "noisy" ones internally)" OFF
HDF5_ENABLE_CODESTACK "Enable the function stack tracing (for developer debugging)." OFF
HDF5_ENABLE_COVERAGE "Enable code coverage for Libraries and Programs" OFF
HDF5_ENABLE_DEBUG_APIS "Turn on extra debug output in all packages" OFF
Expand Down
2 changes: 1 addition & 1 deletion src/H5Dpkg.h
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ H5_DLL herr_t H5D__chunk_allocated(const H5D_t *dset, hsize_t *nbytes);
H5_DLL herr_t H5D__chunk_allocate(const H5D_t *dset, bool full_overwrite, const hsize_t old_dim[]);
H5_DLL herr_t H5D__chunk_file_alloc(const H5D_chk_idx_info_t *idx_info, const H5F_block_t *old_chunk,
H5F_block_t *new_chunk, bool *need_insert, const hsize_t *scaled);
H5_DLL void *H5D__chunk_mem_alloc(size_t size, void *pline);
H5_DLL void *H5D__chunk_mem_alloc(size_t size, void *pline) H5_ATTR_MALLOC;
H5_DLL void H5D__chunk_mem_free(void *chk, void *pline);
H5_DLL void *H5D__chunk_mem_xfree(void *chk, const void *pline);
H5_DLL void *H5D__chunk_mem_realloc(void *chk, size_t size, const H5O_pline_t *pline);
Expand Down
2 changes: 1 addition & 1 deletion src/H5EApkg.h
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ H5_DLL herr_t H5EA__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t
H5_DLL H5EA_hdr_t *H5EA__hdr_alloc(H5F_t *f);
H5_DLL herr_t H5EA__hdr_init(H5EA_hdr_t *hdr, void *ctx_udata);
H5_DLL haddr_t H5EA__hdr_create(H5F_t *f, const H5EA_create_t *cparam, void *ctx_udata);
H5_DLL void *H5EA__hdr_alloc_elmts(H5EA_hdr_t *hdr, size_t nelmts);
H5_DLL void *H5EA__hdr_alloc_elmts(H5EA_hdr_t *hdr, size_t nelmts) H5_ATTR_MALLOC;
H5_DLL herr_t H5EA__hdr_free_elmts(H5EA_hdr_t *hdr, size_t nelmts, void *elmts);
H5_DLL herr_t H5EA__hdr_incr(H5EA_hdr_t *hdr);
H5_DLL herr_t H5EA__hdr_decr(H5EA_hdr_t *hdr);
Expand Down
2 changes: 1 addition & 1 deletion src/H5ESpkg.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ typedef int (*H5ES_list_iter_func_t)(H5ES_event_t *ev, void *ctx);
/******************************/
/* Package Private Prototypes */
/******************************/
H5_DLL H5ES_t *H5ES__create(void);
H5_DLL H5ES_t *H5ES__create(void) H5_ATTR_MALLOC;
H5_DLL herr_t H5ES__insert_request(H5ES_t *es, H5VL_t *connector, void *token);
H5_DLL herr_t H5ES__wait(H5ES_t *es, uint64_t timeout, size_t *num_in_progress, bool *op_failed);
H5_DLL herr_t H5ES__get_requests(H5ES_t *es, H5_iter_order_t order, hid_t *connector_ids, void **requests,
Expand Down
15 changes: 6 additions & 9 deletions src/H5Idbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata)

fprintf(stderr, " id = %" PRIdHID "\n", info->id);
fprintf(stderr, " count = %u\n", info->count);
fprintf(stderr, " obj = 0x%8p\n", info->object);
fprintf(stderr, " obj = 0x%8p\n", info->u.c_object);
fprintf(stderr, " marked = %d\n", info->marked);

/* Get the group location, so we get get the name */
switch (type) {
case H5I_GROUP: {
const H5VL_object_t *vol_obj = (const H5VL_object_t *)info->object;
const H5VL_object_t *vol_obj = (const H5VL_object_t *)info->u.c_object;

object = H5VL_object_data(vol_obj);
if (H5_VOL_NATIVE == vol_obj->connector->cls->value)
Expand All @@ -98,7 +98,7 @@ H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata)
}

case H5I_DATASET: {
const H5VL_object_t *vol_obj = (const H5VL_object_t *)info->object;
const H5VL_object_t *vol_obj = (const H5VL_object_t *)info->u.c_object;

object = H5VL_object_data(vol_obj);
if (H5_VOL_NATIVE == vol_obj->connector->cls->value)
Expand All @@ -107,13 +107,10 @@ H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata)
}

case H5I_DATATYPE: {
const H5T_t *dt = (const H5T_t *)info->object;
H5T_t *dt = info->u.object;

H5_GCC_CLANG_DIAG_OFF("cast-qual")
object = (void *)H5T_get_actual_type((H5T_t *)dt);
H5_GCC_CLANG_DIAG_ON("cast-qual")

path = H5T_nameof(object);
object = H5T_get_actual_type((H5T_t *)dt);
path = H5T_nameof(object);
break;
}

Expand Down
58 changes: 19 additions & 39 deletions src/H5Iint.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,17 +369,16 @@ H5I__mark_node(void *_info, void H5_ATTR_UNUSED *key, void *_udata)
*/
if (udata->force || (info->count - (!udata->app_ref * info->app_count)) <= 1) {
/* Check if this is an un-realized future object */
H5_GCC_CLANG_DIAG_OFF("cast-qual")
if (info->is_future) {
/* Discard the future object */
if ((info->discard_cb)((void *)info->object) < 0) {
if ((info->discard_cb)(info->u.object) < 0) {
if (udata->force) {
#ifdef H5I_DEBUG
if (H5DEBUG(I)) {
fprintf(H5DEBUG(I),
"H5I: discard type=%d obj=%p "
"failure ignored\n",
(int)udata->type_info->cls->type, info->object);
(int)udata->type_info->cls->type, info->u.c_object);
}
#endif /* H5I_DEBUG */

Expand All @@ -395,14 +394,14 @@ H5I__mark_node(void *_info, void H5_ATTR_UNUSED *key, void *_udata)
else {
/* Check for a 'free' function and call it, if it exists */
if (udata->type_info->cls->free_func &&
(udata->type_info->cls->free_func)((void *)info->object, H5_REQUEST_NULL) < 0) {
(udata->type_info->cls->free_func)(info->u.object, H5_REQUEST_NULL) < 0) {
if (udata->force) {
#ifdef H5I_DEBUG
if (H5DEBUG(I)) {
fprintf(H5DEBUG(I),
"H5I: free type=%d obj=%p "
"failure ignored\n",
(int)udata->type_info->cls->type, info->object);
(int)udata->type_info->cls->type, info->u.c_object);
}
#endif /* H5I_DEBUG */

Expand All @@ -415,7 +414,6 @@ H5I__mark_node(void *_info, void H5_ATTR_UNUSED *key, void *_udata)
mark = true;
}
}
H5_GCC_CLANG_DIAG_ON("cast-qual")

/* Remove ID if requested */
if (mark) {
Expand Down Expand Up @@ -524,7 +522,7 @@ H5I__register(H5I_type_t type, const void *object, bool app_ref, H5I_future_real
info->id = new_id;
info->count = 1; /* initial reference count */
info->app_count = !!app_ref;
info->object = object;
info->u.c_object = object;
info->is_future = (NULL != realize_cb);
info->realize_cb = realize_cb;
info->discard_cb = discard_cb;
Expand Down Expand Up @@ -633,7 +631,7 @@ H5I_register_using_existing_id(H5I_type_t type, void *object, bool app_ref, hid_
info->id = existing_id;
info->count = 1; /* initial reference count*/
info->app_count = !!app_ref;
info->object = object;
info->u.object = object;
/* This API call is only used by the native VOL connector, which is
* not asynchronous.
*/
Expand Down Expand Up @@ -677,12 +675,10 @@ H5I_subst(hid_t id, const void *new_object)
HGOTO_ERROR(H5E_ID, H5E_NOTFOUND, NULL, "can't get ID ref count");

/* Get the old object pointer to return */
H5_GCC_CLANG_DIAG_OFF("cast-qual")
ret_value = (void *)info->object;
H5_GCC_CLANG_DIAG_ON("cast-qual")
ret_value = info->u.object;

/* Set the new object pointer for the ID */
info->object = new_object;
info->u.c_object = new_object;

done:
FUNC_LEAVE_NOAPI(ret_value)
Expand All @@ -709,12 +705,9 @@ H5I_object(hid_t id)
FUNC_ENTER_NOAPI_NOERR

/* General lookup of the ID */
if (NULL != (info = H5I__find_id(id))) {
if (NULL != (info = H5I__find_id(id)))
/* Get the object pointer to return */
H5_GCC_CLANG_DIAG_OFF("cast-qual")
ret_value = (void *)info->object;
H5_GCC_CLANG_DIAG_ON("cast-qual")
}
ret_value = info->u.object;

FUNC_LEAVE_NOAPI(ret_value)
} /* end H5I_object() */
Expand Down Expand Up @@ -742,12 +735,9 @@ H5I_object_verify(hid_t id, H5I_type_t type)
assert(type >= 1 && (int)type < H5I_next_type_g);

/* Verify that the type of the ID is correct & lookup the ID */
if (type == H5I_TYPE(id) && NULL != (info = H5I__find_id(id))) {
if (type == H5I_TYPE(id) && NULL != (info = H5I__find_id(id)))
/* Get the object pointer to return */
H5_GCC_CLANG_DIAG_OFF("cast-qual")
ret_value = (void *)info->object;
H5_GCC_CLANG_DIAG_ON("cast-qual")
}
ret_value = info->u.object;

FUNC_LEAVE_NOAPI(ret_value)
} /* H5I_object_verify() */
Expand Down Expand Up @@ -898,9 +888,7 @@ H5I__remove_common(H5I_type_info_t *type_info, hid_t id)
if (type_info->last_id_info == info)
type_info->last_id_info = NULL;

H5_GCC_CLANG_DIAG_OFF("cast-qual")
ret_value = (void *)info->object;
H5_GCC_CLANG_DIAG_ON("cast-qual")
ret_value = info->u.object;

if (!H5I_marking_s)
info = H5FL_FREE(H5I_id_info_t, info);
Expand Down Expand Up @@ -1000,16 +988,14 @@ H5I__dec_ref(hid_t id, void **request)
/* Get the ID's type */
type_info = H5I_type_info_array_g[H5I_TYPE(id)];

H5_GCC_CLANG_DIAG_OFF("cast-qual")
if (!type_info->cls->free_func || (type_info->cls->free_func)((void *)info->object, request) >= 0) {
if (!type_info->cls->free_func || (type_info->cls->free_func)(info->u.object, request) >= 0) {
/* Remove the node from the type */
if (NULL == H5I__remove_common(type_info, id))
HGOTO_ERROR(H5E_ID, H5E_CANTDELETE, (-1), "can't remove ID node");
ret_value = 0;
} /* end if */
else
ret_value = -1;
H5_GCC_CLANG_DIAG_ON("cast-qual")
} /* end if */
else {
--(info->count);
Expand Down Expand Up @@ -1482,9 +1468,7 @@ H5I__iterate_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata)
/* The stored object pointer might be an H5VL_object_t, in which
* case we'll need to get the wrapped object struct (H5F_t *, etc.).
*/
H5_GCC_CLANG_DIAG_OFF("cast-qual")
object = H5I__unwrap((void *)info->object, type);
H5_GCC_CLANG_DIAG_ON("cast-qual")
object = H5I__unwrap(info->u.object, type);

/* Invoke callback function */
cb_ret_val = (*udata->user_func)((void *)object, info->id, udata->user_udata);
Expand Down Expand Up @@ -1607,14 +1591,13 @@ H5I__find_id(hid_t id)
}

/* Check if this is a future ID */
H5_GCC_CLANG_DIAG_OFF("cast-qual")
if (id_info && id_info->is_future) {
hid_t actual_id = H5I_INVALID_HID; /* ID for actual object */
void *future_object; /* Pointer to the future object */
void *actual_object; /* Pointer to the actual object */

/* Invoke the realize callback, to get the actual object */
if ((id_info->realize_cb)((void *)id_info->object, &actual_id) < 0)
if ((id_info->realize_cb)(id_info->u.object, &actual_id) < 0)
HGOTO_DONE(NULL);

/* Verify that we received a valid ID, of the same type */
Expand All @@ -1624,10 +1607,10 @@ H5I__find_id(hid_t id)
HGOTO_DONE(NULL);

/* Swap the actual object in for the future object */
future_object = (void *)id_info->object;
future_object = id_info->u.object;
actual_object = H5I__remove_common(type_info, actual_id);
assert(actual_object);
id_info->object = actual_object;
id_info->u.object = actual_object;

/* Discard the future object */
if ((id_info->discard_cb)(future_object) < 0)
Expand All @@ -1639,7 +1622,6 @@ H5I__find_id(hid_t id)
id_info->realize_cb = NULL;
id_info->discard_cb = NULL;
}
H5_GCC_CLANG_DIAG_ON("cast-qual")

/* Set return value */
ret_value = id_info;
Expand Down Expand Up @@ -1674,9 +1656,7 @@ H5I__find_id_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata)
assert(udata);

/* Get a pointer to the VOL connector's data */
H5_GCC_CLANG_DIAG_OFF("cast-qual")
object = H5I__unwrap((void *)info->object, type);
H5_GCC_CLANG_DIAG_ON("cast-qual")
object = H5I__unwrap(info->u.object, type);

/* Check for a match */
if (object == udata->object) {
Expand Down
11 changes: 7 additions & 4 deletions src/H5Ipkg.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,13 @@

/* ID information structure used */
typedef struct H5I_id_info_t {
hid_t id; /* ID for this info */
unsigned count; /* Ref. count for this ID */
unsigned app_count; /* Ref. count of application visible IDs */
const void *object; /* Pointer associated with the ID */
hid_t id; /* ID for this info */
unsigned count; /* Ref. count for this ID */
unsigned app_count; /* Ref. count of application visible IDs */
union {
const void *c_object; /* Const pointer associated with the ID */
void *object; /* Pointer associated with the ID */
} u;

/* Future ID info */
bool is_future; /* Whether this ID represents a future object */
Expand Down
2 changes: 1 addition & 1 deletion src/H5Pprivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ H5_DLL herr_t H5P_insert(H5P_genplist_t *plist, const char *name, size_t size, v
H5_DLL herr_t H5P_remove(H5P_genplist_t *plist, const char *name);
H5_DLL htri_t H5P_exist_plist(const H5P_genplist_t *plist, const char *name);
H5_DLL htri_t H5P_class_isa(const H5P_genclass_t *pclass1, const H5P_genclass_t *pclass2);
H5_DLL char *H5P_get_class_name(H5P_genclass_t *pclass);
H5_DLL char *H5P_get_class_name(H5P_genclass_t *pclass) H5_ATTR_MALLOC;

/* Internal helper routines */
H5_DLL herr_t H5P_get_nprops_pclass(const H5P_genclass_t *pclass, size_t *nprops, bool recurse);
Expand Down
2 changes: 1 addition & 1 deletion src/H5Tpkg.h
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ H5_DLL herr_t H5T__enum_insert(const H5T_t *dt, const char *name, const void *va
H5_DLL herr_t H5T__get_member_value(const H5T_t *dt, unsigned membno, void *value);

/* Field functions (for both compound & enumerated types) */
H5_DLL char *H5T__get_member_name(H5T_t const *dt, unsigned membno);
H5_DLL char *H5T__get_member_name(H5T_t const *dt, unsigned membno) H5_ATTR_MALLOC;
H5_DLL herr_t H5T__sort_value(const H5T_t *dt, int *map);
H5_DLL herr_t H5T__sort_name(const H5T_t *dt, int *map);

Expand Down
Loading

0 comments on commit 67bef18

Please sign in to comment.