Skip to contentSkip to conversation

cpuset_hotplug: fix cpuset_list_compute

PATCH New Cristian Marussi 2 participants 5 messages Nov 14, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 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 helper cpuset_list_compute was always failing because it was improperly handling getopt retval.

---
 .../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
index 1b55f4b30..b9f176af4 100644
@@ -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
#1 lore raw

PATCH 2/2 cpuset_list_compute fix exit value

Internal usage() helper was meant to use a custom exit value provided by the caller, so use it.

---
 .../cpuset/cpuset_hotplug_test/cpuset_list_compute.c            | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/controllers/cpuset/cpuset_hotplug_test/cpuset_list_compute.c +1 -1
index b9f176af4..1c66b863a 100644
@@ -24,7 +24,7 @@ int convert;
 static void usage(char *prog_name, int status)
 {
 	fprintf(stderr, USAGE, prog_name);
-	exit(1);
+	exit(status);
 }
 
 static void checkopt(int argc, char **argv)
Signature · 1 line
2.17.1
#3 lore raw

PATCH 1/2 cpuset_hotplug: fix cpuset_list_compute

In reply to Cristian Marussi

Hi!

Quoted 11 lines

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 helper cpuset_list_compute was always failing because it was improperly handling getopt retval.

It's working on intel, but I suppose that it overflows on arm since char is smaller than int there. It would be a bit better if something along these lines was written here. Otherwise the patch itself looks good.

Quoted 25 lines
---
 .../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
index 1b55f4b30..b9f176af4 100644
@@ -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 · 5 lines
2.17.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 2 lines
Cyril Hrubis
[email protected]
#4 lore raw

PATCH 1/2 cpuset_hotplug: fix cpuset_list_compute

Hi

Quoted 10 lines · Cyril Hrubis

Hi!

Quoted 9 lines

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: ).

Quoted 7 lines
Quoted 2 lines

It turned out that helper cpuset_list_compute was always failing because it was improperly handling getopt retval.

It's working on intel, but I suppose that it overflows on arm since char is smaller than int there. It would be a bit better if something along these lines was written here. Otherwise the patch itself looks good.

Fine I will add some more explanation.

Thanks

Cristian

Quoted 26 lines
Quoted 25 lines
---
  .../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
index 1b55f4b30..b9f176af4 100644
@@ -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 · 5 lines
2.17.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp