diff options
-rw-r--r-- | config/cmake/H5pubconf.h.in | 4 | ||||
-rwxr-xr-x | configure | 88 | ||||
-rw-r--r-- | configure.ac | 54 | ||||
-rw-r--r-- | src/H5E.c | 16 | ||||
-rw-r--r-- | src/H5Eint.c | 16 | ||||
-rw-r--r-- | src/H5config.h.in | 4 | ||||
-rw-r--r-- | tools/lib/h5tools_str.c | 6 | ||||
-rw-r--r-- | tools/lib/h5tools_utils.c | 19 |
8 files changed, 6 insertions, 201 deletions
diff --git a/config/cmake/H5pubconf.h.in b/config/cmake/H5pubconf.h.in index eccbe29..c47b7c4 100644 --- a/config/cmake/H5pubconf.h.in +++ b/config/cmake/H5pubconf.h.in @@ -637,10 +637,6 @@ /* Version number of package */ #define H5_VERSION "@HDF5_PACKAGE_VERSION_STRING@" -/* Define if vsnprintf() returns the correct value for formatted strings that - don't fit into size allowed */ -#cmakedefine H5_VSNPRINTF_WORKS @H5_VSNPRINTF_WORKS@ - /* Check exception handling functions during data conversions */ #cmakedefine H5_WANT_DCONV_EXCEPTION @H5_WANT_DCONV_EXCEPTION@ @@ -26608,7 +26608,7 @@ _ACEOF fi done -for ac_func in tmpfile asprintf vasprintf waitpid +for ac_func in tmpfile asprintf vasprintf vsnprintf waitpid do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" @@ -26621,92 +26621,6 @@ fi done -## Check for vsnprintf() separately, so we can detect situations where it -## doesn't return the correct size for formatted strings that are too large -## for the buffer provided -for ac_func in vsnprintf -do : - ac_fn_c_check_func "$LINENO" "vsnprintf" "ac_cv_func_vsnprintf" -if test "x$ac_cv_func_vsnprintf" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_VSNPRINTF 1 -_ACEOF - ## Check if vsnprintf() returns correct size for strings that don't fit - ## into the size allowed. If vsnprintf() works correctly on this platform, - ## it should return a value of 42 for the test below - ## - ## Note that vsnprintf fails in two different ways: - ## - In IRIX64, calls to vnsprintf() with a formatted string that - ## is larger than the buffer size allowed incorrectly - ## return the size of the buffer minus one. - ## - In HP/UX, calls to vsnprintf() with a formatted string that - ## is larger than the buffer size allowed incorrectly - ## return (-1) - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if vsnprintf returns correct value" >&5 -$as_echo_n "checking if vsnprintf returns correct value... " >&6; } - - if ${hdf5_cv_vsnprintf_works+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot run test program while cross compiling -See \`config.log' for more details" "$LINENO" 5; } -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include <stdio.h> -#include <stdlib.h> -#include <stdarg.h> - -int test_vsnprintf(const char *fmt,...) -{ - va_list ap; - char *s = malloc(16); - int ret; - - va_start(ap, fmt); - ret=vsnprintf(s,16,"%s",ap); - va_end(ap); - - return(ret!=42 ? 1 : 0); -} - -int main(void) -{ - exit(test_vsnprintf("%s","A string that is longer than 16 characters")); -} - -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - hdf5_cv_vsnprintf_works=yes -else - hdf5_cv_vsnprintf_works=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi - - - if test ${hdf5_cv_vsnprintf_works} = "yes"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - -$as_echo "#define VSNPRINTF_WORKS 1" >>confdefs.h - - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - fi - -fi -done - - ## ---------------------------------------------------------------------- ## Check that a lone colon can be used as an argument ## This is not true on Cray X1, which interprets a lone colon as a diff --git a/configure.ac b/configure.ac index ea7608c..bf13fbf 100644 --- a/configure.ac +++ b/configure.ac @@ -1854,59 +1854,7 @@ AC_CHECK_FUNCS([gethostname getpwuid getrusage gettimeofday]) AC_CHECK_FUNCS([lstat rand_r random setsysinfo]) AC_CHECK_FUNCS([signal longjmp setjmp siglongjmp sigsetjmp sigprocmask]) AC_CHECK_FUNCS([snprintf srandom strdup symlink system]) -AC_CHECK_FUNCS([tmpfile asprintf vasprintf waitpid]) - -## Check for vsnprintf() separately, so we can detect situations where it -## doesn't return the correct size for formatted strings that are too large -## for the buffer provided -AC_CHECK_FUNCS([vsnprintf], - - ## Check if vsnprintf() returns correct size for strings that don't fit - ## into the size allowed. If vsnprintf() works correctly on this platform, - ## it should return a value of 42 for the test below - ## - ## Note that vsnprintf fails in two different ways: - ## - In IRIX64, calls to vnsprintf() with a formatted string that - ## is larger than the buffer size allowed incorrectly - ## return the size of the buffer minus one. - ## - In HP/UX, calls to vsnprintf() with a formatted string that - ## is larger than the buffer size allowed incorrectly - ## return (-1) - AC_MSG_CHECKING([if vsnprintf returns correct value]) - - AC_CACHE_VAL([hdf5_cv_vsnprintf_works], - AC_TRY_RUN([ -#include <stdio.h> -#include <stdlib.h> -#include <stdarg.h> - -int test_vsnprintf(const char *fmt,...) -{ - va_list ap; - char *s = malloc(16); - int ret; - - va_start(ap, fmt); - ret=vsnprintf(s,16,"%s",ap); - va_end(ap); - - return(ret!=42 ? 1 : 0); -} - -int main(void) -{ - exit(test_vsnprintf("%s","A string that is longer than 16 characters")); -} - ],[hdf5_cv_vsnprintf_works=yes],[hdf5_cv_vsnprintf_works=no],)) - - if test ${hdf5_cv_vsnprintf_works} = "yes"; then - AC_MSG_RESULT([yes]) - AC_DEFINE([VSNPRINTF_WORKS], [1], - [Define if vsnprintf() returns the correct value for formatted strings that don't fit into size allowed]) - else - AC_MSG_RESULT([no]) - fi - ,) +AC_CHECK_FUNCS([tmpfile asprintf vasprintf vsnprintf waitpid]) ## ---------------------------------------------------------------------- ## Check that a lone colon can be used as an argument @@ -1397,17 +1397,7 @@ H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line, HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* If the description doesn't fit into the initial buffer size, allocate more space and try again */ - while((desc_len = HDvsnprintf(tmp, (size_t)tmp_len, fmt, ap)) -#ifdef H5_VSNPRINTF_WORKS - > -#else /* H5_VSNPRINTF_WORKS */ - >= -#endif /* H5_VSNPRINTF_WORKS */ - (tmp_len - 1) -#ifndef H5_VSNPRINTF_WORKS - || (desc_len < 0) -#endif /* H5_VSNPRINTF_WORKS */ - ) { + while((desc_len = HDvsnprintf(tmp, (size_t)tmp_len, fmt, ap)) > (tmp_len - 1)) { /* shutdown & restart the va_list */ va_end(ap); va_start(ap, fmt); @@ -1416,11 +1406,7 @@ H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line, H5MM_xfree(tmp); /* Allocate a description of the appropriate length */ -#ifdef H5_VSNPRINTF_WORKS tmp_len = desc_len + 1; -#else /* H5_VSNPRINTF_WORKS */ - tmp_len = 2 * tmp_len; -#endif /* H5_VSNPRINTF_WORKS */ if(NULL == (tmp = H5MM_malloc((size_t)tmp_len))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") } /* end while */ diff --git a/src/H5Eint.c b/src/H5Eint.c index 88dfdee..2092566 100644 --- a/src/H5Eint.c +++ b/src/H5Eint.c @@ -741,17 +741,7 @@ H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned lin HGOTO_DONE(FAIL) /* If the description doesn't fit into the initial buffer size, allocate more space and try again */ - while((desc_len = HDvsnprintf(tmp, (size_t)tmp_len, fmt, ap)) -#ifdef H5_VSNPRINTF_WORKS - > -#else /* H5_VSNPRINTF_WORKS */ - >= -#endif /* H5_VSNPRINTF_WORKS */ - (tmp_len - 1) -#ifndef H5_VSNPRINTF_WORKS - || (desc_len < 0) -#endif /* H5_VSNPRINTF_WORKS */ - ) { + while((desc_len = HDvsnprintf(tmp, (size_t)tmp_len, fmt, ap)) > (tmp_len - 1)) { /* shutdown & restart the va_list */ va_end(ap); va_start(ap, fmt); @@ -760,11 +750,7 @@ H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned lin H5MM_xfree(tmp); /* Allocate a description of the appropriate length */ -#ifdef H5_VSNPRINTF_WORKS tmp_len = desc_len + 1; -#else /* H5_VSNPRINTF_WORKS */ - tmp_len = 2 * tmp_len; -#endif /* H5_VSNPRINTF_WORKS */ if(NULL == (tmp = H5MM_malloc((size_t)tmp_len))) HGOTO_DONE(FAIL) } /* end while */ diff --git a/src/H5config.h.in b/src/H5config.h.in index 9b840f2..c089cd3 100644 --- a/src/H5config.h.in +++ b/src/H5config.h.in @@ -545,10 +545,6 @@ /* Version number of package */ #undef VERSION -/* Define if vsnprintf() returns the correct value for formatted strings that - don't fit into size allowed */ -#undef VSNPRINTF_WORKS - /* Check exception handling functions during data conversions */ #undef WANT_DCONV_EXCEPTION diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c index f4302a9..2603984 100644 --- a/tools/lib/h5tools_str.c +++ b/tools/lib/h5tools_str.c @@ -155,11 +155,7 @@ h5tools_str_append(h5tools_str_t *str/*in,out*/, const char *fmt, ...) * to lack of buffer size, so try one more time after realloc more * buffer size before return NULL. */ - if (nchars < 0 -#ifndef H5_VSNPRINTF_WORKS - && (HDstrlen(str->s) < str->nalloc) -#endif - ) { + if (nchars < 0) { /* failure, such as bad format */ return NULL; } diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c index d7c5adb..fc8cf1d 100644 --- a/tools/lib/h5tools_utils.c +++ b/tools/lib/h5tools_utils.c @@ -89,28 +89,11 @@ void parallel_print(const char* format, ...) HDvprintf(format, ap); else { if(overflow_file == NULL) /*no overflow has occurred yet */ { -#if 0 - printf("calling HDvsnprintf: OUTBUFF_SIZE=%ld, outBuffOffset=%ld, ", (long)OUTBUFF_SIZE, (long)outBuffOffset); -#endif bytes_written = HDvsnprintf(outBuff+outBuffOffset, OUTBUFF_SIZE-outBuffOffset, format, ap); -#if 0 - printf("bytes_written=%ld\n", (long)bytes_written); -#endif HDva_end(ap); HDva_start(ap, format); -#if 0 - printf("Result: bytes_written=%ld, OUTBUFF_SIZE-outBuffOffset=%ld\n", (long)bytes_written, (long)OUTBUFF_SIZE-outBuffOffset); -#endif - - if ((bytes_written < 0) || -#ifdef H5_VSNPRINTF_WORKS - (bytes_written >= (OUTBUFF_SIZE-outBuffOffset)) -#else - ((bytes_written+1) == (OUTBUFF_SIZE-outBuffOffset)) -#endif - ) - { + if((bytes_written < 0) || (bytes_written >= (OUTBUFF_SIZE - outBuffOffset))) { /* Terminate the outbuff at the end of the previous output */ outBuff[outBuffOffset] = '\0'; |