]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: fix a const-correctness issue
authorEric Blake <eblake@redhat.com>
Wed, 23 Nov 2011 14:26:32 +0000 (07:26 -0700)
committerEric Blake <eblake@redhat.com>
Wed, 23 Nov 2011 14:29:45 +0000 (07:29 -0700)
Generally, functions which return malloc'd strings should be typed
as 'char *', not 'const char *', to make it obvious that the caller
is responsible to free things.  free(const char *) fails to compile,
and although we have a cast embedded in VIR_FREE to work around poor
code that frees const char *, it's better to not rely on that hack.

* src/qemu/qemu_driver.c (qemuDiskPathToAlias): Change return type.
(qemuDomainBlockJobImpl): Update caller.

src/qemu/qemu_driver.c

index 98ce69560c3b585c238581760166eb656ee0142d..94fbe94a29bef8e99e26aed1b5a15f10c2bee230 100644 (file)
@@ -10565,8 +10565,9 @@ cleanup:
     return ret;
 }
 
-static const char *
-qemuDiskPathToAlias(virDomainObjPtr vm, const char *path) {
+static char *
+qemuDiskPathToAlias(virDomainObjPtr vm, const char *path)
+{
     int i;
     char *ret = NULL;
     virDomainDiskDefPtr disk;
@@ -10605,7 +10606,7 @@ qemuDomainBlockJobImpl(virDomainPtr dom, const char *path,
     virDomainObjPtr vm = NULL;
     qemuDomainObjPrivatePtr priv;
     char uuidstr[VIR_UUID_STRING_BUFLEN];
-    const char *device = NULL;
+    char *device = NULL;
     int ret = -1;
 
     qemuDriverLock(driver);