// vim:ts=4:sw=4:expandtab
+#include <config.h>
+#if defined(__linux__)
#include <sys/sysinfo.h>
+#endif
#include <stdlib.h>
#include <limits.h>
#include <stdio.h>
int diff_idle, diff_total, diff_usage;
bool colorful_output = false;
-#if defined(LINUX)
+#if defined(__linux__)
// Detecting if CPU count has changed
int curr_cpu_count = get_nprocs_conf();
outwalk += sprintf(outwalk, "%02d%s", diff_usage, pct_mark);
walk += strlen("usage");
}
-#if defined(LINUX)
+#if defined(__linux__)
else if (BEGINS_WITH(walk + 1, "cpu")) {
int number = -1;
sscanf(walk + 1, "cpu%d", &number);
- if (number < 0 || number >= cpu_count) {
- fprintf(stderr, "provided CPU number '%d' above detected number of CPU %d\n", number, cpu_count);
+ if (number == -1) {
+ fprintf(stderr, "i3status: provided CPU number cannot be parsed\n");
+ } else if (number >= cpu_count) {
+ fprintf(stderr, "i3status: provided CPU number '%d' above detected number of CPU %d\n", number, cpu_count);
} else {
int cpu_diff_idle = curr_cpus[number].idle - prev_cpus[number].idle;
int cpu_diff_total = curr_cpus[number].total - prev_cpus[number].total;