]> xenbits.xensource.com Git - libvirt.git/commitdiff
Use g_strdup instead of VIR_STRDUP everywhere
authorJán Tomko <jtomko@redhat.com>
Sun, 20 Oct 2019 11:49:46 +0000 (13:49 +0200)
committerJán Tomko <jtomko@redhat.com>
Mon, 21 Oct 2019 10:51:59 +0000 (12:51 +0200)
Replace all occurrences of
  if (VIR_STRDUP(a, b) < 0)
     /* effectively dead code */
with:
  a = g_strdup(b);

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
13 files changed:
src/admin/admin_server_dispatch.c
src/hyperv/hyperv_driver.c
src/hyperv/hyperv_util.c
src/libvirt-admin.c
src/libvirt.c
src/openvz/openvz_conf.c
src/openvz/openvz_driver.c
src/phyp/phyp_driver.c
src/vmware/vmware_conf.c
src/vmware/vmware_driver.c
src/vmx/vmx.c
src/vz/vz_driver.c
src/vz/vz_sdk.c

index e56da3ba9ff8d67283b08511ce1a560338bb8d2d..0956084301e78a67ccc70a9536c7b07cb7010cb4 100644 (file)
@@ -139,8 +139,7 @@ static int G_GNUC_WARN_UNUSED_RESULT
 make_nonnull_server(admin_nonnull_server *srv_dst,
                     virNetServerPtr srv_src)
 {
-    if (VIR_STRDUP(srv_dst->name, virNetServerGetName(srv_src)) < 0)
-        return -1;
+    srv_dst->name = g_strdup(virNetServerGetName(srv_src));
     return 0;
 }
 
index d69542b5006e5ec3392b293976c7223ad1539834..542253b8b83e8c15b3f93d6f3b5ea09abecbf28b 100644 (file)
@@ -149,8 +149,7 @@ hypervConnectOpen(virConnectPtr conn, virConnectAuthPtr auth,
 
     /* Request credentials */
     if (conn->uri->user != NULL) {
-        if (VIR_STRDUP(username, conn->uri->user) < 0)
-            goto cleanup;
+        username = g_strdup(conn->uri->user);
     } else {
         if (!(username = virAuthGetUsername(conn, auth, "hyperv",
                                             "administrator",
@@ -846,13 +845,10 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
         return NULL;
     }
 
-    if (VIR_STRDUP(def->name, computerSystem->data.common->ElementName) < 0)
-        goto cleanup;
+    def->name = g_strdup(computerSystem->data.common->ElementName);
 
     if (priv->wmiVersion == HYPERV_WMI_VERSION_V1) {
-        if (VIR_STRDUP(def->description,
-                       virtualSystemSettingData->data.v1->Notes) < 0)
-            goto cleanup;
+        def->description = g_strdup(virtualSystemSettingData->data.v1->Notes);
     } else if (priv->wmiVersion == HYPERV_WMI_VERSION_V2 &&
                virtualSystemSettingData->data.v2->Notes.data != NULL) {
         char **notes = (char **)virtualSystemSettingData->data.v2->Notes.data;
@@ -935,8 +931,7 @@ hypervConnectListDefinedDomains(virConnectPtr conn, char **const names, int maxn
 
     for (computerSystem = computerSystemList; computerSystem != NULL;
          computerSystem = computerSystem->next) {
-        if (VIR_STRDUP(names[count], computerSystem->data.common->ElementName) < 0)
-            goto cleanup;
+        names[count] = g_strdup(computerSystem->data.common->ElementName);
 
         ++count;
 
index 3b8471342680a145418494695453f9f2f8f655a9..2425d6a0c6f171c4b9795cd8af4b948d499961fb 100644 (file)
@@ -54,8 +54,7 @@ hypervParseUri(hypervParsedUri **parsedUri, virURIPtr uri)
         if (STRCASEEQ(queryParam->name, "transport")) {
             VIR_FREE((*parsedUri)->transport);
 
-            if (VIR_STRDUP((*parsedUri)->transport, queryParam->value) < 0)
-                goto cleanup;
+            (*parsedUri)->transport = g_strdup(queryParam->value);
 
             if (STRNEQ((*parsedUri)->transport, "http") &&
                 STRNEQ((*parsedUri)->transport, "https")) {
index 93c73615e3324eb33442d219b13d51ab759fa9fe..9a18ea0f8b8e0f5d8575ae22d5f778fd92da4f21 100644 (file)
@@ -112,8 +112,7 @@ getSocketPath(virURIPtr uri)
 
         if (STREQ(param->name, "socket")) {
             VIR_FREE(sock_path);
-            if (VIR_STRDUP(sock_path, param->value) < 0)
-                goto error;
+            sock_path = g_strdup(param->value);
         } else {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                            _("Unknown URI parameter '%s'"), param->name);
@@ -140,8 +139,7 @@ getSocketPath(virURIPtr uri)
         }
 
         if (legacy) {
-            if (VIR_STRDUP(sockbase, "libvirt-admin-sock") < 0)
-                goto error;
+            sockbase = g_strdup("libvirt-admin-sock");
         } else {
             if (virAsprintf(&sockbase, "%s-admin-sock", uri->scheme) < 0)
                 goto error;
@@ -177,8 +175,7 @@ virAdmGetDefaultURI(virConfPtr conf, char **uristr)
 {
     const char *defname = getenv("LIBVIRT_ADMIN_DEFAULT_URI");
     if (defname && *defname) {
-        if (VIR_STRDUP(*uristr, defname) < 0)
-            return -1;
+        *uristr = g_strdup(defname);
         VIR_DEBUG("Using LIBVIRT_ADMIN_DEFAULT_URI '%s'", *uristr);
     } else {
         if (virConfGetValueString(conf, "uri_default", uristr) < 0)
@@ -194,11 +191,9 @@ virAdmGetDefaultURI(virConfPtr conf, char **uristr)
              * 'libvirtd:///session' depending on the process's EUID.
              */
             if (geteuid() == 0) {
-                if (VIR_STRDUP(*uristr, "libvirtd:///system") < 0)
-                    return -1;
+                *uristr = g_strdup("libvirtd:///system");
             } else {
-                if (VIR_STRDUP(*uristr, "libvirtd:///session") < 0)
-                    return -1;
+                *uristr = g_strdup("libvirtd:///session");
             }
         }
     }
@@ -238,8 +233,7 @@ virAdmConnectOpen(const char *name, unsigned int flags)
         goto error;
 
     if (name) {
-        if (VIR_STRDUP(uristr, name) < 0)
-            goto error;
+        uristr = g_strdup(name);
     } else {
         if (virAdmGetDefaultURI(conf, &uristr) < 0)
             goto error;
index 812cb9efde2bc89ed41c3f86ca39cccea4ece93b..33b43305a1b1f6840eacf68fd1bfd50b25017154 100644 (file)
@@ -173,10 +173,7 @@ virConnectAuthCallbackDefault(virConnectCredentialPtr cred,
         }
 
         if (cred[i].type != VIR_CRED_EXTERNAL) {
-            if (VIR_STRDUP(cred[i].result,
-                           STREQ(bufptr, "") && cred[i].defresult ?
-                           cred[i].defresult : bufptr) < 0)
-                return -1;
+            cred[i].result = g_strdup(STREQ(bufptr, "") && cred[i].defresult ? cred[i].defresult : bufptr);
             cred[i].resultlen = strlen(cred[i].result);
         }
     }
@@ -803,8 +800,7 @@ virConnectGetDefaultURI(virConfPtr conf,
     const char *defname = getenv("LIBVIRT_DEFAULT_URI");
     if (defname && *defname) {
         VIR_DEBUG("Using LIBVIRT_DEFAULT_URI '%s'", defname);
-        if (VIR_STRDUP(*name, defname) < 0)
-            goto cleanup;
+        *name = g_strdup(defname);
     } else {
         if (virConfGetValueString(conf, "uri_default", name) < 0)
             goto cleanup;
@@ -885,8 +881,7 @@ virConnectOpenInternal(const char *name,
      * if detectable.
      */
     if (name) {
-        if (VIR_STRDUP(uristr, name) < 0)
-            goto failed;
+        uristr = g_strdup(name);
     } else {
         if (virConnectGetDefaultURI(conf, &uristr) < 0)
             goto failed;
@@ -924,9 +919,8 @@ virConnectOpenInternal(const char *name,
 
         /* Avoid need for drivers to worry about NULLs, as
          * no one needs to distinguish "" vs NULL */
-        if (ret->uri->path == NULL &&
-            VIR_STRDUP(ret->uri->path, "") < 0)
-            goto failed;
+        if (ret->uri->path == NULL)
+            ret->uri->path = g_strdup("");
 
         VIR_DEBUG("Split \"%s\" to URI components:\n"
                   "  scheme %s\n"
index e5ef426329a1eafcca550e0e5045d94485bb1bca..4646308c48c8c340b5e44d2e8a5d003195cfc1f7 100644 (file)
@@ -348,8 +348,7 @@ openvzReadFSConf(virDomainDefPtr def,
             goto error;
 
         fs->type = VIR_DOMAIN_FS_TYPE_TEMPLATE;
-        if (VIR_STRDUP(fs->src->path, temp) < 0)
-            goto error;
+        fs->src->path = g_strdup(temp);
     } else {
         /* OSTEMPLATE was not found, VE was booted from a private dir directly */
         ret = openvzReadVPSConfigParam(veid, "VE_PRIVATE", &temp);
@@ -373,8 +372,7 @@ openvzReadFSConf(virDomainDefPtr def,
         VIR_FREE(veid_str);
     }
 
-    if (VIR_STRDUP(fs->dst, "/") < 0)
-        goto error;
+    fs->dst = g_strdup("/");
 
     param = "DISKSPACE";
     ret = openvzReadVPSConfigParam(veid, param, &temp);
@@ -549,8 +547,7 @@ int openvzLoadDomains(struct openvz_driver *driver)
         }
 
         def->os.type = VIR_DOMAIN_OSTYPE_EXE;
-        if (VIR_STRDUP(def->os.init, "/sbin/init") < 0)
-            goto cleanup;
+        def->os.init = g_strdup("/sbin/init");
 
         ret = openvzReadVPSConfigParam(veid, "CPUS", &temp);
         if (ret < 0) {
@@ -727,10 +724,7 @@ openvzReadConfigParam(const char *conf_file, const char *param, char **value)
         saveptr = NULL;
         if ((token = strtok_r(sf, "\"\t\n", &saveptr)) != NULL) {
             VIR_FREE(*value);
-            if (VIR_STRDUP(*value, token) < 0) {
-                err = 1;
-                break;
-            }
+            *value = g_strdup(token);
             /* keep going - last entry wins */
         }
     }
index bf399986a74e60abd1a6f32e08fb0bc9c0fdb8e6..017eec30811539fc4be560d42ad58afc6664c22c 100644 (file)
@@ -118,10 +118,8 @@ openvzDomainDefPostParse(virDomainDefPtr def,
                          void *parseOpaque G_GNUC_UNUSED)
 {
     /* fill the init path */
-    if (def->os.type == VIR_DOMAIN_OSTYPE_EXE && !def->os.init) {
-        if (VIR_STRDUP(def->os.init, "/sbin/init") < 0)
-            return -1;
-    }
+    if (def->os.type == VIR_DOMAIN_OSTYPE_EXE && !def->os.init)
+        def->os.init = g_strdup("/sbin/init");
 
     return 0;
 }
@@ -780,8 +778,7 @@ openvzDomainSetNetwork(virConnectPtr conn, const char *vpsid,
         /* if net is ethernet and the user has specified guest interface name,
          * let's use it; otherwise generate a new one */
         if (net->ifname_guest) {
-            if (VIR_STRDUP(guest_ifname, net->ifname_guest) < 0)
-                goto cleanup;
+            guest_ifname = g_strdup(net->ifname_guest);
         } else {
             guest_ifname = openvzGenerateContainerVethName(veid);
             if (guest_ifname == NULL) {
@@ -1507,8 +1504,7 @@ static int openvzConnectListDefinedDomains(virConnectPtr conn G_GNUC_UNUSED,
             continue;
         }
         snprintf(vpsname, sizeof(vpsname), "%d", veid);
-        if (VIR_STRDUP(names[got], vpsname) < 0)
-            goto out;
+        names[got] = g_strdup(vpsname);
         got ++;
     }
 
index 4527adc670bbb677b685ead7dcc9452577bc9700..8b1d804233995b4b8858010857f7210207917220 100644 (file)
@@ -946,8 +946,7 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth,
         goto err;
 
     if (conn->uri->user != NULL) {
-        if (VIR_STRDUP(username, conn->uri->user) < 0)
-            goto err;
+        username = g_strdup(conn->uri->user);
     } else {
         if (!(username = virAuthGetUsername(conn, auth, "ssh", NULL,
                                             conn->uri->server)))
@@ -1124,9 +1123,7 @@ phypConnectOpen(virConnectPtr conn,
 
     if (conn->uri->path[0] != '\0') {
         /* need to shift one byte in order to remove the first "/" of URI component */
-        if (VIR_STRDUP(managed_system,
-                       conn->uri->path + (conn->uri->path[0] == '/')) < 0)
-            goto failure;
+        managed_system = g_strdup(conn->uri->path + (conn->uri->path[0] == '/'));
 
         /* here we are handling only the first component of the path,
          * so skipping the second:
@@ -1465,8 +1462,7 @@ phypGetBackingDevice(virConnectPtr conn, const char *managed_system,
         else
             goto cleanup;
 
-        if (VIR_STRDUP(backing_device, char_ptr) < 0)
-            goto cleanup;
+        backing_device = g_strdup(char_ptr);
     } else {
         backing_device = g_steal_pointer(&ret);
     }
@@ -2228,8 +2224,7 @@ phypStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags)
         goto cleanup;
     }
 
-    if (VIR_STRDUP(voldef.key, vol->key) < 0)
-        goto cleanup;
+    voldef.key = g_strdup(vol->key);
 
     voldef.type = VIR_STORAGE_POOL_LOGICAL;
 
@@ -2338,8 +2333,7 @@ phypStoragePoolListVolumes(virStoragePoolPtr pool, char **const volumes,
 
             if (char_ptr) {
                 *char_ptr = '\0';
-                if (VIR_STRDUP(volumes[got++], volumes_list) < 0)
-                    goto cleanup;
+                volumes[got++] = g_strdup(volumes_list);
                 char_ptr++;
                 volumes_list = char_ptr;
             } else {
@@ -2532,8 +2526,7 @@ phypConnectListStoragePools(virConnectPtr conn, char **const pools, int npools)
 
             if (char_ptr) {
                 *char_ptr = '\0';
-                if (VIR_STRDUP(pools[got++], storage_pools) < 0)
-                    goto cleanup;
+                pools[got++] = g_strdup(storage_pools);
                 char_ptr++;
                 storage_pools = char_ptr;
             } else {
@@ -2985,8 +2978,7 @@ phypConnectListInterfaces(virConnectPtr conn, char **const names, int nnames)
 
         if (char_ptr) {
             *char_ptr = '\0';
-            if (VIR_STRDUP(names[got++], networks) < 0)
-                goto cleanup;
+            names[got++] = g_strdup(networks);
             char_ptr++;
             networks = char_ptr;
         } else {
@@ -3146,8 +3138,7 @@ phypConnectListDefinedDomains(virConnectPtr conn, char **const names, int nnames
 
             if (char_ptr) {
                 *char_ptr = '\0';
-                if (VIR_STRDUP(names[got++], domains) < 0)
-                    goto cleanup;
+                names[got++] = g_strdup(domains);
                 char_ptr++;
                 domains = char_ptr;
             } else {
index 207af8fe81d2ac597d96aee065655915b7339311..8707f842ad3224097f23a790bd62e4712d86a95d 100644 (file)
@@ -175,8 +175,7 @@ vmwareLoadDomains(struct vmware_driver *driver)
 
         pDomain = vm->privateData;
 
-        if (VIR_STRDUP(pDomain->vmxPath, vmxPath) < 0)
-            goto cleanup;
+        pDomain->vmxPath = g_strdup(vmxPath);
 
         vmwareDomainConfigDisplay(pDomain, vmdef);
 
@@ -354,14 +353,10 @@ vmwareParsePath(const char *path, char **directory, char **filename)
 
         if (VIR_STRNDUP(*directory, path, separator - path - 1) < 0)
             goto error;
-        if (VIR_STRDUP(*filename, separator) < 0) {
-            VIR_FREE(*directory);
-            goto error;
-        }
+        *filename = g_strdup(separator);
 
     } else {
-        if (VIR_STRDUP(*filename, path) < 0)
-            goto error;
+        *filename = g_strdup(path);
     }
 
     return 0;
index 912827a921112dae019a2289a4f3e003547416f9..83974531d5a1c648fa1a54bfecd36c50a1f8c0e8 100644 (file)
@@ -447,8 +447,7 @@ vmwareDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int fla
         goto cleanup;
 
     pDomain = vm->privateData;
-    if (VIR_STRDUP(pDomain->vmxPath, vmxPath) < 0)
-        goto cleanup;
+    pDomain->vmxPath = g_strdup(vmxPath);
 
     vmwareDomainConfigDisplay(pDomain, vmdef);
 
@@ -708,8 +707,7 @@ vmwareDomainCreateXML(virConnectPtr conn, const char *xml,
         goto cleanup;
 
     pDomain = vm->privateData;
-    if (VIR_STRDUP(pDomain->vmxPath, vmxPath) < 0)
-        goto cleanup;
+    pDomain->vmxPath = g_strdup(vmxPath);
 
     vmwareDomainConfigDisplay(pDomain, vmdef);
     vmdef = NULL;
index c9a80ba35d49575000b5b5b0419bcb0e629fba61..0d1d87bac606794a144428e0a69b605611182fe1 100644 (file)
@@ -1085,8 +1085,7 @@ virVMXHandleLegacySCSIDiskDriverName(virDomainDefPtr def,
     if (disk->bus != VIR_DOMAIN_DISK_BUS_SCSI || !driver)
         return 0;
 
-    if (VIR_STRDUP(copy, driver) < 0)
-        return -1;
+    copy = g_strdup(driver);
     tmp = copy;
 
     for (; *tmp != '\0'; ++tmp)
@@ -1812,13 +1811,15 @@ virVMXParseConfig(virVMXContext *ctx,
     if (ctx->datacenterPath || ctx->moref) {
         struct virVMXDomainDefNamespaceData *nsdata = NULL;
 
-        if (VIR_ALLOC(nsdata) < 0 ||
-            VIR_STRDUP(nsdata->datacenterPath, ctx->datacenterPath) < 0 ||
-            VIR_STRDUP(nsdata->moref, ctx->moref) < 0) {
+        if (VIR_ALLOC(nsdata) < 0) {
             virVMXDomainDefNamespaceFree(nsdata);
             goto cleanup;
         }
 
+        nsdata->datacenterPath = g_strdup(ctx->datacenterPath);
+
+        nsdata->moref = g_strdup(ctx->moref);
+
         def->ns = *virDomainXMLOptionGetNamespace(xmlopt);
         def->namespaceData = nsdata;
     }
@@ -2839,8 +2840,7 @@ virVMXParseSerial(virVMXContext *ctx, virConfPtr conf, int port,
             goto cleanup;
         }
 
-        if (VIR_STRDUP((*def)->source->data.tcp.host, parsedUri->server) < 0)
-            goto cleanup;
+        (*def)->source->data.tcp.host = g_strdup(parsedUri->server);
 
         if (virAsprintf(&(*def)->source->data.tcp.service, "%d",
                         parsedUri->port) < 0)
index 76b23788b82ee15db71ca03f808c0112250e4f94..5b54f83b22341bfad262fc8714d48d44ab2e0305 100644 (file)
@@ -3015,8 +3015,7 @@ vzDomainMigratePrepare3Params(virConnectPtr conn,
 
     if (dname) {
         VIR_FREE(def->name);
-        if (VIR_STRDUP(def->name, dname) < 0)
-            goto cleanup;
+        def->name = g_strdup(dname);
     }
 
     if (virDomainMigratePrepare3ParamsEnsureACL(conn, def) < 0)
index 68284d53f7663444a6dd50523ae3c599b8b2087a..e7c1676df909a39bca1d875c937ee268be97a1ab 100644 (file)
@@ -501,8 +501,7 @@ prlsdkUUIDParse(const char *uuidstr, unsigned char *uuid)
     virCheckNonNullArgGoto(uuidstr, error);
     virCheckNonNullArgGoto(uuid, error);
 
-    if (VIR_STRDUP(tmp, uuidstr) < 0)
-        goto error;
+    tmp = g_strdup(uuidstr);
 
     tmp[strlen(tmp) - 1] = '\0';
 
@@ -774,10 +773,8 @@ prlsdkGetFSInfo(PRL_HANDLE prldisk,
         fs->type = VIR_DOMAIN_FS_TYPE_VOLUME;
         if (VIR_ALLOC(fs->src->srcpool) < 0)
             goto cleanup;
-        if (VIR_STRDUP(fs->src->srcpool->pool, matches[1]) < 0)
-            goto cleanup;
-        if (VIR_STRDUP(fs->src->srcpool->volume, matches[2]) < 0)
-            goto cleanup;
+        fs->src->srcpool->pool = g_strdup(matches[1]);
+        fs->src->srcpool->volume = g_strdup(matches[2]);
         VIR_FREE(buf);
     } else {
         fs->type = VIR_DOMAIN_FS_TYPE_FILE;
@@ -1054,9 +1051,7 @@ prlsdkGetNetInfo(PRL_HANDLE netAdapter, virDomainNetDefPtr net, bool isCt)
          * always up */
         net->linkstate = VIR_DOMAIN_NET_INTERFACE_LINK_STATE_UP;
         net->type = VIR_DOMAIN_NET_TYPE_NETWORK;
-        if (VIR_STRDUP(net->data.network.name,
-                       PARALLELS_DOMAIN_ROUTED_NETWORK_NAME) < 0)
-            goto cleanup;
+        net->data.network.name = g_strdup(PARALLELS_DOMAIN_ROUTED_NETWORK_NAME);
         return 0;
     }
 
@@ -1078,9 +1073,7 @@ prlsdkGetNetInfo(PRL_HANDLE netAdapter, virDomainNetDefPtr net, bool isCt)
 
     if (emulatedType == PNA_ROUTED) {
         net->type = VIR_DOMAIN_NET_TYPE_NETWORK;
-        if (VIR_STRDUP(net->data.network.name,
-                       PARALLELS_DOMAIN_ROUTED_NETWORK_NAME) < 0)
-            goto cleanup;
+        net->data.network.name = g_strdup(PARALLELS_DOMAIN_ROUTED_NETWORK_NAME);
     } else {
         char *netid =
               prlsdkGetStringParamVar(PrlVmDevNet_GetVirtualNetworkId,
@@ -1224,8 +1217,7 @@ prlsdkGetSerialInfo(PRL_HANDLE serialPort, virDomainChrDefPtr chr)
             goto cleanup;
         if (!(uri = virURIParse(uristr)))
             goto cleanup;
-        if (VIR_STRDUP(chr->source->data.tcp.host, uri->server) < 0)
-            goto cleanup;
+        chr->source->data.tcp.host = g_strdup(uri->server);
         if (virAsprintf(&chr->source->data.tcp.service, "%d", uri->port) < 0)
             goto cleanup;
         chr->source->data.tcp.listen = socket_mode == PSP_SERIAL_SOCKET_SERVER;
@@ -1236,12 +1228,10 @@ prlsdkGetSerialInfo(PRL_HANDLE serialPort, virDomainChrDefPtr chr)
             goto cleanup;
         if (!(uri = virURIParse(uristr)))
             goto cleanup;
-        if (VIR_STRDUP(chr->source->data.udp.bindHost, uri->server) < 0)
-            goto cleanup;
+        chr->source->data.udp.bindHost = g_strdup(uri->server);
         if (virAsprintf(&chr->source->data.udp.bindService, "%d", uri->port) < 0)
             goto cleanup;
-        if (VIR_STRDUP(chr->source->data.udp.connectHost, uri->server) < 0)
-            goto cleanup;
+        chr->source->data.udp.connectHost = g_strdup(uri->server);
         if (virAsprintf(&chr->source->data.udp.connectService, "%d", uri->port) < 0)
             goto cleanup;
         break;
@@ -1526,8 +1516,7 @@ prlsdkConvertDomainType(PRL_HANDLE sdkdom, virDomainDefPtr def)
         break;
     case PVT_CT:
         def->os.type = VIR_DOMAIN_OSTYPE_EXE;
-        if (VIR_STRDUP(def->os.init, "/sbin/init") < 0)
-            return -1;
+        def->os.init = g_strdup("/sbin/init");
         break;
     default:
         virReportError(VIR_ERR_INTERNAL_ERROR,