From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: Re: [PATCH] tools/xl: Fix build error following c/s f52fbcf7 Date: Thu, 9 Jul 2015 11:47:43 +0100 Message-ID: <1436438863.23508.107.camel@citrix.com> References: <1436438182-16305-1-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1436438182-16305-1-git-send-email-andrew.cooper3@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Andrew Cooper Cc: Wei Liu , Ian Jackson , Chao Peng , Xen-devel List-Id: xen-devel@lists.xenproject.org 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 Acked-by: Ian Campbell I'll wait a bit before applying to give Chao a chance to have a look. > CC: Ian Jackson > CC: Wei Liu > CC: Chao Peng > > --- > 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;