Merge pull request #318 from gportay/fix-invalid-cpu-placeholder
print_cpu_usage: fix invalid %cpu placeholder output
This commit is contained in:
commit
be5f38e0a6
@ -151,7 +151,7 @@ void print_cpu_usage(yajl_gen json_gen, char *buffer, const char *format, const
|
||||
}
|
||||
#if defined(LINUX)
|
||||
else if (BEGINS_WITH(walk + 1, "cpu")) {
|
||||
int number = 0;
|
||||
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);
|
||||
|
7
testcases/024-cpu-usage-invalid-cpu/expected_output.pl
Normal file
7
testcases/024-cpu-usage-invalid-cpu/expected_output.pl
Normal file
@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
use v5.10;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
print "CPU: \n";
|
9
testcases/024-cpu-usage-invalid-cpu/i3status.conf
Normal file
9
testcases/024-cpu-usage-invalid-cpu/i3status.conf
Normal file
@ -0,0 +1,9 @@
|
||||
general {
|
||||
output_format = "none"
|
||||
}
|
||||
|
||||
order += "cpu_usage"
|
||||
|
||||
cpu_usage {
|
||||
format = "CPU: %cpu"
|
||||
}
|
Loading…
Reference in New Issue
Block a user