Fix error messages

This commit is contained in:
eplanet 2018-11-07 23:00:22 +01:00
parent 1492868b80
commit bc5cc6f238
2 changed files with 5 additions and 3 deletions

View File

@ -666,7 +666,7 @@ int main(int argc, char *argv[]) {
while (1) { while (1) {
if (exit_upon_signal) { if (exit_upon_signal) {
fprintf(stderr, "Exiting due to signal.\n"); fprintf(stderr, "i3status: exiting due to signal.\n");
exit(1); exit(1);
} }
struct timeval tv; struct timeval tv;

View File

@ -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")) { else if (BEGINS_WITH(walk + 1, "cpu")) {
int number = -1; int number = -1;
sscanf(walk + 1, "cpu%d", &number); sscanf(walk + 1, "cpu%d", &number);
if (number < 0 || number >= cpu_count) { if (number == -1) {
fprintf(stderr, "provided CPU number '%d' above detected number of CPU %d\n", number, cpu_count); 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 { } else {
int cpu_diff_idle = curr_cpus[number].idle - prev_cpus[number].idle; int cpu_diff_idle = curr_cpus[number].idle - prev_cpus[number].idle;
int cpu_diff_total = curr_cpus[number].total - prev_cpus[number].total; int cpu_diff_total = curr_cpus[number].total - prev_cpus[number].total;