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>
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'},
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;