* [PATCH] tools/xl: Fix build error following c/s f52fbcf7
@ 2015-07-09 10:36 Andrew Cooper
2015-07-09 10:47 ` Ian Campbell
0 siblings, 1 reply; 4+ messages in thread
From: Andrew Cooper @ 2015-07-09 10:36 UTC (permalink / raw)
To: Xen-devel; +Cc: Andrew Cooper, Chao Peng, Ian Jackson, Ian Campbell, Wei Liu
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>
---
NB: Only compile tested.
---
tools/libxl/xl_cmdimpl.c | 20 ++++++--------------
1 file changed, 6 insertions(+), 14 deletions(-)
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index eeb3b90..877165a 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -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;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] tools/xl: Fix build error following c/s f52fbcf7
2015-07-09 10:36 [PATCH] tools/xl: Fix build error following c/s f52fbcf7 Andrew Cooper
@ 2015-07-09 10:47 ` Ian Campbell
2015-07-09 13:31 ` Chao Peng
0 siblings, 1 reply; 4+ messages in thread
From: Ian Campbell @ 2015-07-09 10:47 UTC (permalink / raw)
To: Andrew Cooper; +Cc: Wei Liu, Ian Jackson, Chao Peng, Xen-devel
On Thu, 2015-07-09 at 11:36 +0100, Andrew Cooper wrote:
> 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>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
I'll wait a bit before applying to give Chao a chance to have a look.
> CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
> CC: Wei Liu <wei.liu2@citrix.com>
> CC: Chao Peng <chao.p.peng@linux.intel.com>
>
> ---
> NB: Only compile tested.
> ---
> tools/libxl/xl_cmdimpl.c | 20 ++++++--------------
> 1 file changed, 6 insertions(+), 14 deletions(-)
>
> diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
> index eeb3b90..877165a 100644
> --- a/tools/libxl/xl_cmdimpl.c
> +++ b/tools/libxl/xl_cmdimpl.c
> @@ -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;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] tools/xl: Fix build error following c/s f52fbcf7
2015-07-09 10:47 ` Ian Campbell
@ 2015-07-09 13:31 ` Chao Peng
2015-07-09 14:20 ` Ian Campbell
0 siblings, 1 reply; 4+ messages in thread
From: Chao Peng @ 2015-07-09 13:31 UTC (permalink / raw)
To: Ian Campbell, Andrew Cooper; +Cc: Ian Jackson, Wei Liu, Xen-devel
On Thu, Jul 09, 2015 at 11:47:43AM +0100, Ian Campbell wrote:
> On Thu, 2015-07-09 at 11:36 +0100, Andrew Cooper wrote:
> > 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>
>
> Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
>
> 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
>
> > CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
> > CC: Wei Liu <wei.liu2@citrix.com>
> > CC: Chao Peng <chao.p.peng@linux.intel.com>
> >
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] tools/xl: Fix build error following c/s f52fbcf7
2015-07-09 13:31 ` Chao Peng
@ 2015-07-09 14:20 ` Ian Campbell
0 siblings, 0 replies; 4+ messages in thread
From: Ian Campbell @ 2015-07-09 14:20 UTC (permalink / raw)
To: Chao Peng; +Cc: Andrew Cooper, Ian Jackson, Wei Liu, Xen-devel
On Thu, 2015-07-09 at 21:31 +0800, Chao Peng wrote:
> On Thu, Jul 09, 2015 at 11:47:43AM +0100, Ian Campbell wrote:
> > On Thu, 2015-07-09 at 11:36 +0100, Andrew Cooper wrote:
> > > 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>
> >
> > Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
> >
> > 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
Tested-by: Chao Peng <chao.p.peng@linux.intel.com>
and have applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-07-09 14:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-09 10:36 [PATCH] tools/xl: Fix build error following c/s f52fbcf7 Andrew Cooper
2015-07-09 10:47 ` Ian Campbell
2015-07-09 13:31 ` Chao Peng
2015-07-09 14:20 ` Ian Campbell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).