]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Pass buffer size to VG_(elapsed_wallclock_time) so the function
authorFlorian Krohm <florian@eich-krohm.de>
Fri, 14 Nov 2014 22:34:40 +0000 (22:34 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Fri, 14 Nov 2014 22:34:40 +0000 (22:34 +0000)
can check it's large enough.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14724

coregrind/m_libcprint.c
coregrind/m_main.c
coregrind/pub_core_libcprint.h

index 549e7d7e884f87ca924067136792c0e7a96796d3..13258568b5f00769d28564af58b90c7747dcb487 100644 (file)
@@ -424,10 +424,12 @@ void VG_(percentify)(ULong n, ULong m, UInt d, Int n_buf, HChar buf[])
    millisecond timer having been set to zero by an initial read in
    m_main during startup. */
 
-void VG_(elapsed_wallclock_time) ( /*OUT*/HChar* buf )
+void VG_(elapsed_wallclock_time) ( /*OUT*/HChar* buf, SizeT bufsize )
 {
    UInt t, ms, s, mins, hours, days;
 
+   vg_assert(bufsize > 20);
+
    t  = VG_(read_millisecond_timer)(); /* milliseconds */
 
    ms = t % 1000;
@@ -534,9 +536,7 @@ static void add_to__vmessage_buf ( HChar c, void *p )
          b->buf[b->buf_used++] = ch;
 
          if (VG_(clo_time_stamp)) {
-            VG_(memset)(tmp, 0, sizeof(tmp));
-            VG_(elapsed_wallclock_time)(tmp);
-            tmp[sizeof(tmp)-1] = 0;
+            VG_(elapsed_wallclock_time)(tmp, sizeof tmp);
             for (i = 0; tmp[i]; i++)
                b->buf[b->buf_used++] = tmp[i];
          }
index 6542600d0153b3ac2c2c2b9fa7a797f9410bda2f..2a0b2a67785a75afbeb10b5c8dbcf74bb4aa3c15 100644 (file)
@@ -2208,7 +2208,7 @@ Int valgrind_main ( Int argc, HChar **argv, HChar **envp )
 
    if (VG_(clo_xml)) {
       HChar buf[50];
-      VG_(elapsed_wallclock_time)(buf);
+      VG_(elapsed_wallclock_time)(buf, sizeof buf);
       VG_(printf_xml)( "<status>\n"
                        "  <state>RUNNING</state>\n"
                        "  <time>%pS</time>\n"
@@ -2545,7 +2545,7 @@ void shutdown_actions_NORETURN( ThreadId tid,
 
    if (VG_(clo_xml)) {
       HChar buf[50];
-      VG_(elapsed_wallclock_time)(buf);
+      VG_(elapsed_wallclock_time)(buf, sizeof buf);
       VG_(printf_xml)( "<status>\n"
                               "  <state>FINISHED</state>\n"
                               "  <time>%pS</time>\n"
index ef086da9be689de0c12635a844d64ae685afdff2..c9adb0b24fe3611f33aebe7ddbd6fe458b483776 100644 (file)
@@ -48,11 +48,13 @@ typedef
 extern OutputSink VG_(log_output_sink);
 extern OutputSink VG_(xml_output_sink);
 
-/* Get the elapsed wallclock time since startup into buf, which must
-   16 chars long.  This is unchecked.  It also relies on the
+/* Get the elapsed wallclock time since startup into buf which has size
+   bufsize. The function will assert if bufsize is not large enough.
+   Upon return, buf will contain the zero-terminated wallclock time as
+   a string. The function also relies on the
    millisecond timer having been set to zero by an initial read in
    m_main during startup. */
-void VG_(elapsed_wallclock_time) ( /*OUT*/HChar* buf );
+void VG_(elapsed_wallclock_time) ( /*OUT*/HChar* buf, SizeT bufsize );
 
 /* Call this if the executable is missing.  This function prints an
    error message, then shuts down the entire system. */