openvz: Use g_strdup_printf() instead of virAsprintf()

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
Michal Privoznik 2019-10-22 15:26:14 +02:00
parent c09b0fe7a7
commit e5caed83bd
2 changed files with 9 additions and 16 deletions

View File

@ -362,8 +362,7 @@ openvzReadFSConf(virDomainDefPtr def,
if (VIR_ALLOC(fs) < 0) if (VIR_ALLOC(fs) < 0)
goto error; goto error;
if (virAsprintf(&veid_str, "%d", veid) < 0) veid_str = g_strdup_printf("%d", veid);
goto error;
fs->type = VIR_DOMAIN_FS_TYPE_MOUNT; fs->type = VIR_DOMAIN_FS_TYPE_MOUNT;
if (!(fs->src->path = virStringReplace(temp, "$VEID", veid_str))) if (!(fs->src->path = virStringReplace(temp, "$VEID", veid_str)))
@ -534,8 +533,7 @@ int openvzLoadDomains(struct openvz_driver *driver)
def->id = -1; def->id = -1;
else else
def->id = veid; def->id = veid;
if (virAsprintf(&def->name, "%i", veid) < 0) def->name = g_strdup_printf("%i", veid);
goto cleanup;
openvzGetVPSUUID(veid, uuidstr, sizeof(uuidstr)); openvzGetVPSUUID(veid, uuidstr, sizeof(uuidstr));
ret = virUUIDParse(uuidstr, def->uuid); ret = virUUIDParse(uuidstr, def->uuid);
@ -626,8 +624,7 @@ openvzWriteConfigParam(const char * conf_file, const char *param, const char *va
char *line = NULL; char *line = NULL;
size_t line_size = 0; size_t line_size = 0;
if (virAsprintf(&temp_file, "%s.tmp", conf_file)<0) temp_file = g_strdup_printf("%s.tmp", conf_file);
return -1;
fp = fopen(conf_file, "r"); fp = fopen(conf_file, "r");
if (fp == NULL) if (fp == NULL)
@ -823,9 +820,8 @@ openvzCopyDefaultConfig(int vpsid)
if (confdir == NULL) if (confdir == NULL)
goto cleanup; goto cleanup;
if (virAsprintf(&default_conf_file, "%s/ve-%s.conf-sample", confdir, default_conf_file = g_strdup_printf("%s/ve-%s.conf-sample", confdir,
configfile_value) < 0) configfile_value);
goto cleanup;
if (openvzLocateConfFile(vpsid, &conf_file, "conf") < 0) if (openvzLocateConfFile(vpsid, &conf_file, "conf") < 0)
goto cleanup; goto cleanup;
@ -855,9 +851,7 @@ openvzLocateConfFileDefault(int vpsid, char **conffile, const char *ext)
if (confdir == NULL) if (confdir == NULL)
return -1; return -1;
if (virAsprintf(conffile, "%s/%d.%s", confdir, vpsid, *conffile = g_strdup_printf("%s/%d.%s", confdir, vpsid, ext ? ext : "conf");
ext ? ext : "conf") < 0)
ret = -1;
VIR_FREE(confdir); VIR_FREE(confdir);
return ret; return ret;

View File

@ -702,7 +702,7 @@ openvzGenerateVethName(int veid, char *dev_name_ve)
if (sscanf(dev_name_ve, "%*[^0-9]%d", &ifNo) != 1) if (sscanf(dev_name_ve, "%*[^0-9]%d", &ifNo) != 1)
return NULL; return NULL;
ignore_value(virAsprintf(&ret, "veth%d.%d.", veid, ifNo)); ret = g_strdup_printf("veth%d.%d.", veid, ifNo);
return ret; return ret;
} }
@ -729,7 +729,7 @@ openvzGenerateContainerVethName(int veid)
} }
/* set new name */ /* set new name */
ignore_value(virAsprintf(&name, "eth%d", max + 1)); name = g_strdup_printf("eth%d", max + 1);
} }
VIR_FREE(temp); VIR_FREE(temp);
@ -2207,8 +2207,7 @@ openvzDomainMigratePrepare3Params(virConnectPtr dconn,
} }
} }
if (virAsprintf(uri_out, "ssh://%s", hostname) < 0) *uri_out = g_strdup_printf("ssh://%s", hostname);
goto error;
ret = 0; ret = 0;
goto done; goto done;