[Toybox] vmstat bug + patch

José Bollo jobol at nonadev.net
Mon May 11 01:22:30 PDT 2015


Please find here an alternate proposal for fixing that issue.
Best regards
José


diff --git a/toys/other/vmstat.c b/toys/other/vmstat.c
index eed7945..0884fe9 100644
--- a/toys/other/vmstat.c
+++ b/toys/other/vmstat.c
@@ -93,14 +93,15 @@ void vmstat_main(void)
 
     // Print headers
     if (rows>3 && !(loop % (rows-3))) {
+      char *h = headers;
       if (isatty(1)) terminal_size(0, &rows);
       else rows = 0;
 
       printf("procs -----------memory---------- ---swap-- -----io----
-system-- ----cpu----\n");
 
       for (i=0; i<sizeof(lengths); i++) {
-        printf(" %*s"+!i, lengths[i], headers);
-        headers += strlen(headers)+1;
+        printf(" %*s"+!i, lengths[i], h++);
+        while(*h++ != 0);
       }
       xputc('\n');
     }




 1431332550.0


More information about the Toybox mailing list