]> granicus.if.org Git - procps-ng/commitdiff
vmstat: Null the diskstats pointer
authorCraig Small <csmall@dropbear.xyz>
Sun, 13 Sep 2020 00:25:19 +0000 (10:25 +1000)
committerCraig Small <csmall@dropbear.xyz>
Sun, 13 Sep 2020 00:25:19 +0000 (10:25 +1000)
I'm not sure why, but the make check will now fail for vmstat

Running ./vmstat.test/vmstat.exp ...
FAIL: vmstat disk information (-d option)

With the _new function returning the error.
In vmstat all other structures are set to NULL before calling _new
except the diskstat ones. This has been corrected.

vmstat.c

index 71f518a72e8ddf0c2c539104bbf8966134e921f4..269a5a4a4bfa3a3e29a9e039c38c7a9b1c2ad0fe 100644 (file)
--- a/vmstat.c
+++ b/vmstat.c
@@ -542,7 +542,7 @@ static void diskpartition_header(const char *partition_name)
 static void diskpartition_format(const char *partition_name)
 {
  #define partVAL(x) DISKSTATS_VAL(x, ul_int, stack, disk_stat)
-    struct diskstats_info *disk_stat;
+    struct diskstats_info *disk_stat = NULL;
     struct diskstats_stack *stack;
     struct diskstats_result *got;
        const char format[] = "%21lu  %16lu  %10lu  %16lu\n";
@@ -642,7 +642,7 @@ static void diskheader(void)
 static void diskformat(void)
 {
 #define diskVAL(e,t) DISKSTATS_VAL(e, t, reap->stacks[j], disk_stat)
-    struct diskstats_info *disk_stat;
+    struct diskstats_info *disk_stat = NULL;
     struct diskstats_reaped *reap;
     int i, j;
     time_t the_time;
@@ -765,7 +765,7 @@ static void slabformat (void)
 static void disksum_format(void)
 {
 #define diskVAL(e,t) DISKSTATS_VAL(e, t, reap->stacks[j], disk_stat)
-    struct diskstats_info *disk_stat;
+    struct diskstats_info *disk_stat = NULL;
     struct diskstats_reaped *reap;
     int j, disk_count, part_count;
     unsigned long reads, merged_reads, read_sectors, milli_reading, writes,