From: Ján Tomko Date: Tue, 12 Feb 2019 10:42:36 +0000 (+0100) Subject: virsh: do not assign negative values to niothreads X-Git-Tag: v5.1.0-rc1~103 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4834c9a4bd1527adc4c54eea9aafe065d327a9a3;p=thirdparty%2Flibvirt.git virsh: do not assign negative values to niothreads Use a temporary 'rc' variable to avoid comparing signed and unsigned integers in the cleanup section. Bug introduced by commit 3072ded which added the comparison against the unsigned 'i'. Also make niothreads size_t to mark that it should be unsigned. Signed-off-by: Ján Tomko Reviewed-by: John Ferlan --- diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index a1c09abf71..de19f5b6fe 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -7531,7 +7531,7 @@ cmdIOThreadInfo(vshControl *ctl, const vshCmd *cmd) bool config = vshCommandOptBool(cmd, "config"); bool live = vshCommandOptBool(cmd, "live"); bool current = vshCommandOptBool(cmd, "current"); - int niothreads = 0; + size_t niothreads = 0; virDomainIOThreadInfoPtr *info; size_t i; int maxcpu; @@ -7539,6 +7539,7 @@ cmdIOThreadInfo(vshControl *ctl, const vshCmd *cmd) virshControlPtr priv = ctl->privData; vshTablePtr table = NULL; bool ret = false; + int rc; VSH_EXCLUSIVE_OPTIONS_VAR(current, live); VSH_EXCLUSIVE_OPTIONS_VAR(current, config); @@ -7554,10 +7555,11 @@ cmdIOThreadInfo(vshControl *ctl, const vshCmd *cmd) if ((maxcpu = virshNodeGetCPUCount(priv->conn)) < 0) goto cleanup; - if ((niothreads = virDomainGetIOThreadInfo(dom, &info, flags)) < 0) { + if ((rc = virDomainGetIOThreadInfo(dom, &info, flags)) < 0) { vshError(ctl, _("Unable to get domain IOThreads information")); goto cleanup; } + niothreads = rc; if (niothreads == 0) { ret = true;