tools/xl: Fix build error following c/s f52fbcf7
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.
---
NB: Only compile tested.
--- tools/libxl/xl_cmdimpl.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-)
tools/libxl/xl_cmdimpl.c +6 -14
@@ -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
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.
Signed-off-by Andrew Cooper <[email protected]>
I'll wait a bit before applying to give Chao a chance to have a look.
Quoted 55 lines
---
NB: Only compile tested.--- tools/libxl/xl_cmdimpl.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-)tools/libxl/xl_cmdimpl.c +6
-14@@ -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;
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
Signed-off-by Andrew Cooper <[email protected]>Acked-by Ian Campbell <[email protected]>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
Ian Campbell
Tested-by Chao PengQuoted 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
Signed-off-by Andrew Cooper <[email protected]>Acked-by Ian Campbell <[email protected]>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.