Signed-off-by: Laine Stump <laine(a)redhat.com>
---
src/hypervisor/domain_driver.c | 7 +++----
src/locking/lock_driver_sanlock.c | 2 +-
src/node_device/node_device_udev.c | 2 +-
src/openvz/openvz_driver.c | 5 ++---
src/security/virt-aa-helper.c | 4 ++--
src/storage/storage_backend_rbd.c | 7 ++-----
src/storage/storage_util.c | 9 ++++-----
src/vmx/vmx.c | 5 +----
src/vz/vz_driver.c | 4 ++--
9 files changed, 18 insertions(+), 27 deletions(-)
diff --git a/src/hypervisor/domain_driver.c b/src/hypervisor/domain_driver.c
index 31821fc712..f5f0f6e2e9 100644
--- a/src/hypervisor/domain_driver.c
+++ b/src/hypervisor/domain_driver.c
@@ -86,7 +86,7 @@ virDomainDriverGenerateMachineName(const char *drivername,
const char *name,
bool privileged)
{
- virBuffer buf = VIR_BUFFER_INITIALIZER;
+ g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
if (root) {
g_autofree char *hash = NULL;
@@ -100,10 +100,9 @@ virDomainDriverGenerateMachineName(const char *drivername,
if (!privileged) {
g_autofree char *username = NULL;
- if (!(username = virGetUserName(geteuid()))) {
- virBufferFreeAndReset(&buf);
+ if (!(username = virGetUserName(geteuid())))
return NULL;
- }
+
virBufferAsprintf(&buf, "%s-", username);
}
}
diff --git a/src/locking/lock_driver_sanlock.c b/src/locking/lock_driver_sanlock.c
index 4ebe98e86d..23711a75cb 100644
--- a/src/locking/lock_driver_sanlock.c
+++ b/src/locking/lock_driver_sanlock.c
@@ -825,7 +825,7 @@ virLockManagerSanlockRegisterKillscript(int sock,
const char *uuidstr,
virDomainLockFailureAction action)
{
- virBuffer buf = VIR_BUFFER_INITIALIZER;
+ g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
char *path;
char *args = NULL;
int ret = -1;
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index cec99cb898..e389b56302 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -294,7 +294,7 @@ udevGenerateDeviceName(struct udev_device *device,
const char *s)
{
size_t i;
- virBuffer buf = VIR_BUFFER_INITIALIZER;
+ g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
virBufferAsprintf(&buf, "%s_%s",
udev_device_get_subsystem(device),
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index 79a100c343..71e270ea09 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -704,7 +704,7 @@ openvzDomainSetNetwork(virConnectPtr conn, const char *vpsid,
if (net->type == VIR_DOMAIN_NET_TYPE_BRIDGE ||
(net->type == VIR_DOMAIN_NET_TYPE_ETHERNET &&
net->guestIP.nips == 0)) {
- virBuffer buf = VIR_BUFFER_INITIALIZER;
+ g_auto(virBuffer)buf = VIR_BUFFER_INITIALIZER;
int veid = openvzGetVEID(vpsid);
/* if net is ethernet and the user has specified guest interface name,
@@ -782,7 +782,7 @@ openvzDomainSetNetworkConfig(virConnectPtr conn,
virDomainDefPtr def)
{
size_t i;
- virBuffer buf = VIR_BUFFER_INITIALIZER;
+ g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
char *param;
int first = 1;
struct openvz_driver *driver = conn->privateData;
@@ -819,7 +819,6 @@ openvzDomainSetNetworkConfig(virConnectPtr conn,
return 0;
exit:
- virBufferFreeAndReset(&buf);
return -1;
}
diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index 08eb162b8c..dadb9d1614 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -907,7 +907,7 @@ storage_source_add_files(virStorageSourcePtr src,
static int
get_files(vahControl * ctl)
{
- virBuffer buf = VIR_BUFFER_INITIALIZER;
+ g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
int rc = -1;
size_t i;
char *uuid;
@@ -1448,7 +1448,6 @@ int
main(int argc, char **argv)
{
vahControl _ctl, *ctl = &_ctl;
- virBuffer buf = VIR_BUFFER_INITIALIZER;
int rc = -1;
char *profile = NULL;
char *include_file = NULL;
@@ -1496,6 +1495,7 @@ main(int argc, char **argv)
}
} else if (ctl->cmd == 'c' || ctl->cmd == 'r') {
char *included_files = NULL;
+ g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
if (ctl->cmd == 'c' && virFileExists(profile))
vah_error(ctl, 1, _("profile exists"));
diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c
index f0b7653736..08dc5a19dc 100644
--- a/src/storage/storage_backend_rbd.c
+++ b/src/storage/storage_backend_rbd.c
@@ -190,7 +190,7 @@ virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr ptr,
unsigned char *secret_value = NULL;
size_t secret_value_size = 0;
VIR_AUTODISPOSE_STR rados_key = NULL;
- virBuffer mon_host = VIR_BUFFER_INITIALIZER;
+ g_auto(virBuffer) mon_host = VIR_BUFFER_INITIALIZER;
size_t i;
const char *client_mount_timeout = "30";
const char *mon_op_timeout = "30";
@@ -330,7 +330,6 @@ virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr ptr,
VIR_DISPOSE_N(secret_value, secret_value_size);
virObjectUnref(conn);
- virBufferFreeAndReset(&mon_host);
return ret;
}
@@ -1151,7 +1150,7 @@ virStorageBackendRBDCloneImage(rados_ioctx_t io,
uint64_t features;
uint64_t stripe_count;
uint64_t stripe_unit;
- virBuffer snapname = VIR_BUFFER_INITIALIZER;
+ g_auto(virBuffer) snapname = VIR_BUFFER_INITIALIZER;
rbd_image_t image = NULL;
g_autofree char *snapname_buff = NULL;
@@ -1220,8 +1219,6 @@ virStorageBackendRBDCloneImage(rados_ioctx_t io,
ret = 0;
cleanup:
- virBufferFreeAndReset(&snapname);
-
if (image)
rbd_close(image);
diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
index 1ec1d13625..36b5b21a5b 100644
--- a/src/storage/storage_util.c
+++ b/src/storage/storage_util.c
@@ -717,7 +717,7 @@ storageBackendCreateQemuImgOpts(virStorageEncryptionInfoDefPtr
encinfo,
char **opts,
struct _virStorageBackendQemuImgInfo *info)
{
- virBuffer buf = VIR_BUFFER_INITIALIZER;
+ g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
if (info->backingPath)
virBufferAsprintf(&buf, "backing_fmt=%s,",
@@ -761,7 +761,6 @@ storageBackendCreateQemuImgOpts(virStorageEncryptionInfoDefPtr
encinfo,
return 0;
error:
- virBufferFreeAndReset(&buf);
return -1;
}
@@ -934,7 +933,7 @@ storageBackendCreateQemuImgSecretObject(virCommandPtr cmd,
const char *secretPath,
const char *secretAlias)
{
- virBuffer buf = VIR_BUFFER_INITIALIZER;
+ g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
g_autofree char *commandStr = NULL;
virBufferAsprintf(&buf, "secret,id=%s,file=", secretAlias);
@@ -958,7 +957,7 @@ storageBackendResizeQemuImgImageOpts(virCommandPtr cmd,
const char *path,
const char *secretAlias)
{
- virBuffer buf = VIR_BUFFER_INITIALIZER;
+ g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
g_autofree char *commandStr = NULL;
virBufferAsprintf(&buf, "driver=luks,key-secret=%s,file.filename=",
@@ -4058,7 +4057,7 @@ virStorageBackendFileSystemMountAddOptions(virCommandPtr cmd,
const char *providedOpts)
{
g_autofree char *mountOpts = NULL;
- virBuffer buf = VIR_BUFFER_INITIALIZER;
+ g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
if (*default_mount_opts != '\0')
virBufferAsprintf(&buf, "%s,", default_mount_opts);
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index 67bbe27fde..2f2cc19078 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -3060,7 +3060,7 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt,
virDomainDe
size_t i;
int sched_cpu_affinity_length;
unsigned char zero[VIR_UUID_BUFLEN];
- virBuffer buffer = VIR_BUFFER_INITIALIZER;
+ g_auto(virBuffer) buffer = VIR_BUFFER_INITIALIZER;
char *preliminaryDisplayName = NULL;
char *displayName = NULL;
char *annotation = NULL;
@@ -3445,9 +3445,6 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt,
virDomainDe
vmx = virBufferContentAndReset(&buffer);
cleanup:
- if (vmx == NULL)
- virBufferFreeAndReset(&buffer);
-
VIR_FREE(preliminaryDisplayName);
VIR_FREE(displayName);
VIR_FREE(annotation);
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index d882b91def..86fa6f8bef 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -456,7 +456,7 @@ vzConnectGetSysinfo(virConnectPtr conn, unsigned int flags)
{
vzConnPtr privconn = conn->privateData;
vzDriverPtr driver = privconn->driver;
- virBuffer buf = VIR_BUFFER_INITIALIZER;
+ g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
virCheckFlags(0, NULL);
@@ -2741,7 +2741,7 @@ vzBakeCookie(vzDriverPtr driver,
unsigned int flags)
{
char uuidstr[VIR_UUID_STRING_BUFLEN];
- virBuffer buf = VIR_BUFFER_INITIALIZER;
+ g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
if (!cookieout || !cookieoutlen) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
--
2.25.4