[libvirt] [PATCH] cmdPerf: Display enabled/disabled message on perf event enable/disable

Currently, the code to display enabled/disabled message is a dead code as its misplaced in if block instead of else. This patch fixes that issue. Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com> --- tools/virsh-domain.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 3a6fa5c..624a36a 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -8891,18 +8891,19 @@ cmdPerf(vshControl *ctl, const vshCmd *cmd) vshError(ctl, "%s", _("Unable to get perf events")); goto cleanup; } - for (i = 0; i < nparams; i++) { - if (params[i].type == VIR_TYPED_PARAM_BOOLEAN && - params[i].value.b) { - vshPrint(ctl, "%-15s: %s\n", params[i].field, _("enabled")); - } else { - vshPrint(ctl, "%-15s: %s\n", params[i].field, _("disabled")); - } - } } else { if (virDomainSetPerfEvents(dom, params, nparams, flags) != 0) { vshError(ctl, "%s", _("Unable to enable/disable perf events")); goto cleanup; + } else { + for (i = 0; i < nparams; i++) { + if (params[i].type == VIR_TYPED_PARAM_BOOLEAN && + params[i].value.b) { + vshPrint(ctl, "%-15s: %s\n", params[i].field, _("enabled")); + } else { + vshPrint(ctl, "%-15s: %s\n", params[i].field, _("disabled")); + } + } } } -- 1.9.3

I realized after sending the patch that the code I mentioned as "dead code" is not a dead code. I have sent a v2 for the same. On Wed, Dec 28, 2016 at 3:19 PM, Nitesh Konkar < niteshkonkar.libvirt@gmail.com> wrote:
Currently, the code to display enabled/disabled message is a dead code as its misplaced in if block instead of else. This patch fixes that issue.
Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com> --- tools/virsh-domain.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 3a6fa5c..624a36a 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -8891,18 +8891,19 @@ cmdPerf(vshControl *ctl, const vshCmd *cmd) vshError(ctl, "%s", _("Unable to get perf events")); goto cleanup; } - for (i = 0; i < nparams; i++) { - if (params[i].type == VIR_TYPED_PARAM_BOOLEAN && - params[i].value.b) { - vshPrint(ctl, "%-15s: %s\n", params[i].field, _("enabled")); - } else { - vshPrint(ctl, "%-15s: %s\n", params[i].field, _("disabled")); - } - } } else { if (virDomainSetPerfEvents(dom, params, nparams, flags) != 0) { vshError(ctl, "%s", _("Unable to enable/disable perf events")); goto cleanup; + } else { + for (i = 0; i < nparams; i++) { + if (params[i].type == VIR_TYPED_PARAM_BOOLEAN && + params[i].value.b) { + vshPrint(ctl, "%-15s: %s\n", params[i].field, _("enabled")); + } else { + vshPrint(ctl, "%-15s: %s\n", params[i].field, _("disabled")); + } + } } }
-- 1.9.3
participants (1)
-
Nitesh Konkar