From: Andrew Cooper Subject: [PATCH] tools/xl: Fix build error following c/s f52fbcf7 Date: Thu, 9 Jul 2015 11:36:22 +0100 Message-ID: <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: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Xen-devel Cc: Andrew Cooper , Chao Peng , Ian Jackson , Ian Campbell , Wei Liu List-Id: xen-devel@lists.xenproject.org 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 CC: Ian Campbell 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; -- 1.7.10.4