From 6a664ffa5aba85eb2d35526fa9d41a5b69f7f21d Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Mon, 30 Mar 2015 09:47:36 -0500 Subject: [svn-r26648] Description: Bring r26635 from trunk to 1.8 branch: Bring r26651 from autotools_rework branch to trunk: Remove the VSNPRINTF_WORKS macro, it's working around bugs in old SGI & HP compilers. Tested on: Linux/32 2.6.18 (jam) w/serial & parallel (Daily tested on trunk for 2+ days) --- config/cmake/H5pubconf.h.in | 4 -- configure | 90 +-------------------------------------------- configure.ac | 54 +-------------------------- src/H5E.c | 16 +------- src/H5Eint.c | 16 +------- src/H5config.h.in | 4 -- tools/lib/h5tools_str.c | 6 +-- tools/lib/h5tools_utils.c | 19 +--------- 8 files changed, 7 insertions(+), 202 deletions(-) diff --git a/config/cmake/H5pubconf.h.in b/config/cmake/H5pubconf.h.in index 3b46d62..916c4c4 100644 --- a/config/cmake/H5pubconf.h.in +++ b/config/cmake/H5pubconf.h.in @@ -657,10 +657,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@ - /* Data accuracy is prefered to speed during data conversions */ #cmakedefine H5_WANT_DATA_ACCURACY @H5_WANT_DATA_ACCURACY@ diff --git a/configure b/configure index becc43f..d500848 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.ac Id: configure.ac 26638 2015-03-28 02:19:21Z koziol . +# From configure.ac Id: configure.ac 26644 2015-03-29 23:17:21Z hdftest . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for HDF5 1.8.15-snap14. # @@ -26523,7 +26523,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" @@ -26536,92 +26536,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 -#include -#include - -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 bc2f0d4..f192768 100644 --- a/configure.ac +++ b/configure.ac @@ -1802,59 +1802,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 -#include -#include - -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 diff --git a/src/H5E.c b/src/H5E.c index 3fe2a83..cd4da9f 100644 --- a/src/H5E.c +++ b/src/H5E.c @@ -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 4c678b6..0dab65c 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 5299d44..8b4648f 100644 --- a/src/H5config.h.in +++ b/src/H5config.h.in @@ -568,10 +568,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 - /* Data accuracy is prefered to speed during data conversions */ #undef WANT_DATA_ACCURACY diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c index ac191d6..22518d6 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'; -- cgit v0.12