Skip to content
Merged
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
40 changes: 34 additions & 6 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,41 @@ StatementMacros:
- H5E_END_TRY
- H5_BEGIN_TAG
- H5_END_TAG
- H5_GCC_DIAG_OFF
- H5_GCC_DIAG_ON
- H5_CLANG_DIAG_OFF
- H5_CLANG_DIAG_ON
- H5_GCC_CLANG_DIAG_OFF
- H5_GCC_CLANG_DIAG_ON
- H5_LEAVE
- H5_WARN_C11_EXTENSIONS_OFF
- H5_WARN_C11_EXTENSIONS_ON
- H5_WARN_CAST_ALIGNMENT_OFF
- H5_WARN_CAST_ALIGNMENT_ON
- H5_WARN_CAST_AWAY_CONST_OFF
- H5_WARN_CAST_AWAY_CONST_ON
- H5_WARN_DUPLICATED_BRANCHES_OFF
- H5_WARN_DUPLICATED_BRANCHES_ON
- H5_WARN_FLOAT_CONVERSION_OFF
- H5_WARN_FLOAT_CONVERSION_ON
- H5_WARN_FLOAT_EQUAL_OFF
- H5_WARN_FLOAT_EQUAL_ON
- H5_WARN_FORMAT_NONLITERAL_OFF
- H5_WARN_FORMAT_NONLITERAL_ON
- H5_WARN_FORMAT_TRUNCATION_OFF
- H5_WARN_FORMAT_TRUNCATION_ON
- H5_WARN_IMPLICIT_FALLTHROUGH_OFF
- H5_WARN_IMPLICIT_FALLTHROUGH_ON
- H5_WARN_LARGE_STACK_OBJECTS_OFF
- H5_WARN_LARGE_STACK_OBJECTS_ON
- H5_WARN_MISSING_PROTOTPYE_OFF
- H5_WARN_MISSING_PROTOTPYE_ON
- H5_WARN_MPI_STATUSES_IGNORE_OFF
- H5_WARN_MPI_STATUSES_IGNORE_ON
- H5_WARN_NONSTD_SUFFIX_OFF
- H5_WARN_NONSTD_SUFFIX_ON
- H5_WARN_OBJ_FXN_POINTER_CONVERSION_OFF
- H5_WARN_OBJ_FXN_POINTER_CONVERSION_ON
- H5_WARN_SIGN_CONVERSION_OFF
- H5_WARN_SIGN_CONVERSION_ON
- H5_WARN_UNUSED_PARAMETER_OFF
- H5_WARN_UNUSED_PARAMETER_ON
- H5_WARN_USELESS_COMPARISON_OFF
- H5_WARN_USELESS_COMPARISON_ON
- HGOTO_DONE
- HMPI_DONE_ERROR
- HMPI_ERROR
Expand Down
24 changes: 20 additions & 4 deletions c++/test/tcompound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ test_compound_2()
bkg = static_cast<unsigned char *>(malloc(nelmts * sizeof(dst_typ_t)));
orig = static_cast<unsigned char *>(malloc(nelmts * sizeof(src_typ_t)));
for (i = 0; i < nelmts; i++) {
s_ptr = (reinterpret_cast<src_typ_t *>(orig)) + i;
H5_WARN_CAST_ALIGNMENT_OFF
s_ptr = (reinterpret_cast<src_typ_t *>(orig)) + i;
Copy link
Collaborator

Choose a reason for hiding this comment

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

If these few places are the only locations where cast-align is currently suppressed, I'd much rather these be fixed (maybe in a separate PR) than continuing to be suppressed. The solution is very simple so no real need to keep suppressing cast-align.

H5_WARN_CAST_ALIGNMENT_ON
s_ptr->a = i * 8 + 0;
s_ptr->b = i * 8 + 1;
s_ptr->c[0] = i * 8 + 2;
Expand Down Expand Up @@ -139,8 +141,10 @@ test_compound_2()

// Compare results
for (i = 0; i < nelmts; i++) {
H5_WARN_CAST_ALIGNMENT_OFF
s_ptr = (reinterpret_cast<src_typ_t *>(orig)) + i;
d_ptr = (reinterpret_cast<dst_typ_t *>(buf)) + i;
H5_WARN_CAST_ALIGNMENT_ON
if (s_ptr->a != d_ptr->a || s_ptr->b != d_ptr->b || s_ptr->c[0] != d_ptr->c[0] ||
s_ptr->c[1] != d_ptr->c[1] || s_ptr->c[2] != d_ptr->c[2] || s_ptr->c[3] != d_ptr->c[3] ||
s_ptr->d != d_ptr->d || s_ptr->e != d_ptr->e) {
Expand Down Expand Up @@ -208,7 +212,9 @@ test_compound_3()
bkg = static_cast<unsigned char *>(malloc(nelmts * sizeof(dst_typ_t)));
orig = static_cast<unsigned char *>(malloc(nelmts * sizeof(src_typ_t)));
for (i = 0; i < nelmts; i++) {
s_ptr = (reinterpret_cast<src_typ_t *>(orig)) + i;
H5_WARN_CAST_ALIGNMENT_OFF
s_ptr = (reinterpret_cast<src_typ_t *>(orig)) + i;
H5_WARN_CAST_ALIGNMENT_ON
s_ptr->a = i * 8 + 0;
s_ptr->b = i * 8 + 1;
s_ptr->c[0] = i * 8 + 2;
Expand Down Expand Up @@ -247,8 +253,10 @@ test_compound_3()

/* Compare results */
for (i = 0; i < nelmts; i++) {
H5_WARN_CAST_ALIGNMENT_OFF
s_ptr = (reinterpret_cast<src_typ_t *>(orig)) + i;
d_ptr = (reinterpret_cast<dst_typ_t *>(buf)) + i;
H5_WARN_CAST_ALIGNMENT_ON
if (s_ptr->a != d_ptr->a || s_ptr->c[0] != d_ptr->c[0] || s_ptr->c[1] != d_ptr->c[1] ||
s_ptr->c[2] != d_ptr->c[2] || s_ptr->c[3] != d_ptr->c[3] || s_ptr->e != d_ptr->e) {
H5_FAILED();
Expand Down Expand Up @@ -320,7 +328,9 @@ test_compound_4()
bkg = static_cast<unsigned char *>(malloc(nelmts * sizeof(dst_typ_t)));
orig = static_cast<unsigned char *>(malloc(nelmts * sizeof(src_typ_t)));
for (i = 0; i < nelmts; i++) {
s_ptr = (reinterpret_cast<src_typ_t *>(orig)) + i;
H5_WARN_CAST_ALIGNMENT_OFF
s_ptr = (reinterpret_cast<src_typ_t *>(orig)) + i;
H5_WARN_CAST_ALIGNMENT_ON
s_ptr->a = i * 8 + 0;
s_ptr->b = (i * 8 + 1) & 0x7fff;
s_ptr->c[0] = i * 8 + 2;
Expand Down Expand Up @@ -361,8 +371,10 @@ test_compound_4()

/* Compare results */
for (i = 0; i < nelmts; i++) {
H5_WARN_CAST_ALIGNMENT_OFF
s_ptr = (reinterpret_cast<src_typ_t *>(orig)) + i;
d_ptr = (reinterpret_cast<dst_typ_t *>(buf)) + i;
H5_WARN_CAST_ALIGNMENT_ON
if (s_ptr->a != d_ptr->a || s_ptr->b != d_ptr->b || s_ptr->c[0] != d_ptr->c[0] ||
s_ptr->c[1] != d_ptr->c[1] || s_ptr->c[2] != d_ptr->c[2] || s_ptr->c[3] != d_ptr->c[3] ||
s_ptr->d != d_ptr->d || s_ptr->e != d_ptr->e) {
Expand Down Expand Up @@ -525,7 +537,9 @@ test_compound_6()
bkg = static_cast<unsigned char *>(malloc(nelmts * sizeof(dst_typ_t)));
orig = static_cast<unsigned char *>(malloc(nelmts * sizeof(src_typ_t)));
for (i = 0; i < nelmts; i++) {
s_ptr = (reinterpret_cast<src_typ_t *>(orig)) + i;
H5_WARN_CAST_ALIGNMENT_OFF
s_ptr = (reinterpret_cast<src_typ_t *>(orig)) + i;
H5_WARN_CAST_ALIGNMENT_ON
s_ptr->b = (i * 8 + 1) & 0x7fff;
s_ptr->d = (i * 8 + 6) & 0x7fff;
}
Expand All @@ -545,8 +559,10 @@ test_compound_6()

/* Compare results */
for (i = 0; i < nelmts; i++) {
H5_WARN_CAST_ALIGNMENT_OFF
s_ptr = (reinterpret_cast<src_typ_t *>(orig)) + i;
d_ptr = (reinterpret_cast<dst_typ_t *>(buf)) + i;
H5_WARN_CAST_ALIGNMENT_ON
if (s_ptr->b != d_ptr->b || s_ptr->d != d_ptr->d) {
H5_FAILED();
cerr << " i=" << i << endl;
Expand Down
1 change: 1 addition & 0 deletions config/clang-warnings/general
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
-Wdouble-promotion
-Wextra
-Wformat=2
-Wformat-nonliteral
-Wframe-larger-than=16384
-Wimplicit-fallthrough
-Wnull-dereference
Expand Down
1 change: 0 additions & 1 deletion config/gnu-warnings/5
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
-Warray-bounds=2
-Wc99-c11-compat
1 change: 1 addition & 0 deletions config/gnu-warnings/general
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
-Wextra
-Wfloat-equal
-Wformat=2
-Wformat-nonliteral
-Winit-self
-Winvalid-pch
-Wmissing-include-dirs
Expand Down
8 changes: 4 additions & 4 deletions hl/fortran/src/H5TBfc.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ h5tbmake_table_c(size_t_f *namelen1, _fcd name1, hid_t_f *loc_id, size_t_f *name
/*
* call H5TBmake_table function.
*/
H5_GCC_CLANG_DIAG_OFF("cast-qual")
H5_WARN_CAST_AWAY_CONST_OFF
if (H5TBmake_table(c_name1, (hid_t)*loc_id, c_name, c_nfields, (hsize_t)*nrecords, (size_t)*type_size,
(const char **)c_field_names, c_field_offset, c_field_types, (hsize_t)*chunk_size,
NULL, *compress, NULL) < 0)
HGOTO_DONE(FAIL);
H5_GCC_CLANG_DIAG_ON("cast-qual")
H5_WARN_CAST_AWAY_CONST_ON

done:
if (c_name)
Expand Down Expand Up @@ -195,12 +195,12 @@ h5tbmake_table_ptr_c(size_t_f *namelen1, _fcd name1, hid_t_f *loc_id, size_t_f *
/*
* call H5TBmake_table function.
*/
H5_GCC_CLANG_DIAG_OFF("cast-qual")
H5_WARN_CAST_AWAY_CONST_OFF
if (H5TBmake_table(c_name1, (hid_t)*loc_id, c_name, c_nfields, (hsize_t)*nrecords, (size_t)*type_size,
(const char **)c_field_names, c_field_offset, c_field_types, (hsize_t)*chunk_size,
fill_data, *compress, data) < 0)
HGOTO_DONE(FAIL);
H5_GCC_CLANG_DIAG_ON("cast-qual")
H5_WARN_CAST_AWAY_CONST_ON

done:
if (c_name)
Expand Down
4 changes: 2 additions & 2 deletions hl/src/H5LT.c
Original file line number Diff line number Diff line change
Expand Up @@ -1256,13 +1256,13 @@ find_dataset(H5_ATTR_UNUSED hid_t loc_id, const char *name, H5_ATTR_UNUSED const
* modify the op_data buffer (i.e.: dset_name) during the traversal, and the
* library never modifies that buffer.
*/
H5_GCC_CLANG_DIAG_OFF("cast-qual")
H5_WARN_CAST_AWAY_CONST_OFF
herr_t
H5LTfind_dataset(hid_t loc_id, const char *dset_name)
{
return H5Literate2(loc_id, H5_INDEX_NAME, H5_ITER_INC, 0, find_dataset, (void *)dset_name);
}
H5_GCC_CLANG_DIAG_ON("cast-qual")
H5_WARN_CAST_AWAY_CONST_ON

/*-------------------------------------------------------------------------
*
Expand Down
16 changes: 8 additions & 8 deletions java/src/jni/h5Constants.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ extern "C" {
#include <stdlib.h>
#include "h5jni.h"

H5_GCC_CLANG_DIAG_OFF("missing-prototypes")
H5_GCC_CLANG_DIAG_OFF("unused-parameter")
H5_WARN_MISSING_PROTOTYPE_OFF
H5_WARN_UNUSED_PARAMETER_OFF

JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_HDF5Constants_H5_1QUARTER_1HADDR_1MAX(JNIEnv *env, jclass cls)
Expand Down Expand Up @@ -1210,7 +1210,7 @@ Java_hdf_hdf5lib_HDF5Constants_H5ES_1STATUS_1CANCELED(JNIEnv *env, jclass cls)
}

/* Java does not have unsigned native types */
H5_GCC_CLANG_DIAG_OFF("sign-conversion")
H5_WARN_SIGN_CONVERSION_OFF
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_HDF5Constants_H5F_1ACC_1CREAT(JNIEnv *env, jclass cls)
{
Expand Down Expand Up @@ -1251,7 +1251,7 @@ Java_hdf_hdf5lib_HDF5Constants_H5F_1ACC_1SWMR_1WRITE(JNIEnv *env, jclass cls)
{
return H5F_ACC_SWMR_WRITE;
}
H5_GCC_CLANG_DIAG_ON("sign-conversion")
H5_WARN_SIGN_CONVERSION_ON

JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_HDF5Constants_H5F_1CLOSE_1DEFAULT(JNIEnv *env, jclass cls)
Expand Down Expand Up @@ -1652,7 +1652,7 @@ Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1DEFAULT_1GHEAP_1SIZE(JNIEnv *env, jcla
{
return (hsize_t)(3 * (HADDR_MAX / (H5FD_MEM_NTYPES - 1)));
}
H5_GCC_CLANG_DIAG_OFF("sign-conversion")
H5_WARN_SIGN_CONVERSION_OFF
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1DEFAULT_1LHEAP_1SIZE(JNIEnv *env, jclass cls)
{
Expand All @@ -1669,7 +1669,7 @@ Java_hdf_hdf5lib_HDF5Constants_H5FD_1MEM_1DEFAULT_1OHDR_1SIZE(JNIEnv *env, jclas
/* XXX: BADNESS! - This value cannot fit into a jlong! */
return (hsize_t)(5 * (HADDR_MAX / (H5FD_MEM_NTYPES - 1)));
}
H5_GCC_CLANG_DIAG_ON("sign-conversion")
H5_WARN_SIGN_CONVERSION_ON

/* Symbols defined for compatibility with previous versions of the HDF5 API.
*
Expand Down Expand Up @@ -3800,8 +3800,8 @@ Java_hdf_hdf5lib_HDF5Constants_H5Z_1FILTER_1ALL(JNIEnv *env, jclass cls)
return H5Z_FILTER_ALL;
}

H5_GCC_CLANG_DIAG_ON("missing-prototypes")
H5_GCC_CLANG_DIAG_ON("unused-parameter")
H5_WARN_UNUSED_PARAMETER_ON
H5_WARN_MISSING_PROTOTYPE_ON

#ifdef __cplusplus
} /* end extern "C" */
Expand Down
5 changes: 2 additions & 3 deletions src/H5Dint.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,10 @@ H5FL_EXTERN(H5D_piece_info_t);
/* Declare extern the free list to manage blocks of type conversion data */
H5FL_BLK_EXTERN(type_conv);

/* Disable warning for intentional identical branches here -QAK */
H5_GCC_DIAG_OFF("larger-than=")
/* Define a static "default" dataset structure to use to initialize new datasets */
H5_WARN_LARGE_STACK_OBJECTS_OFF
static H5D_shared_t H5D_def_dset;
H5_GCC_DIAG_ON("larger-than=")
H5_WARN_LARGE_STACK_OBJECTS_ON

/* Dataset ID class */
static const H5I_class_t H5I_DATASET_CLS[1] = {{
Expand Down
21 changes: 5 additions & 16 deletions src/H5Dmpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -4342,18 +4342,12 @@ H5D__mpio_share_chunk_modification_data(H5D_filtered_collective_io_info_t *chunk
else {
int all_sends_completed;

/* Determine if all send requests have completed
*
* gcc 11 complains about passing MPI_STATUSES_IGNORE as an MPI_Status
* array. See the discussion here:
*
* https://github.com/pmodels/mpich/issues/5687
*/
H5_GCC_DIAG_OFF("stringop-overflow")
/* Determine if all send requests have completed */
H5_WARN_MPI_STATUSES_IGNORE_OFF
if (MPI_SUCCESS != (mpi_code = MPI_Testall((int)num_send_requests, send_requests,
&all_sends_completed, MPI_STATUSES_IGNORE)))
HMPI_GOTO_ERROR(FAIL, "MPI_Testall failed", mpi_code)
H5_GCC_DIAG_ON("stringop-overflow")
H5_WARN_MPI_STATUSES_IGNORE_ON

if (all_sends_completed) {
/* Post non-blocking barrier */
Expand Down Expand Up @@ -4387,16 +4381,11 @@ H5D__mpio_share_chunk_modification_data(H5D_filtered_collective_io_info_t *chunk
* in the order that chunks are processed. So, the safest way to
* support both I/O modes is to simply make sure all messages
* are available.
*
* gcc 11 complains about passing MPI_STATUSES_IGNORE as an MPI_Status
* array. See the discussion here:
*
* https://github.com/pmodels/mpich/issues/5687
*/
H5_GCC_DIAG_OFF("stringop-overflow")
H5_WARN_MPI_STATUSES_IGNORE_OFF
if (MPI_SUCCESS != (mpi_code = MPI_Waitall((int)num_recv_requests, recv_requests, MPI_STATUSES_IGNORE)))
HMPI_GOTO_ERROR(FAIL, "MPI_Waitall failed", mpi_code)
H5_GCC_DIAG_ON("stringop-overflow")
H5_WARN_MPI_STATUSES_IGNORE_ON

/* Set the new number of locally-selected chunks */
chunk_list->num_chunk_infos = last_assigned_idx;
Expand Down
9 changes: 2 additions & 7 deletions src/H5Eint.c
Original file line number Diff line number Diff line change
Expand Up @@ -1740,15 +1740,10 @@ H5E__set_stack_entry(H5E_error2_t *err_entry, const char *file, const char *func
if (ap) {
char *desc = NULL;

/* GCC complains about the 'fmt' parameter, but it's either from static
* strings in the library, which we know are OK, or from application
* error push calls, and the application should be sanity checking their
* strings.
*/
H5_GCC_CLANG_DIAG_OFF("format-nonliteral")
H5_WARN_FORMAT_NONLITERAL_OFF
if (HDvasprintf(&desc, fmt, *ap) < 0)
HGOTO_DONE(FAIL);
H5_GCC_CLANG_DIAG_ON("format-nonliteral")
H5_WARN_FORMAT_NONLITERAL_ON

err_entry->desc = desc;
}
Expand Down
Loading
Loading