mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-21 20:15:17 +00:00
use g_auto() for all remaining non-g_auto() virBuffers
Signed-off-by: Laine Stump <laine@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
453316e8bc
commit
f7e3610095
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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),
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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"));
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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",
|
||||
|
Loading…
x
Reference in New Issue
Block a user