summaryrefslogtreecommitdiffstats
path: root/src/H5E.c
diff options
context:
space:
mode:
authorDavid Young <dyoung@hdfgroup.org>2020-09-28 19:42:18 (GMT)
committerDavid Young <dyoung@hdfgroup.org>2020-09-28 19:42:18 (GMT)
commit14851e3b82a9b116153f9505654faf2f60e1abe2 (patch)
tree4ab01f77f124bad03f76338e70b6e2b3f0fb01e5 /src/H5E.c
parent8ee8b7abb55bc8d901e31b3eef9ba35abb352814 (diff)
parentc0fbc5c086566d5d3c1d1ef26baa81a53d59fc08 (diff)
downloadhdf5-14851e3b82a9b116153f9505654faf2f60e1abe2.zip
hdf5-14851e3b82a9b116153f9505654faf2f60e1abe2.tar.gz
hdf5-14851e3b82a9b116153f9505654faf2f60e1abe2.tar.bz2
Merge pull request #2650 in HDFFV/hdf5 from ~DYOUNG/werror:rebased-fprintf-experiment to develop
* commit 'c0fbc5c086566d5d3c1d1ef26baa81a53d59fc08': (24 commits) Use the right format string, "%zu", for size_t. Repair more format strings. Fix a bunch of format string errors reported by Larry. Fix some HDfprintf compilation errors: use the right format strings ("zu", PRIuHSIZE), avoid casting some printf arguments, pass the right number of arguments. Test the format string "ll" before "l", "L", and "q", like the ./configure script does. This ought to fix the compilation failure in test/dt_arith.c that Allen told me about: Cast a non-void pointer to void pointer for "%p". Use PRIu32 and "zu" formats. Delete some casts from `size_t`. I'm taking a guess that this code intended to point the 2-digit wide hexadecimal octet values, not 2 character-wide pointers to the bytes. The %02p format, which is a GNU-ism, disagreed with GCC 8.3.0 and the option flags we use. %08p is not portable, it's a GNU-ism. Use %8p, instead. Squashes a GCC error. Add format string macros PRI[doxX]HID for hid_t and use PRIdHID. Use HDva_copy() and introduce a bunch of compatbility format-string constants for uppercase hexadecimal strings, `PRIX...`. Should fix the VS2010 errors that Allen mentioned: Always #define HDfprintf as fprintf in this header. I believe this will fix the Windows build error that Allen reported. Provide an HDvasprintf implementation only if it isn't #defined. This should fix the mingw compilation issue that Allen reported. Fix va_list usage in the vasprintf(3) implementation. Promote format-string warnings to errors. Use the portable `-eq` operator instead of the bash-ism `==`. Fixes the tests on NetBSD, where /bin/sh != bash. Restore a literal percent sign ("%%") that I accidentally deleted. Fix code that made GCC complain about a NULL or `unsigned char *` arguments for "%s". Take pains to provide UINT64_MAX in all conditions. Correct a couple of format strings. ...
Diffstat (limited to 'src/H5E.c')
-rw-r--r--src/H5E.c31
1 files changed, 0 insertions, 31 deletions
diff --git a/src/H5E.c b/src/H5E.c
index a56181d..15cf5f4 100644
--- a/src/H5E.c
+++ b/src/H5E.c
@@ -1355,10 +1355,6 @@ H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line,
{
va_list ap; /* Varargs info */
H5E_t *estack; /* Pointer to error stack to modify */
-#ifndef H5_HAVE_VASPRINTF
- int tmp_len; /* Current size of description buffer */
- int desc_len; /* Actual length of description when formatted */
-#endif /* H5_HAVE_VASPRINTF */
char *tmp = NULL; /* Buffer to place formatted description in */
hbool_t va_started = FALSE; /* Whether the variable argument list is open */
herr_t ret_value=SUCCEED; /* Return value */
@@ -1388,31 +1384,9 @@ H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line,
HDva_start(ap, fmt);
va_started = TRUE;
-#ifdef H5_HAVE_VASPRINTF
/* Use the vasprintf() routine, since it does what we're trying to do below */
if(HDvasprintf(&tmp, fmt, ap) < 0)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
-#else /* H5_HAVE_VASPRINTF */
- /* Allocate space for the formatted description buffer */
- tmp_len = 128;
- if(NULL == (tmp = H5MM_malloc((size_t)tmp_len)))
- 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)) > (tmp_len - 1)) {
- /* shutdown & restart the va_list */
- HDva_end(ap);
- HDva_start(ap, fmt);
-
- /* Release the previous description, it's too small */
- H5MM_xfree(tmp);
-
- /* Allocate a description of the appropriate length */
- tmp_len = desc_len + 1;
- if(NULL == (tmp = H5MM_malloc((size_t)tmp_len)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
- } /* end while */
-#endif /* H5_HAVE_VASPRINTF */
/* Push the error on the stack */
if(H5E__push_stack(estack, file, func, line, cls_id, maj_id, min_id, tmp) < 0)
@@ -1421,16 +1395,11 @@ H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line,
done:
if(va_started)
HDva_end(ap);
-#ifdef H5_HAVE_VASPRINTF
/* Memory was allocated with HDvasprintf so it needs to be freed
* with HDfree
*/
if(tmp)
HDfree(tmp);
-#else /* H5_HAVE_VASPRINTF */
- if(tmp)
- H5MM_xfree(tmp);
-#endif /* H5_HAVE_VASPRINTF */
FUNC_LEAVE_API(ret_value)
} /* end H5Epush2() */