From c29e1b9fdfcba9ca276600b1bad4ec2cf17bb01e Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Thu, 25 Feb 2021 13:15:02 -0500 Subject: Patches from vtk (#358) * Drop the export attribute on forward declaration They don't mean anything on forward declarations anyways. * Fixed -Wunused-parameter warnings in some C++ files Allowed all the attribute #defines to work in C++ also. * Fixed -Wunused-variable warnings by removing dead code * Fixed all -Wshorten-64-to-32 warnings by adjusting casts There was no truncation in fact, since the unsigned result was upcast to size_t then implicitly downcast to uint32_t. * Fixed all -Wcomma warnings by spliting statements onto own lines * Fixed all -Wself-assign warnings with different unused param suppression * Fixed all -Wextra-semi warnings * Fixed all -Wswitch-enum warnings Just added new explicit cases with the existing default case. * Fixed all -Wmissing-prototypes warnings Just made functions static. Moved them into an extern "C" block. * Reformatted source with bin/format_source using clang version 10.0.1 Co-authored-by: Larry Knox --- c++/src/H5Attribute.cpp | 2 +- c++/src/H5Location.cpp | 2 ++ c++/src/H5Object.cpp | 14 ++++++++++---- c++/src/H5PredType.cpp | 3 ++- c++/src/H5PropList.cpp | 3 +++ c++/src/H5StrType.cpp | 3 ++- hl/c++/src/H5PacketTable.h | 2 +- hl/src/H5IM.c | 8 ++------ hl/src/H5LT.c | 14 ++++---------- hl/tools/gif2h5/hdfgifwr.c | 12 ++++++------ src/H5Cimage.c | 3 ++- src/H5FDmulti.c | 2 +- src/H5FDstdio.c | 32 ++++++++++++++++---------------- src/H5HFhuge.c | 28 ++++++++++++++-------------- src/H5VLpassthru.c | 2 +- src/H5private.h | 14 -------------- test/stab.c | 2 +- test/tattr.c | 4 ++-- tools/lib/h5diff_array.c | 4 +--- tools/lib/h5tools_utils.c | 2 -- 20 files changed, 71 insertions(+), 85 deletions(-) diff --git a/c++/src/H5Attribute.cpp b/c++/src/H5Attribute.cpp index 08367c5..81e656f 100644 --- a/c++/src/H5Attribute.cpp +++ b/c++/src/H5Attribute.cpp @@ -41,7 +41,7 @@ namespace H5 { using std::cerr; using std::endl; -class H5_DLLCPP H5Object; // forward declaration for UserData4Aiterate +class H5Object; // forward declaration for UserData4Aiterate //-------------------------------------------------------------------------- // Function: Attribute default constructor diff --git a/c++/src/H5Location.cpp b/c++/src/H5Location.cpp index 832efea..2d14bfc 100644 --- a/c++/src/H5Location.cpp +++ b/c++/src/H5Location.cpp @@ -2153,6 +2153,7 @@ H5Location::childObjType(const char *objname) const break; case H5O_TYPE_UNKNOWN: case H5O_TYPE_NTYPES: + case H5O_TYPE_MAP: default: throwException("childObjType", "Unknown type of object"); } @@ -2231,6 +2232,7 @@ H5Location::childObjType(hsize_t index, H5_index_t index_type, H5_iter_order_t o break; case H5O_TYPE_UNKNOWN: case H5O_TYPE_NTYPES: + case H5O_TYPE_MAP: default: throwException("childObjType", "Unknown type of object"); } diff --git a/c++/src/H5Object.cpp b/c++/src/H5Object.cpp index 669bffc..725d1da 100644 --- a/c++/src/H5Object.cpp +++ b/c++/src/H5Object.cpp @@ -42,8 +42,11 @@ namespace H5 { #ifndef DOXYGEN_SHOULD_SKIP_THIS // userAttrOpWrpr interfaces between the user's function and the // C library function H5Aiterate2 -extern "C" herr_t -userAttrOpWrpr(hid_t loc_id, const char *attr_name, const H5A_info_t *ainfo, void *op_data) +extern "C" { + +static herr_t +userAttrOpWrpr(H5_ATTR_UNUSED hid_t loc_id, const char *attr_name, H5_ATTR_UNUSED const H5A_info_t *ainfo, + void *op_data) { H5std_string s_attr_name = H5std_string(attr_name); UserData4Aiterate *myData = reinterpret_cast(op_data); @@ -53,8 +56,9 @@ userAttrOpWrpr(hid_t loc_id, const char *attr_name, const H5A_info_t *ainfo, voi // userVisitOpWrpr interfaces between the user's function and the // C library function H5Ovisit3 -extern "C" herr_t -userVisitOpWrpr(hid_t obj_id, const char *attr_name, const H5O_info2_t *obj_info, void *op_data) +static herr_t +userVisitOpWrpr(H5_ATTR_UNUSED hid_t obj_id, const char *attr_name, const H5O_info2_t *obj_info, + void *op_data) { H5std_string s_attr_name = H5std_string(attr_name); UserData4Visit *myData = reinterpret_cast(op_data); @@ -62,6 +66,8 @@ userVisitOpWrpr(hid_t obj_id, const char *attr_name, const H5O_info2_t *obj_info return status; } +} // extern "C" + //-------------------------------------------------------------------------- // Function: H5Object default constructor (protected) // Programmer Binh-Minh Ribler - 2000 diff --git a/c++/src/H5PredType.cpp b/c++/src/H5PredType.cpp index dd70353..b58569f 100644 --- a/c++/src/H5PredType.cpp +++ b/c++/src/H5PredType.cpp @@ -27,6 +27,7 @@ #include "H5DataType.h" #include "H5AtomType.h" #include "H5PredType.h" +#include "H5private.h" namespace H5 { @@ -82,7 +83,7 @@ PredType::operator=(const PredType &rhs) // These dummy functions do not inherit from DataType - they'll // throw an DataTypeIException if invoked. void -PredType::commit(H5Location &loc, const char *name) +PredType::commit(H5_ATTR_UNUSED H5Location &loc, H5_ATTR_UNUSED const char *name) { throw DataTypeIException("PredType::commit", "Error: Attempted to commit a predefined datatype. Invalid operation!"); diff --git a/c++/src/H5PropList.cpp b/c++/src/H5PropList.cpp index 3f9a28e..3780220 100644 --- a/c++/src/H5PropList.cpp +++ b/c++/src/H5PropList.cpp @@ -155,6 +155,9 @@ PropList::PropList(const hid_t plist_id) : IdComponent() case H5I_ERROR_STACK: case H5I_NTYPES: case H5I_UNINIT: + case H5I_MAP: + case H5I_SPACE_SEL_ITER: + case H5I_EVENTSET: default: id = H5P_DEFAULT; break; diff --git a/c++/src/H5StrType.cpp b/c++/src/H5StrType.cpp index 7bbe3ab..473cab3 100644 --- a/c++/src/H5StrType.cpp +++ b/c++/src/H5StrType.cpp @@ -32,6 +32,7 @@ #include "H5StrType.h" #include "H5DataSet.h" #include "H5PredType.h" +#include "H5private.h" namespace H5 { @@ -102,7 +103,7 @@ StrType::StrType(const PredType &pred_type, const size_t &size) : AtomType() // This constructor replaced the previous one. // Programmer Binh-Minh Ribler - Nov 28, 2005 //-------------------------------------------------------------------------- -StrType::StrType(const int dummy, const size_t &size) : AtomType() +StrType::StrType(H5_ATTR_UNUSED const int dummy, const size_t &size) : AtomType() { // use DataType::copy to make a copy of the string predefined type // then set its length diff --git a/hl/c++/src/H5PacketTable.h b/hl/c++/src/H5PacketTable.h index 735901f..825caf7 100644 --- a/hl/c++/src/H5PacketTable.h +++ b/hl/c++/src/H5PacketTable.h @@ -163,7 +163,7 @@ class H5_HLCPPDLL FL_PacketTable : virtual public PacketTable { /* Destructor * Cleans up the packet table */ - virtual ~FL_PacketTable(){}; + virtual ~FL_PacketTable() {} /* AppendPacket * Adds a single packet to the packet table. Takes a pointer diff --git a/hl/src/H5IM.c b/hl/src/H5IM.c index 64cb535..310d665 100644 --- a/hl/src/H5IM.c +++ b/hl/src/H5IM.c @@ -160,7 +160,8 @@ H5IMmake_image_24bit(hid_t loc_id, const char *dset_name, hsize_t width, hsize_t *------------------------------------------------------------------------- */ static herr_t -find_palette(hid_t loc_id, const char *name, const H5A_info_t *ainfo, void *op_data) +find_palette(H5_ATTR_UNUSED hid_t loc_id, const char *name, H5_ATTR_UNUSED const H5A_info_t *ainfo, + H5_ATTR_UNUSED void *op_data) { int ret = H5_ITER_CONT; @@ -168,11 +169,6 @@ find_palette(hid_t loc_id, const char *name, const H5A_info_t *ainfo, void *op_d if (name == NULL) return -1; - /* Shut compiler up */ - loc_id = loc_id; - ainfo = ainfo; - op_data = op_data; - /* Define a positive value for return value if the attribute was found. This will * cause the iterator to immediately return that positive value, * indicating short-circuit success diff --git a/hl/src/H5LT.c b/hl/src/H5LT.c index 267e38e..6478a96 100644 --- a/hl/src/H5LT.c +++ b/hl/src/H5LT.c @@ -1297,7 +1297,8 @@ out: */ static herr_t -find_dataset(hid_t loc_id, const char *name, const H5L_info2_t *linfo, void *op_data) +find_dataset(H5_ATTR_UNUSED hid_t loc_id, const char *name, H5_ATTR_UNUSED const H5L_info2_t *linfo, + void *op_data) { /* Define a default zero value for return. This will cause the iterator to continue if * the dataset is not found yet. @@ -1308,10 +1309,6 @@ find_dataset(hid_t loc_id, const char *name, const H5L_info2_t *linfo, void *op_ if (name == NULL) return ret; - /* Shut the compiler up */ - loc_id = loc_id; - linfo = linfo; - /* Define a positive value for return value if the dataset was found. This will * cause the iterator to immediately return that positive value, * indicating short-circuit success @@ -1841,7 +1838,8 @@ H5LTset_attribute_double(hid_t loc_id, const char *obj_name, const char *attr_na *------------------------------------------------------------------------- */ static herr_t -find_attr(hid_t loc_id, const char *name, const H5A_info_t *ainfo, void *op_data) +find_attr(H5_ATTR_UNUSED hid_t loc_id, const char *name, H5_ATTR_UNUSED const H5A_info_t *ainfo, + void *op_data) { int ret = H5_ITER_CONT; @@ -1849,10 +1847,6 @@ find_attr(hid_t loc_id, const char *name, const H5A_info_t *ainfo, void *op_data if (name == NULL) return H5_ITER_CONT; - /* Shut compiler up */ - loc_id = loc_id; - ainfo = ainfo; - /* Define a positive value for return value if the attribute was found. This will * cause the iterator to immediately return that positive value, * indicating short-circuit success diff --git a/hl/tools/gif2h5/hdfgifwr.c b/hl/tools/gif2h5/hdfgifwr.c index 333c808..8068829 100644 --- a/hl/tools/gif2h5/hdfgifwr.c +++ b/hl/tools/gif2h5/hdfgifwr.c @@ -152,12 +152,12 @@ hdfWriteGIF(FILE *fp, byte *pic, int ptype, int w, int h, byte *rmap, byte *gmap } /* Shut compiler up... */ - ptype = ptype; - rmap = rmap; - gmap = gmap; - bmap = bmap; - numcols = numcols; - colorstyle = colorstyle; + (void)ptype; + (void)rmap; + (void)gmap; + (void)bmap; + (void)numcols; + (void)colorstyle; for (i = 0; i < 256; i++) { pc2nc[i] = pc2ncmap[i]; diff --git a/src/H5Cimage.c b/src/H5Cimage.c index b49f192..b366a94 100644 --- a/src/H5Cimage.c +++ b/src/H5Cimage.c @@ -1158,7 +1158,8 @@ H5C_load_cache_image_on_next_protect(H5F_t *f, haddr_t addr, hsize_t len, hbool_ HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); /* Set information needed to load cache image */ - cache_ptr->image_addr = addr, cache_ptr->image_len = len; + cache_ptr->image_addr = addr; + cache_ptr->image_len = len; cache_ptr->load_image = TRUE; cache_ptr->delete_image = rw; diff --git a/src/H5FDmulti.c b/src/H5FDmulti.c index b61b193..e468554 100644 --- a/src/H5FDmulti.c +++ b/src/H5FDmulti.c @@ -1195,7 +1195,7 @@ static herr_t H5FD_multi_query(const H5FD_t *_f, unsigned long *flags /* out */) { /* Shut compiler up */ - _f = _f; + (void)_f; /* Set the VFL feature flags that this driver supports */ if (flags) { diff --git a/src/H5FDstdio.c b/src/H5FDstdio.c index b9d018a..efc1802 100644 --- a/src/H5FDstdio.c +++ b/src/H5FDstdio.c @@ -346,7 +346,7 @@ H5FD_stdio_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr assert(sizeof(file_offset_t) >= sizeof(size_t)); /* Quiet compiler */ - fapl_id = fapl_id; + (void)fapl_id; /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); @@ -587,7 +587,7 @@ static herr_t H5FD_stdio_query(const H5FD_t *_f, unsigned long /*OUT*/ *flags) { /* Quiet the compiler */ - _f = _f; + (void)_f; /* Set the VFL feature flags that this driver supports. * @@ -632,8 +632,8 @@ H5FD_stdio_alloc(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxp haddr_t addr; /* Quiet compiler */ - type = type; - dxpl_id = dxpl_id; + (void)type; + (void)dxpl_id; /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); @@ -671,7 +671,7 @@ H5FD_stdio_get_eoa(const H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type) H5Eclear2(H5E_DEFAULT); /* Quiet compiler */ - type = type; + (void)type; return file->eoa; } /* end H5FD_stdio_get_eoa() */ @@ -701,7 +701,7 @@ H5FD_stdio_set_eoa(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, haddr_t addr) H5Eclear2(H5E_DEFAULT); /* Quiet the compiler */ - type = type; + (void)type; file->eoa = addr; @@ -732,13 +732,13 @@ H5FD_stdio_get_eof(const H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type) const H5FD_stdio_t *file = (const H5FD_stdio_t *)_file; /* Quiet the compiler */ - type = type; + (void)type; /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); /* Quiet the compiler */ - type = type; + (void)type; return (file->eof); } /* end H5FD_stdio_get_eof() */ @@ -762,7 +762,7 @@ H5FD_stdio_get_handle(H5FD_t *_file, hid_t /*UNUSED*/ fapl, void **file_handle) static const char *func = "H5FD_stdio_get_handle"; /* Function Name for error reporting */ /* Quiet the compiler */ - fapl = fapl; + (void)fapl; /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); @@ -800,8 +800,8 @@ H5FD_stdio_read(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxpl static const char *func = "H5FD_stdio_read"; /* Function Name for error reporting */ /* Quiet the compiler */ - type = type; - dxpl_id = dxpl_id; + (void)type; + (void)dxpl_id; /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); @@ -902,8 +902,8 @@ H5FD_stdio_write(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxp static const char *func = "H5FD_stdio_write"; /* Function Name for error reporting */ /* Quiet the compiler */ - dxpl_id = dxpl_id; - type = type; + (void)dxpl_id; + (void)type; /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); @@ -990,7 +990,7 @@ H5FD_stdio_flush(H5FD_t *_file, hid_t /*UNUSED*/ dxpl_id, hbool_t closing) static const char *func = "H5FD_stdio_flush"; /* Function Name for error reporting */ /* Quiet the compiler */ - dxpl_id = dxpl_id; + (void)dxpl_id; /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); @@ -1034,8 +1034,8 @@ H5FD_stdio_truncate(H5FD_t *_file, hid_t /*UNUSED*/ dxpl_id, hbool_t /*UNUSED*/ static const char *func = "H5FD_stdio_truncate"; /* Function Name for error reporting */ /* Quiet the compiler */ - dxpl_id = dxpl_id; - closing = closing; + (void)dxpl_id; + (void)closing; /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); diff --git a/src/H5HFhuge.c b/src/H5HFhuge.c index 1e1b066..83a61ec 100644 --- a/src/H5HFhuge.c +++ b/src/H5HFhuge.c @@ -113,32 +113,32 @@ H5HF__huge_bt2_create(H5HF_hdr_t *hdr) if (hdr->huge_ids_direct) { if (hdr->filter_len > 0) { bt2_cparam.rrec_size = - (size_t)((unsigned)hdr->sizeof_addr /* Address of object */ - + (unsigned)hdr->sizeof_size /* Length of object */ - + (unsigned)4 /* Filter mask for filtered object */ - + (unsigned)hdr->sizeof_size); /* Size of de-filtered object in memory */ + (uint32_t)((unsigned)hdr->sizeof_addr /* Address of object */ + + (unsigned)hdr->sizeof_size /* Length of object */ + + (unsigned)4 /* Filter mask for filtered object */ + + (unsigned)hdr->sizeof_size); /* Size of de-filtered object in memory */ bt2_cparam.cls = H5HF_HUGE_BT2_FILT_DIR; } /* end if */ else { - bt2_cparam.rrec_size = (size_t)((unsigned)hdr->sizeof_addr /* Address of object */ - + (unsigned)hdr->sizeof_size); /* Length of object */ + bt2_cparam.rrec_size = (uint32_t)((unsigned)hdr->sizeof_addr /* Address of object */ + + (unsigned)hdr->sizeof_size); /* Length of object */ bt2_cparam.cls = H5HF_HUGE_BT2_DIR; } /* end else */ } /* end if */ else { if (hdr->filter_len > 0) { bt2_cparam.rrec_size = - (size_t)((unsigned)hdr->sizeof_addr /* Address of filtered object */ - + (unsigned)hdr->sizeof_size /* Length of filtered object */ - + (unsigned)4 /* Filter mask for filtered object */ - + (unsigned)hdr->sizeof_size /* Size of de-filtered object in memory */ - + (unsigned)hdr->sizeof_size); /* Unique ID for object */ + (uint32_t)((unsigned)hdr->sizeof_addr /* Address of filtered object */ + + (unsigned)hdr->sizeof_size /* Length of filtered object */ + + (unsigned)4 /* Filter mask for filtered object */ + + (unsigned)hdr->sizeof_size /* Size of de-filtered object in memory */ + + (unsigned)hdr->sizeof_size); /* Unique ID for object */ bt2_cparam.cls = H5HF_HUGE_BT2_FILT_INDIR; } /* end if */ else { - bt2_cparam.rrec_size = (size_t)((unsigned)hdr->sizeof_addr /* Address of object */ - + (unsigned)hdr->sizeof_size /* Length of object */ - + (unsigned)hdr->sizeof_size); /* Unique ID for object */ + bt2_cparam.rrec_size = (uint32_t)((unsigned)hdr->sizeof_addr /* Address of object */ + + (unsigned)hdr->sizeof_size /* Length of object */ + + (unsigned)hdr->sizeof_size); /* Unique ID for object */ bt2_cparam.cls = H5HF_HUGE_BT2_INDIR; } /* end else */ } /* end else */ diff --git a/src/H5VLpassthru.c b/src/H5VLpassthru.c index d73f7c5..5ccc082 100644 --- a/src/H5VLpassthru.c +++ b/src/H5VLpassthru.c @@ -488,7 +488,7 @@ H5VL_pass_through_init(hid_t vipl_id) #endif /* Shut compiler up about unused parameter */ - vipl_id = vipl_id; + (void)vipl_id; return 0; } /* end H5VL_pass_through_init() */ diff --git a/src/H5private.h b/src/H5private.h index e850523..741214f 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -306,19 +306,6 @@ * gcc warnings (it has to use the public API and can't include this * file). Be sure to update that file if the #ifdefs change here. */ -#ifdef __cplusplus -#define H5_ATTR_FORMAT(X, Y, Z) /*void*/ -#define H5_ATTR_UNUSED /*void*/ -#define H5_ATTR_DEPRECATED_USED /*void*/ -#define H5_ATTR_NDEBUG_UNUSED /*void*/ -#define H5_ATTR_DEBUG_API_USED /*void*/ -#define H5_ATTR_PARALLEL_UNUSED /*void*/ -#define H5_ATTR_PARALLEL_USED /*void*/ -#define H5_ATTR_NORETURN /*void*/ -#define H5_ATTR_CONST /*void*/ -#define H5_ATTR_PURE /*void*/ -#define H5_ATTR_FALLTHROUGH /*void*/ -#else /* __cplusplus */ #if defined(H5_HAVE_ATTRIBUTE) && !defined(__SUNPRO_C) #define H5_ATTR_FORMAT(X, Y, Z) __attribute__((format(X, Y, Z))) #define H5_ATTR_UNUSED __attribute__((unused)) @@ -365,7 +352,6 @@ #define H5_ATTR_PURE /*void*/ #define H5_ATTR_FALLTHROUGH /*void*/ #endif -#endif /* __cplusplus */ /* * Networking headers used by the mirror VFD and related tests and utilities. diff --git a/test/stab.c b/test/stab.c index d99391b..c40b518 100644 --- a/test/stab.c +++ b/test/stab.c @@ -1273,7 +1273,7 @@ old_api(hid_t fapl) PASSED(); #else /* H5_NO_DEPRECATED_SYMBOLS */ /* Shut compiler up */ - fapl = fapl; + (void)fapl; SKIPPED(); HDputs(" Deprecated API symbols not enabled"); diff --git a/test/tattr.c b/test/tattr.c index aeea268..2b7a03b 100644 --- a/test/tattr.c +++ b/test/tattr.c @@ -4206,8 +4206,8 @@ test_attr_deprec(hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Fclose"); #else /* H5_NO_DEPRECATED_SYMBOLS */ /* Shut compiler up */ - fcpl = fcpl; - fapl = fapl; + (void)fcpl; + (void)fapl; /* Output message about test being skipped */ MESSAGE(5, ("Skipping Test On Deprecated Attribute Routines\n")); diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c index d9616e1..f28c1bc 100644 --- a/tools/lib/h5diff_array.c +++ b/tools/lib/h5diff_array.c @@ -472,9 +472,7 @@ diff_datum(void *_mem1, void *_mem2, hsize_t elemtno, diff_opt_t *opts, hid_t co size_t size = 0; hbool_t iszero1; hbool_t iszero2; - hsize_t nfound = 0; /* differences found */ - double per; - hbool_t both_zero; + hsize_t nfound = 0; /* differences found */ diff_err_t ret_value = opts->err_stat; H5TOOLS_START_DEBUG("ph:%d elemtno:%d - errstat:%d", opts->print_header, elemtno, opts->err_stat); diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c index bee6262..7da717f 100644 --- a/tools/lib/h5tools_utils.c +++ b/tools/lib/h5tools_utils.c @@ -208,8 +208,6 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti arg[arg_len] = 0; for (i = 0; l_opts && l_opts[i].name; i++) { - size_t len = HDstrlen(l_opts[i].name); - if (HDstrcmp(arg, l_opts[i].name) == 0) { /* we've found a matching long command line flag */ opt_opt = l_opts[i].shortval; -- cgit v0.12