mirror of https://gitee.com/openkylin/libvirt.git
locking: 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:
parent
f9d6b01262
commit
b1d58418aa
|
@ -464,11 +464,8 @@ virLockDaemonUnixSocketPaths(bool privileged,
|
|||
}
|
||||
umask(old_umask);
|
||||
|
||||
if (virAsprintf(sockfile, "%s/virtlockd-sock", rundir) < 0 ||
|
||||
virAsprintf(adminSockfile, "%s/virtlockd-admin-sock", rundir) < 0) {
|
||||
VIR_FREE(rundir);
|
||||
goto error;
|
||||
}
|
||||
*sockfile = g_strdup_printf("%s/virtlockd-sock", rundir);
|
||||
*adminSockfile = g_strdup_printf("%s/virtlockd-admin-sock", rundir);
|
||||
|
||||
VIR_FREE(rundir);
|
||||
}
|
||||
|
@ -531,8 +528,7 @@ virLockDaemonSetupLogging(virLockDaemonConfigPtr config,
|
|||
/* Define the default output. This is only applied if there was no setting
|
||||
* from either the config or the environment.
|
||||
*/
|
||||
if (virLogSetDefaultOutput("virtlockd", godaemon, privileged) < 0)
|
||||
return -1;
|
||||
virLogSetDefaultOutput("virtlockd", godaemon, privileged);
|
||||
|
||||
if (virLogGetNbOutputs() == 0)
|
||||
virLogSetOutputs(virLogGetDefaultOutput());
|
||||
|
@ -845,10 +841,7 @@ virLockDaemonExecRestartStatePath(bool privileged,
|
|||
}
|
||||
umask(old_umask);
|
||||
|
||||
if (virAsprintf(state_file, "%s/virtlockd-restart-exec.json", rundir) < 0) {
|
||||
VIR_FREE(rundir);
|
||||
goto error;
|
||||
}
|
||||
*state_file = g_strdup_printf("%s/virtlockd-restart-exec.json", rundir);
|
||||
|
||||
VIR_FREE(rundir);
|
||||
}
|
||||
|
@ -865,7 +858,7 @@ virLockDaemonGetExecRestartMagic(void)
|
|||
{
|
||||
char *ret;
|
||||
|
||||
ignore_value(virAsprintf(&ret, "%lld", (long long int)getpid()));
|
||||
ret = g_strdup_printf("%lld", (long long int)getpid());
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,10 +46,7 @@ virLockDaemonConfigFilePath(bool privileged, char **configfile)
|
|||
if (!(configdir = virGetUserConfigDirectory()))
|
||||
goto error;
|
||||
|
||||
if (virAsprintf(configfile, "%s/virtlockd.conf", configdir) < 0) {
|
||||
VIR_FREE(configdir);
|
||||
goto error;
|
||||
}
|
||||
*configfile = g_strdup_printf("%s/virtlockd.conf", configdir);
|
||||
VIR_FREE(configdir);
|
||||
}
|
||||
|
||||
|
|
|
@ -127,10 +127,7 @@ static char *virLockManagerLockDaemonPath(bool privileged)
|
|||
if (!(rundir = virGetUserRuntimeDirectory()))
|
||||
return NULL;
|
||||
|
||||
if (virAsprintf(&path, "%s/virtlockd-sock", rundir) < 0) {
|
||||
VIR_FREE(rundir);
|
||||
return NULL;
|
||||
}
|
||||
path = g_strdup_printf("%s/virtlockd-sock", rundir);
|
||||
|
||||
VIR_FREE(rundir);
|
||||
}
|
||||
|
@ -577,9 +574,7 @@ static int virLockManagerLockDaemonAddResource(virLockManagerPtr lock,
|
|||
_("Missing path or lockspace for lease resource"));
|
||||
goto cleanup;
|
||||
}
|
||||
if (virAsprintf(&newLockspace, "%s/%s",
|
||||
path, lockspace) < 0)
|
||||
goto cleanup;
|
||||
newLockspace = g_strdup_printf("%s/%s", path, lockspace);
|
||||
newName = g_strdup(name);
|
||||
|
||||
} break;
|
||||
|
|
|
@ -103,7 +103,7 @@ virLockManagerSanlockError(int err,
|
|||
#if HAVE_SANLOCK_STRERROR
|
||||
*message = g_strdup(sanlock_strerror(err));
|
||||
#else
|
||||
ignore_value(virAsprintfQuiet(message, _("sanlock error %d"), err));
|
||||
message = g_strdup_printf(_("sanlock error %d"), err);
|
||||
#endif
|
||||
return true;
|
||||
} else {
|
||||
|
@ -211,10 +211,8 @@ virLockManagerSanlockSetupLockspace(virLockManagerSanlockDriverPtr driver)
|
|||
char *dir = NULL;
|
||||
int retries = LOCKSPACE_RETRIES;
|
||||
|
||||
if (virAsprintf(&path, "%s/%s",
|
||||
driver->autoDiskLeasePath,
|
||||
VIR_LOCK_MANAGER_SANLOCK_AUTO_DISK_LOCKSPACE) < 0)
|
||||
goto error;
|
||||
path = g_strdup_printf("%s/%s", driver->autoDiskLeasePath,
|
||||
VIR_LOCK_MANAGER_SANLOCK_AUTO_DISK_LOCKSPACE);
|
||||
|
||||
if (virStrcpyStatic(ls.name,
|
||||
VIR_LOCK_MANAGER_SANLOCK_AUTO_DISK_LOCKSPACE) < 0) {
|
||||
|
@ -645,9 +643,7 @@ virLockManagerSanlockAddDisk(virLockManagerSanlockDriverPtr driver,
|
|||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virAsprintf(&path, "%s/%s",
|
||||
driver->autoDiskLeasePath, res->name) < 0)
|
||||
goto cleanup;
|
||||
path = g_strdup_printf("%s/%s", driver->autoDiskLeasePath, res->name);
|
||||
if (virStrcpy(res->disks[0].path, path, SANLK_PATH_LEN) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Lease path '%s' exceeds %d characters"),
|
||||
|
|
|
@ -131,9 +131,7 @@ virLockManagerPluginPtr virLockManagerPluginNew(const char *name,
|
|||
VIR_DEBUG("name=%s driverName=%s configDir=%s flags=0x%x",
|
||||
name, driverName, configDir, flags);
|
||||
|
||||
if (virAsprintf(&configFile, "%s/%s-%s.conf",
|
||||
configDir, driverName, name) < 0)
|
||||
return NULL;
|
||||
configFile = g_strdup_printf("%s/%s-%s.conf", configDir, driverName, name);
|
||||
|
||||
if (STREQ(name, "nop")) {
|
||||
driver = &virLockDriverNop;
|
||||
|
|
Loading…
Reference in New Issue