mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
libxl: use g_auto() for all virBuffers
Signed-off-by: Laine Stump <laine@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
fc81c07427
commit
7a6bfea145
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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");
|
||||
|
@ -1444,7 +1444,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;
|
||||
virBitmapPtr cpumask = virDomainNumaGetNodeCpumask(numa, node);
|
||||
size_t nodeSize = virDomainNumaGetNodeMemorySize(numa, node) / 1024;
|
||||
@ -1565,7 +1565,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) {
|
||||
@ -1622,8 +1622,6 @@ xenFormatXLDiskSrcNet(virStorageSourcePtr src)
|
||||
}
|
||||
|
||||
cleanup:
|
||||
virBufferFreeAndReset(&buf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -1664,7 +1662,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);
|
||||
@ -1756,7 +1754,6 @@ xenFormatXLDisk(virConfValuePtr list, virDomainDiskDefPtr disk)
|
||||
|
||||
cleanup:
|
||||
VIR_FREE(target);
|
||||
virBufferFreeAndReset(&buf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -1978,7 +1975,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) {
|
||||
@ -1999,10 +1996,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;
|
||||
@ -2100,7 +2096,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;
|
||||
|
||||
@ -2139,7 +2135,6 @@ xenFormatXLChannel(virConfValuePtr list, virDomainChrDefPtr channel)
|
||||
return 0;
|
||||
|
||||
cleanup:
|
||||
virBufferFreeAndReset(&buf);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user