str = sysfs_strdup(sysfs, "mm_stat");
if (str) {
z->mm_stat = strv_split(str, " ");
- if (strv_length(z->mm_stat) < ARRAY_SIZE(mm_stat_names))
- errx(EXIT_FAILURE, _("Failed to parse mm_stat"));
+
+ /* make sure kernel provides mm_stat as expected */
+ if (strv_length(z->mm_stat) < ARRAY_SIZE(mm_stat_names)) {
+ strv_free(z->mm_stat);
+ z->mm_stat = NULL;
+ }
}
z->mm_stat_probed = 1;
free(str);
ln = scols_table_new_line(tb, NULL);
if (!ln)
- err(EXIT_FAILURE, _("failed to initialize output line"));
+ err(EXIT_FAILURE, _("failed to allocate output line"));
for (i = 0; i < (size_t) ncolumns; i++) {
char *str = NULL;
str = get_mm_stat(z, MM_NUM_MIGRATED, inbytes);
break;
}
- if (str)
- scols_line_refer_data(ln, i, str);
+ if (str && scols_line_refer_data(ln, i, str))
+ err(EXIT_FAILURE, _("failed to add output data"))
}
}
tb = scols_new_table();
if (!tb)
- err(EXIT_FAILURE, _("failed to initialize output table"));
+ err(EXIT_FAILURE, _("failed to allocate output table"));
scols_table_enable_raw(tb, raw);
scols_table_enable_noheadings(tb, no_headings);
case 'h':
usage(stdout);
default:
- usage(stderr);
+ errtryhelp(EXIT_FAILURE);
}
}