|
From: <sv...@va...> - 2014-07-31 11:55:51
|
Author: florian
Date: Thu Jul 31 11:55:40 2014
New Revision: 14215
Log:
Get rid of the fixed size buffer in VG_(assert_fail). I have no idea
why it was there in the first place. First, we would write into it
and later printf("%s", buf). We can as well use vprintf directly.
That's what we do now.
Modified:
branches/BUF_REMOVAL/coregrind/m_libcassert.c
Modified: branches/BUF_REMOVAL/coregrind/m_libcassert.c
==============================================================================
--- branches/BUF_REMOVAL/coregrind/m_libcassert.c (original)
+++ branches/BUF_REMOVAL/coregrind/m_libcassert.c Thu Jul 31 11:55:40 2014
@@ -396,8 +396,7 @@
void VG_(assert_fail) ( Bool isCore, const HChar* expr, const HChar* file,
Int line, const HChar* fn, const HChar* format, ... )
{
- va_list vargs;
- HChar buf[512];
+ va_list vargs, vargs_copy;
const HChar* component;
const HChar* bugs_to;
UInt written;
@@ -407,15 +406,6 @@
VG_(exit)(2);
entered = True;
- va_start(vargs, format);
- written = VG_(vsnprintf) ( buf, sizeof(buf), format, vargs );
- va_end(vargs);
-
- if (written >= sizeof(buf)) {
- VG_(printf)("\nvalgrind: %s: buf is too small, sizeof(buf) = %u, "
- "written = %d\n", __func__, (unsigned)sizeof(buf), written);
- }
-
if (isCore) {
component = "valgrind";
bugs_to = VG_BUGS_TO;
@@ -435,8 +425,19 @@
VG_(printf)("\n%s: %s:%d (%s): Assertion '%s' failed.\n",
component, file, line, fn, expr );
}
- if (!VG_STREQ(buf, ""))
- VG_(printf)("%s: %s\n", component, buf );
+
+ /* Check whether anything will be written */
+ HChar buf[5];
+ va_start(vargs, format);
+ va_copy(vargs_copy, vargs);
+ written = VG_(vsnprintf) ( buf, sizeof(buf), format, vargs );
+ va_end(vargs);
+
+ if (written > 0) {
+ VG_(printf)("%s: ", component);
+ VG_(vprintf)(format, vargs_copy);
+ VG_(printf)("\n");
+ }
report_and_quit(bugs_to, NULL);
}
|