From bc5cc6f23820b5d997baa9a3d7473c9a3e0e1a38 Mon Sep 17 00:00:00 2001 From: eplanet Date: Wed, 7 Nov 2018 23:00:22 +0100 Subject: Fix error messages --- src/print_cpu_usage.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/print_cpu_usage.c b/src/print_cpu_usage.c index 2549043..faac920 100644 --- a/src/print_cpu_usage.c +++ b/src/print_cpu_usage.c @@ -165,8 +165,10 @@ void print_cpu_usage(yajl_gen json_gen, char *buffer, const char *format, const 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; -- cgit v1.2.3