rt-tests: cyclictest: Fix parsing affinity with a space and a leading zero

-/cyclictest -t -a1-4
./cyclictest -t -a 1-4
./cyclictest -t -a0-4
all work as expected, but
./cyclictest -t -a 0-4
did not work, and instead AFFINITY_USEALL was set.

This is because atoi(argv[optind]) returns 0 for parsing non-numbers,
and this was treated as an error.

This missed the case where the user intentionally passes a 0 which
should not be treated as an error.

Fix this by testing for this case.

Signed-off-by: John Kacur <jkacur@redhat.com>
This commit is contained in:
John Kacur 2020-02-27 21:52:52 -05:00
parent 96d9f54eb0
commit 164e6251b3
1 changed files with 1 additions and 1 deletions

View File

@ -1199,7 +1199,7 @@ static void process_options (int argc, char *argv[], int max_cpus)
if (optarg != NULL) {
parse_cpumask(optarg, max_cpus);
setaffinity = AFFINITY_SPECIFIED;
} else if (optind<argc && atoi(argv[optind])) {
} else if (optind<argc && (atoi(argv[optind]) || argv[optind][0] == '0')) {
parse_cpumask(argv[optind], max_cpus);
setaffinity = AFFINITY_SPECIFIED;
} else {