]> xenbits.xensource.com Git - libvirt.git/commitdiff
ch: virCHProcessSetupIOThreads: use correct type for return value
authorJán Tomko <jtomko@redhat.com>
Wed, 2 Feb 2022 16:26:48 +0000 (17:26 +0100)
committerJán Tomko <jtomko@redhat.com>
Thu, 3 Feb 2022 13:15:04 +0000 (14:15 +0100)
virCHMonitorGetIOThreads returns an int, not size_t.

Also return early if it's negative, because promoting it to
an unsigned type in the for loop condition could lead to
an infinte loop.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
src/ch/ch_process.c

index 414e203154e8321ccd92994aeaf36d722ec27cac..e4313d100889415c80ef86b738b91dfae8b92aa4 100644 (file)
@@ -327,9 +327,11 @@ virCHProcessSetupIOThreads(virDomainObj *vm)
     virCHDomainObjPrivate *priv = vm->privateData;
     virDomainIOThreadInfo **iothreads = NULL;
     size_t i;
-    size_t  niothreads;
+    int niothreads;
+
+    if ((niothreads = virCHMonitorGetIOThreads(priv->monitor, &iothreads)) < 0)
+        return -1;
 
-    niothreads = virCHMonitorGetIOThreads(priv->monitor, &iothreads);
     for (i = 0; i < niothreads; i++) {
         VIR_DEBUG("IOThread index = %ld , tid = %d", i, iothreads[i]->iothread_id);
         if (virCHProcessSetupIOThread(vm, iothreads[i]) < 0)