tools/xl: Fix build error following c/s f52fbcf7
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 9 Jul 2015 10:36:22 +0000 (11:36 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Thu, 9 Jul 2015 13:57:06 +0000 (14:57 +0100)
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.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Chao Peng <chao.p.peng@linux.intel.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Tested-by: Chao Peng <chao.p.peng@linux.intel.com>
tools/libxl/xl_cmdimpl.c

index 609cf04af94f93ee2dd091c7f25cdb8af9d9aa45..971209cc223f85014b9046123d8f6cac9bf08f46 100644 (file)
@@ -8442,8 +8442,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'},
@@ -8453,25 +8453,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;