Re: [PATCH 15/32] use g_auto() for all remaining non-g_auto() virBuffers

2020-07-08 Thread Ján Tomko

On a Sunday in 2020, Laine Stump wrote:

Signed-off-by: Laine Stump 
---
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(-)



Reviewed-by: Ján Tomko 

Jano


signature.asc
Description: PGP signature


[PATCH 15/32] use g_auto() for all remaining non-g_auto() virBuffers

2020-07-05 Thread Laine Stump
Signed-off-by: Laine Stump 
---
 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();
+if (!(username = virGetUserName(geteuid(
 return NULL;
-}
+
 virBufferAsprintf(, "%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(, "%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();
 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