Signed-off-by: Laine Stump <laine(a)redhat.com>
---
src/libxl/libxl_conf.c | 6 ++----
src/libxl/libxl_driver.c | 2 +-
src/libxl/libxl_migration.c | 2 +-
src/libxl/xen_common.c | 12 +++++-------
src/libxl/xen_xl.c | 19 +++++++------------
src/libxl/xen_xm.c | 3 +--
6 files changed, 17 insertions(+), 27 deletions(-)
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index a0059fc2a7..124e08d598 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -911,7 +911,7 @@ libxlMakeNetworkDiskSrcStr(virStorageSourcePtr src,
const char *secret)
{
char *ret = NULL;
- virBuffer buf = VIR_BUFFER_INITIALIZER;
+ g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
size_t i;
switch ((virStorageNetProtocol) src->protocol) {
@@ -978,7 +978,6 @@ libxlMakeNetworkDiskSrcStr(virStorageSourcePtr src,
}
cleanup:
- virBufferFreeAndReset(&buf);
return ret;
}
@@ -1241,7 +1240,7 @@ libxlMakeNic(virDomainDefPtr def,
const virNetDevBandwidth *actual_bw;
const virNetDevVPortProfile *port_profile;
const virNetDevVlan *virt_vlan;
- virBuffer buf = VIR_BUFFER_INITIALIZER;
+ g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
size_t i;
const char *script = NULL;
int ret = -1;
@@ -1434,7 +1433,6 @@ libxlMakeNic(virDomainDefPtr def,
ret = 0;
cleanup:
- virBufferFreeAndReset(&buf);
virObjectUnref(network);
virObjectUnref(conn);
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index a80bc3fe3a..9b9713df2c 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -942,7 +942,7 @@ static char *
libxlConnectGetSysinfo(virConnectPtr conn, unsigned int flags)
{
libxlDriverPrivatePtr driver = conn->privateData;
- virBuffer buf = VIR_BUFFER_INITIALIZER;
+ g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
virCheckFlags(0, NULL);
diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c
index 9d253346eb..87cd5337ba 100644
--- a/src/libxl/libxl_migration.c
+++ b/src/libxl/libxl_migration.c
@@ -117,7 +117,7 @@ libxlMigrationBakeCookie(libxlMigrationCookiePtr mig,
char **cookieout,
int *cookieoutlen)
{
- virBuffer buf = VIR_BUFFER_INITIALIZER;
+ g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
char uuidstr[VIR_UUID_STRING_BUFLEN];
if (!cookieout || !cookieoutlen)
diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c
index 5c37e431eb..6b16752c8a 100644
--- a/src/libxl/xen_common.c
+++ b/src/libxl/xen_common.c
@@ -1633,7 +1633,7 @@ xenFormatSxprChr(virDomainChrDefPtr def,
static int
xenFormatSerial(virConfValuePtr list, virDomainChrDefPtr serial)
{
- virBuffer buf = VIR_BUFFER_INITIALIZER;
+ g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
virConfValuePtr val, tmp;
int ret;
@@ -1661,7 +1661,6 @@ xenFormatSerial(virConfValuePtr list, virDomainChrDefPtr serial)
return 0;
cleanup:
- virBufferFreeAndReset(&buf);
return -1;
}
@@ -1694,7 +1693,7 @@ xenFormatNet(virConnectPtr conn,
int hvm,
const char *vif_typename)
{
- virBuffer buf = VIR_BUFFER_INITIALIZER;
+ g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
virConfValuePtr val, tmp;
char macaddr[VIR_MAC_STRING_BUFLEN];
@@ -1826,7 +1825,6 @@ xenFormatNet(virConnectPtr conn,
return 0;
cleanup:
- virBufferFreeAndReset(&buf);
return -1;
}
@@ -2034,7 +2032,7 @@ xenFormatCharDev(virConfPtr conf, virDomainDefPtr def,
if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
if (def->nparallels) {
- virBuffer buf = VIR_BUFFER_INITIALIZER;
+ g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
char *str;
int ret;
@@ -2052,7 +2050,7 @@ xenFormatCharDev(virConfPtr conf, virDomainDefPtr def,
if (def->nserials) {
if ((def->nserials == 1) && (def->serials[0]->target.port ==
0)) {
- virBuffer buf = VIR_BUFFER_INITIALIZER;
+ g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
char *str;
int ret;
@@ -2329,7 +2327,7 @@ xenFormatVfb(virConfPtr conf, virDomainDefPtr def)
} else {
virConfValuePtr vfb, disp;
char *vfbstr = NULL;
- virBuffer buf = VIR_BUFFER_INITIALIZER;
+ g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
if (def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_SDL) {
virBufferAddLit(&buf, "type=sdl");
diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c
index d40c2e1d8e..ec5e4791a3 100644
--- a/src/libxl/xen_xl.c
+++ b/src/libxl/xen_xl.c
@@ -1445,7 +1445,7 @@ xenFormatXLVnuma(virConfValuePtr list,
int ret = -1;
size_t i;
- virBuffer buf = VIR_BUFFER_INITIALIZER;
+ g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
virConfValuePtr numaVnode, tmp;
size_t nodeSize = virDomainNumaGetNodeMemorySize(numa, node) / 1024;
@@ -1563,7 +1563,7 @@ static char *
xenFormatXLDiskSrcNet(virStorageSourcePtr src)
{
char *ret = NULL;
- virBuffer buf = VIR_BUFFER_INITIALIZER;
+ g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
size_t i;
switch ((virStorageNetProtocol) src->protocol) {
@@ -1620,8 +1620,6 @@ xenFormatXLDiskSrcNet(virStorageSourcePtr src)
}
cleanup:
- virBufferFreeAndReset(&buf);
-
return ret;
}
@@ -1662,7 +1660,7 @@ xenFormatXLDiskSrc(virStorageSourcePtr src, char **srcstr)
static int
xenFormatXLDisk(virConfValuePtr list, virDomainDiskDefPtr disk)
{
- virBuffer buf = VIR_BUFFER_INITIALIZER;
+ g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
virConfValuePtr val, tmp;
int format = virDomainDiskGetFormat(disk);
const char *driver = virDomainDiskGetDriver(disk);
@@ -1754,7 +1752,6 @@ xenFormatXLDisk(virConfValuePtr list, virDomainDiskDefPtr disk)
cleanup:
VIR_FREE(target);
- virBufferFreeAndReset(&buf);
return ret;
}
@@ -1976,7 +1973,7 @@ xenFormatXLUSBController(virConfPtr conf,
for (i = 0; i < def->ncontrollers; i++) {
if (def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_USB) {
virConfValuePtr val, tmp;
- virBuffer buf = VIR_BUFFER_INITIALIZER;
+ g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
if (def->controllers[i]->model != -1) {
switch (def->controllers[i]->model) {
@@ -1997,10 +1994,9 @@ xenFormatXLUSBController(virConfPtr conf,
virBufferAsprintf(&buf, "ports=%x",
def->controllers[i]->opts.usbopts.ports);
- if (VIR_ALLOC(val) < 0) {
- virBufferFreeAndReset(&buf);
+ if (VIR_ALLOC(val) < 0)
goto error;
- }
+
val->type = VIR_CONF_STRING;
val->str = virBufferContentAndReset(&buf);
tmp = usbctrlVal->list;
@@ -2098,7 +2094,7 @@ xenFormatXLUSB(virConfPtr conf,
static int
xenFormatXLChannel(virConfValuePtr list, virDomainChrDefPtr channel)
{
- virBuffer buf = VIR_BUFFER_INITIALIZER;
+ g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
int sourceType = channel->source->type;
virConfValuePtr val, tmp;
@@ -2137,7 +2133,6 @@ xenFormatXLChannel(virConfValuePtr list, virDomainChrDefPtr
channel)
return 0;
cleanup:
- virBufferFreeAndReset(&buf);
return -1;
}
diff --git a/src/libxl/xen_xm.c b/src/libxl/xen_xm.c
index 3883725efc..f28326ade8 100644
--- a/src/libxl/xen_xm.c
+++ b/src/libxl/xen_xm.c
@@ -290,7 +290,7 @@ static int
xenFormatXMDisk(virConfValuePtr list,
virDomainDiskDefPtr disk)
{
- virBuffer buf = VIR_BUFFER_INITIALIZER;
+ g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
virConfValuePtr val, tmp;
const char *src = virDomainDiskGetSource(disk);
int format = virDomainDiskGetFormat(disk);
@@ -361,7 +361,6 @@ xenFormatXMDisk(virConfValuePtr list,
return 0;
cleanup:
- virBufferFreeAndReset(&buf);
return -1;
}
--
2.25.4