It's a good thing the latter while loop condition
could never be true -- otherwise it'd be an infloop.
From 319fd4536555d68316a2cb7967f1093be8de3945 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Mon, 17 May 2010 22:50:21 +0200
Subject: [PATCH] (qemuTeardownDiskCgroup): avoid dead code
* src/qemu/qemu_driver.c (qemuTeardownDiskCgroup): Convert
bogus while...while loop to the intended do...while loop.
---
src/qemu/qemu_driver.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 16a9646..3e44407 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2981,65 +2981,65 @@ static int qemuSetupDiskCgroup(virCgroupPtr cgroup,
goto cleanup;
}
}
memset(&meta, 0, sizeof(meta));
rc = virStorageFileGetMetadata(path, &meta);
if (path != disk->src)
VIR_FREE(path);
path = NULL;
if (rc < 0)
goto cleanup;
path = meta.backingStore;
} while (path != NULL);
ret = 0;
cleanup:
return ret;
}
static int qemuTeardownDiskCgroup(virCgroupPtr cgroup,
virDomainObjPtr vm,
virDomainDiskDefPtr disk)
{
char *path = disk->src;
int ret = -1;
- while (path != NULL) {
+ do {
virStorageFileMetadata meta;
int rc;
VIR_DEBUG("Process path %s for disk", path);
rc = virCgroupDenyDevicePath(cgroup, path);
if (rc != 0) {
/* Get this for non-block devices */
if (rc == -EINVAL) {
VIR_DEBUG("Ignoring EINVAL for %s", path);
} else {
virReportSystemError(-rc,
_("Unable to deny device %s for %s"),
path, vm->def->name);
if (path != disk->src)
VIR_FREE(path);
goto cleanup;
}
}
memset(&meta, 0, sizeof(meta));
rc = virStorageFileGetMetadata(path, &meta);
if (path != disk->src)
VIR_FREE(path);
path = NULL;
if (rc < 0)
goto cleanup;
path = meta.backingStore;
} while (path != NULL);
--
1.7.1.250.g7d1e8