From 05b604da9abdb85e0aeeec5128cb9ebb57aeea32 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Fri, 20 Nov 2015 22:48:01 -0500 Subject: [svn-r28433] Misc warning and cleanup fixes. Tested on Ubuntu 15.10 (Linux 4.2.0 x86_64) gcc 5.2.1 serial only --- fortran/src/H5Pf.c | 8 ++++++++ hl/src/H5TB.c | 2 +- src/H5private.h | 4 ++++ tools/h5jam/h5jam.c | 25 +++++++++---------------- tools/h5repack/dynlib_rpk.c | 16 ++++++++++++++-- tools/h5stat/h5stat.c | 4 ++-- tools/misc/talign.c | 2 +- 7 files changed, 39 insertions(+), 22 deletions(-) diff --git a/fortran/src/H5Pf.c b/fortran/src/H5Pf.c index 9735f48..523ed0b 100644 --- a/fortran/src/H5Pf.c +++ b/fortran/src/H5Pf.c @@ -4843,6 +4843,10 @@ h5pset_link_phase_change_c(hid_t_f *gcpl_id, int_f *max_compact, int_f *min_dens * * SOURCE */ +#ifndef H5_HAVE_DIRECT +/* Only gets gcc const attribute when the direct VFD is not built. */ +H5_ATTR_CONST +#endif int_f h5pset_fapl_direct_c(hid_t_f H5_ATTR_UNUSED *fapl_id, size_t_f H5_ATTR_UNUSED *alignment, size_t_f H5_ATTR_UNUSED *block_size, size_t_f H5_ATTR_UNUSED *cbuf_size) /******/ @@ -4886,6 +4890,10 @@ h5pset_fapl_direct_c(hid_t_f H5_ATTR_UNUSED *fapl_id, size_t_f H5_ATTR_UNUSED *a * * SOURCE */ +#ifndef H5_HAVE_DIRECT +/* Only gets gcc const attribute when the direct VFD is not built. */ +H5_ATTR_CONST +#endif int_f h5pget_fapl_direct_c(hid_t_f H5_ATTR_UNUSED *fapl_id, size_t_f H5_ATTR_UNUSED *alignment, size_t_f H5_ATTR_UNUSED *block_size, size_t_f H5_ATTR_UNUSED *cbuf_size) /******/ diff --git a/hl/src/H5TB.c b/hl/src/H5TB.c index 0f90393..bcd3339 100644 --- a/hl/src/H5TB.c +++ b/hl/src/H5TB.c @@ -3248,7 +3248,7 @@ out: * *------------------------------------------------------------------------- */ -static +H5_ATTR_PURE static hbool_t H5TB_find_field(const char *field, const char *field_list) { const char *start = field_list; diff --git a/src/H5private.h b/src/H5private.h index 532dc59..c536566 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -298,6 +298,10 @@ * * Note that Solaris Studio supports attribute, but does not support the * attributes we use. + * + * H5_ATTR_CONST is redefined in tools/h5repack/dynlib_rpk.c to quiet + * 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*/ diff --git a/tools/h5jam/h5jam.c b/tools/h5jam/h5jam.c index f70947c..4509734 100644 --- a/tools/h5jam/h5jam.c +++ b/tools/h5jam/h5jam.c @@ -515,28 +515,21 @@ copy_some_to_file(int infid, int outfid, hsize_t startin, hsize_t startout, * * Return: Success: last byte written in the output. * Failure: Exits program with EXIT_FAILURE value. - * - * Programmer: - * - * Modifications: - * *------------------------------------------------------------------------- */ -hsize_t -compute_user_block_size (hsize_t ublock_size) +H5_ATTR_CONST hsize_t +compute_user_block_size(hsize_t ublock_size) { - hsize_t where = 512; + hsize_t where = 512; - if (ublock_size == 0) - return 0; + if(0 == ublock_size) + return 0; - while (where < ublock_size) - { - where *= 2; - } + while(where < ublock_size) + where *= 2; - return (where); -} + return where; +} /* end compute_user_block_size() */ /* * Write zeroes to fill the file from 'where' to 512, 1024, etc. bytes. diff --git a/tools/h5repack/dynlib_rpk.c b/tools/h5repack/dynlib_rpk.c index 1ccc33a..6e8a7b6 100644 --- a/tools/h5repack/dynlib_rpk.c +++ b/tools/h5repack/dynlib_rpk.c @@ -24,6 +24,18 @@ #define H5Z_FILTER_DYNLIB1 257 +/* gcc attribute support from H5private.h */ +#ifdef __cplusplus +# define H5_ATTR_CONST /*void*/ +#else /* __cplusplus */ +#if defined(H5_HAVE_ATTRIBUTE) && !defined(__SUNPRO_C) +# define H5_ATTR_CONST __attribute__((const)) +#else +# define H5_ATTR_CONST /*void*/ +#endif +#endif /* __cplusplus */ + + static size_t H5Z_filter_dynlib1(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); @@ -38,8 +50,8 @@ const H5Z_class2_t H5Z_DYNLIB1[1] = {{ (H5Z_func_t)H5Z_filter_dynlib1, /* The actual filter function */ }}; -H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} -const void *H5PLget_plugin_info(void) {return H5Z_DYNLIB1;} +H5_ATTR_CONST H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} +H5_ATTR_CONST const void *H5PLget_plugin_info(void) {return H5Z_DYNLIB1;} /*------------------------------------------------------------------------- * Function: H5Z_filter_dynlib1 diff --git a/tools/h5stat/h5stat.c b/tools/h5stat/h5stat.c index ac6ca23..a331014 100644 --- a/tools/h5stat/h5stat.c +++ b/tools/h5stat/h5stat.c @@ -310,7 +310,7 @@ static void usage(const char *prog) * *------------------------------------------------------------------------- */ -static unsigned +H5_ATTR_CONST static unsigned ceil_log10(unsigned long x) { unsigned long pow10 = 1; @@ -321,7 +321,7 @@ ceil_log10(unsigned long x) ret++; } /* end while */ - return(ret); + return ret; } /* ceil_log10() */ diff --git a/tools/misc/talign.c b/tools/misc/talign.c index 194364e..be373e7 100644 --- a/tools/misc/talign.c +++ b/tools/misc/talign.c @@ -49,7 +49,7 @@ int main(void) char string5[5]; float fok[2] = {1234.0f, 2341.0f}; float fnok[2] = {5678.0f, 6785.0f}; - float *fptr; + float *fptr = NULL; char *data = NULL; -- cgit v0.12