Skip to contentSkip to conversation

tools/xl: Fix build error following c/s f52fbcf7

PATCH In review Andrew Cooper 3 participants 4 messages Jul 9, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/xl: Fix build error following c/s f52fbcf7

CentOS7 complains that 'ret' might be unused, and indeed this is the case for xl psr-hwinfo --cat.

The logic for selecting which information to print was rather awkward. Introduce a new 'all' which default to true, and is cleared if specific options are selected. This allows for a far more clear logic when choosing whether to print information or not.

CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
CC Chao Peng <[email protected]>

---
NB: Only compile tested.

---
 tools/libxl/xl_cmdimpl.c |   20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)
tools/libxl/xl_cmdimpl.c +6 -14
index eeb3b90..877165a 100644
@@ -8426,8 +8426,8 @@ int main_psr_cat_show(int argc, char **argv)
 
 int main_psr_hwinfo(int argc, char **argv)
 {
-    int opt, ret;
-    int cmt = 0, cat = 0;
+    int opt, ret = 0;
+    bool all = true, cmt = false, cat = false;
     static struct option opts[] = {
         {"cmt", 0, 0, 'm'},
         {"cat", 0, 0, 'a'},
@@ -8437,25 +8437,17 @@ int main_psr_hwinfo(int argc, char **argv)
 
     SWITCH_FOREACH_OPT(opt, "ma", opts, "psr-hwinfo", 0) {
     case 'm':
-        cmt = 1;
+        all = false; cmt = true;
         break;
     case 'a':
-        cat = 1;
+        all = false; cat = true;
         break;
     }
 
-    if (!(cmt | cat)) {
-        cmt = 1;
-        cat = 1;
-    }
-
-    if (cmt)
+    if (!ret && (all || cmt))
         ret = psr_cmt_hwinfo();
 
-    if (ret)
-        return ret;
-
-    if (cat)
+    if (!ret && (all || cat))
         ret = psr_cat_hwinfo();
 
     return ret;
Signature · 1 line
1.7.10.4
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Andrew Cooper

CentOS7 complains that 'ret' might be unused, and indeed this is the case for xl psr-hwinfo --cat.

The logic for selecting which information to print was rather awkward. Introduce a new 'all' which default to true, and is cleared if specific options are selected. This allows for a far more clear logic when choosing whether to print information or not.

I'll wait a bit before applying to give Chao a chance to have a look.

Quoted 55 lines
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
CC Chao Peng <[email protected]>

---
NB: Only compile tested.

---
 tools/libxl/xl_cmdimpl.c |   20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)
tools/libxl/xl_cmdimpl.c +6 -14
index eeb3b90..877165a 100644
@@ -8426,8 +8426,8 @@ int main_psr_cat_show(int argc, char **argv)
 
 int main_psr_hwinfo(int argc, char **argv)
 {
-    int opt, ret;
-    int cmt = 0, cat = 0;
+    int opt, ret = 0;
+    bool all = true, cmt = false, cat = false;
     static struct option opts[] = {
         {"cmt", 0, 0, 'm'},
         {"cat", 0, 0, 'a'},
@@ -8437,25 +8437,17 @@ int main_psr_hwinfo(int argc, char **argv)
 
     SWITCH_FOREACH_OPT(opt, "ma", opts, "psr-hwinfo", 0) {
     case 'm':
-        cmt = 1;
+        all = false; cmt = true;
         break;
     case 'a':
-        cat = 1;
+        all = false; cat = true;
         break;
     }
 
-    if (!(cmt | cat)) {
-        cmt = 1;
-        cat = 1;
-    }
-
-    if (cmt)
+    if (!ret && (all || cmt))
         ret = psr_cmt_hwinfo();
 
-    if (ret)
-        return ret;
-
-    if (cat)
+    if (!ret && (all || cat))
         ret = psr_cat_hwinfo();
 
     return ret;
#2 lore raw
Quoted 9 lines · Ian Campbell
Quoted 8 lines · Andrew Cooper

CentOS7 complains that 'ret' might be unused, and indeed this is the case for xl psr-hwinfo --cat.

The logic for selecting which information to print was rather awkward. Introduce a new 'all' which default to true, and is cleared if specific options are selected. This allows for a far more clear logic when choosing whether to print information or not.

Quoted 5 lines
Quoted 1 line

I'll wait a bit before applying to give Chao a chance to have a look.

Thanks and I verified it successfully on my psr-enabled box.

Chao

Quoted 5 lines
Quoted 5 lines
CC Ian Jackson <[email protected]>
CC Wei Liu <[email protected]>
CC Chao Peng <[email protected]>
Tested-by Chao Peng
#3 lore raw
Quoted 10 lines · Chao Peng
Quoted 9 lines · Ian Campbell
Quoted 8 lines · Andrew Cooper

CentOS7 complains that 'ret' might be unused, and indeed this is the case for xl psr-hwinfo --cat.

The logic for selecting which information to print was rather awkward. Introduce a new 'all' which default to true, and is cleared if specific options are selected. This allows for a far more clear logic when choosing whether to print information or not.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

I'll wait a bit before applying to give Chao a chance to have a look.

Thanks and I verified it successfully on my psr-enabled box.

Thanks. I converted this into a

and have applied.