node_device: 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 52a6b45e18
commit 7847f011b0
3 changed files with 6 additions and 15 deletions

View File

@ -113,8 +113,7 @@ nodeDeviceUpdateDriverName(virNodeDeviceDefPtr def)
VIR_FREE(def->driver);
if (virAsprintf(&driver_link, "%s/driver", def->sysfs_path) < 0)
goto cleanup;
driver_link = g_strdup_printf("%s/driver", def->sysfs_path);
/* Some devices don't have an explicit driver, so just return
without a name */

View File

@ -614,16 +614,13 @@ nodeStateInitialize(bool privileged G_GNUC_UNUSED,
nodeDeviceLock();
if (privileged) {
if (virAsprintf(&driver->stateDir,
"%s/libvirt/nodedev", RUNSTATEDIR) < 0)
goto failure;
driver->stateDir = g_strdup_printf("%s/libvirt/nodedev", RUNSTATEDIR);
} else {
g_autofree char *rundir = NULL;
if (!(rundir = virGetUserRuntimeDirectory()))
goto failure;
if (virAsprintf(&driver->stateDir, "%s/nodedev/run", rundir) < 0)
goto failure;
driver->stateDir = g_strdup_printf("%s/nodedev/run", rundir);
}
if (virFileMakePathWithMode(driver->stateDir, S_IRWXU) < 0) {

View File

@ -1025,9 +1025,7 @@ udevProcessMediatedDevice(struct udev_device *dev,
* it by waiting for the attributes to become available.
*/
if (virAsprintf(&linkpath, "%s/mdev_type",
udev_device_get_syspath(dev)) < 0)
goto cleanup;
linkpath = g_strdup_printf("%s/mdev_type", udev_device_get_syspath(dev));
if (virFileWaitForExists(linkpath, 1, 100) < 0) {
virReportSystemError(errno,
@ -1809,16 +1807,13 @@ nodeStateInitialize(bool privileged,
driver->privileged = privileged;
if (privileged) {
if (virAsprintf(&driver->stateDir,
"%s/libvirt/nodedev", RUNSTATEDIR) < 0)
goto cleanup;
driver->stateDir = g_strdup_printf("%s/libvirt/nodedev", RUNSTATEDIR);
} else {
g_autofree char *rundir = NULL;
if (!(rundir = virGetUserRuntimeDirectory()))
goto cleanup;
if (virAsprintf(&driver->stateDir, "%s/nodedev/run", rundir) < 0)
goto cleanup;
driver->stateDir = g_strdup_printf("%s/nodedev/run", rundir);
}
if (virFileMakePathWithMode(driver->stateDir, S_IRWXU) < 0) {