]> sourceware.org Git - systemtap.git/commitdiff
monitor mode: bugfix
authorFelix Lu <flu@redhat.com>
Tue, 26 Apr 2016 20:48:27 +0000 (16:48 -0400)
committerFelix Lu <flu@redhat.com>
Tue, 26 Apr 2016 21:06:11 +0000 (17:06 -0400)
Fix an off by 1 error and always flush output.

staprun/monitor.c

index 0f806e1d6febe7a9245357f0a3a4f235d79d9aba..45fabbb0e57c9f600b24629348471eb0c020c63e 100644 (file)
@@ -541,7 +541,7 @@ void monitor_input(void)
       char *p = h_queue.linebuf; /* scan position */
       char *p_end = h_queue.linebuf + h_queue.linebuf_ptr + bytes; /* one past last byte */
       char *line = p;
-      while (p <= p_end)
+      while (p < p_end)
         {
           if (*p == '\n') /* got a line */
             {
@@ -551,19 +551,10 @@ void monitor_input(void)
           p ++;
         }
 
-      if (line != p)
-        {
-          /* Move trailing partial line (if any) to front of buffer. */
-          memmove (h_queue.linebuf, line, (p_end - line));
-          h_queue.linebuf_ptr = (p_end - line);
-        }
-      else
-        {
-          /* No line found in entire buffer!  Pretend it was all one line. */
-          monitor_remember_output_line(line, (p_end - line));
-          h_queue.linebuf_ptr = 0;
-        }
-    }          
+      /* Flush remaining output */
+      monitor_remember_output_line(line, (p_end - line));
+      h_queue.linebuf_ptr = 0;
+    }
 
   getmaxyx(monitor_output, max_rows, max_cols);
   getyx(monitor_status, cur_y, cur_x);
This page took 0.026062 seconds and 5 git commands to generate.