cpuset_hotplug: fix cpuset_list_compute
PATCH 1/1 cpuset_hotplug: fix cpuset_list_compute
cpuset_hotplug failed with:
Usage : cpuset_list_compute [-a|s] list1 [list2]
-a|s list1 add/subtract list2.[default: -a]
-h Help.cpuset_hotplug 1 TFAIL: root group's cpus isn't expected(Result: 0,2-5, Expect: ).
It turned out that the helper cpuset_list_compute was always failing because it was improperly handling getopt retval using a char variable; in such a case the while() loop used around getopt never gets false, and as a consequence getopt() keeps on being invoked parsing also the following unknown non-option input material: this in turn leads to the loop termination through the default switch-label that finally terminates the program without doing anything each time.
This condition can also be spotted during the compilation process:
cpuset_list_compute.c: In function 'checkopt':
cpuset_list_compute.c:35:41: warning: comparison is always true due to limited range of data type [-Wtype-limits]
while ((c = getopt(argc, argv, "ahs")) != -1) {
^~--- .../cpuset/cpuset_hotplug_test/cpuset_list_compute.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
testcases/kernel/controllers/cpuset/cpuset_hotplug_test/cpuset_list_compute.c +1 -2
@@ -29,8 +29,7 @@ static void usage(char *prog_name, int status)static void checkopt (int argc,char **argv) { -char c ='\0' ; -int optc =0 ; +int c, optc =0 ;while ((c =getopt (argc, argv,"ahs" )) !=-1 ) {switch (c) {
Signature · 1 line
2.17.1
Cyril Hrubis
AppliedPATCH 1/1 cpuset_hotplug: fix cpuset_list_compute
Applied, thanks.
Signature · 2 lines
Cyril Hrubis [email protected]