summaryrefslogtreecommitdiffstats
path: root/src/H5Eint.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2010-07-22 17:02:26 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2010-07-22 17:02:26 (GMT)
commit3e48f9be0067b9df317d000aa83e6ad8ed6f583a (patch)
tree2f3fc77453c39d8c9daf28152547570e5a6aa69a /src/H5Eint.c
parent06763537dabab2043d7df4cf05ed21f7d01977c0 (diff)
downloadhdf5-3e48f9be0067b9df317d000aa83e6ad8ed6f583a.zip
hdf5-3e48f9be0067b9df317d000aa83e6ad8ed6f583a.tar.gz
hdf5-3e48f9be0067b9df317d000aa83e6ad8ed6f583a.tar.bz2
[svn-r19122] Description:
Bring metadata journaling branch closer to trunk by bringing back updates to internal error reporting macros, routines that deal with writing object header messages to the superblock extension, and some object header query routines. Also cleanups to journaling code & tests to use this code and to clean up in general. Tested on: Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode (h5committest not required on this branch)
Diffstat (limited to 'src/H5Eint.c')
-rw-r--r--src/H5Eint.c101
1 files changed, 101 insertions, 0 deletions
diff --git a/src/H5Eint.c b/src/H5Eint.c
index e0fa482..92c36a4 100644
--- a/src/H5Eint.c
+++ b/src/H5Eint.c
@@ -660,6 +660,107 @@ H5E_set_auto(H5E_t *estack, const H5E_auto_op_t *op, void *client_data)
/*-------------------------------------------------------------------------
+ * Function: H5E_printf_stack
+ *
+ * Purpose: Printf-like wrapper around H5E_push_stack.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, August 12, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned line,
+ hid_t cls_id, hid_t maj_id, hid_t min_id, const char *fmt, ...)
+{
+ va_list ap; /* Varargs info */
+#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 */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ /*
+ * WARNING: We cannot call HERROR() from within this function or else we
+ * could enter infinite recursion. Furthermore, we also cannot
+ * call any other HDF5 macro or function which might call
+ * HERROR(). HERROR() is called by HRETURN_ERROR() which could
+ * be called by FUNC_ENTER().
+ */
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5E_printf_stack)
+
+ /* Sanity check */
+ HDassert(cls_id > 0);
+ HDassert(maj_id > 0);
+ HDassert(min_id > 0);
+ HDassert(fmt);
+
+/* Note that the variable-argument parsing for the format is identical in
+ * the H5Epush2() routine - correct errors and make changes in both
+ * places. -QAK
+ */
+
+ /* Start the variable-argument parsing */
+ va_start(ap, fmt);
+
+#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_DONE(FAIL)
+#else /* H5_HAVE_VASPRINTF */
+ /* Allocate space for the formatted description buffer */
+ tmp_len = 128;
+ if(NULL == (tmp = H5MM_malloc((size_t)tmp_len)))
+ 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 */
+ ) {
+ /* shutdown & restart the va_list */
+ va_end(ap);
+ va_start(ap, fmt);
+
+ /* Release the previous description, it's too small */
+ 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 */
+#endif /* H5_HAVE_VASPRINTF */
+
+ va_end(ap);
+
+ /* Push the error on the stack */
+ if(H5E_push_stack(estack, file, func, line, cls_id, maj_id, min_id, tmp) < 0)
+ HGOTO_DONE(FAIL)
+
+done:
+ if(tmp)
+ H5MM_xfree(tmp);
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5E_printf_stack() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5E_push_stack
*
* Purpose: Pushes a new error record onto error stack for the current