提交 d63f9164 编写于 作者: J Ján Tomko

Use g_strdup instead of VIR_STRDUP everywhere

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