static int
xenFormatPCI(virConf *conf, virDomainDef *def)
{
- virConfValue *pciVal = NULL;
+ g_autoptr(virConfValue) pciVal = NULL;
int hasPCI = 0;
size_t i;
if (ret < 0)
return -1;
}
- VIR_FREE(pciVal);
return 0;
}
} else {
size_t j = 0;
int maxport = -1, port;
- virConfValue *serialVal = NULL;
+ g_autoptr(virConfValue) serialVal = NULL;
if (STREQ(nativeFormat, XEN_CONFIG_FORMAT_XM)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
}
if (xenFormatSerial(serialVal, chr) < 0) {
- VIR_FREE(serialVal);
return -1;
}
}
if (ret < 0)
return -1;
}
- VIR_FREE(serialVal);
}
} else {
if (xenConfigSetString(conf, "serial", "none") < 0)
return -1;
}
} else {
- virConfValue *vfb;
- virConfValue *disp;
+ g_autoptr(virConfValue) vfb = NULL;
+ g_autoptr(virConfValue) disp = NULL;
char *vfbstr = NULL;
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
vfbstr = virBufferContentAndReset(&buf);
- vfb = g_new0(virConfValue, 1);
disp = g_new0(virConfValue, 1);
-
- vfb->type = VIR_CONF_LIST;
- vfb->list = disp;
disp->type = VIR_CONF_STRING;
disp->str = vfbstr;
- if (virConfSetValue(conf, "vfb", vfb) < 0)
+ vfb = g_new0(virConfValue, 1);
+ vfb->type = VIR_CONF_LIST;
+ vfb->list = g_steal_pointer(&disp);
+
+ if (virConfSetValue(conf, "vfb", vfb) < 0) {
+ vfb = NULL;
return -1;
+ }
+ vfb = NULL;
}
}
virDomainDef *def,
const char *vif_typename)
{
- virConfValue *netVal = NULL;
+ g_autoptr(virConfValue) netVal = NULL;
size_t i;
int hvm = def->os.type == VIR_DOMAIN_OSTYPE_HVM;
goto cleanup;
}
- VIR_FREE(netVal);
return 0;
cleanup:
- virConfFreeValue(netVal);
return -1;
}
virDomainDef *def)
{
virDomainNuma *numa = def->numa;
- virConfValue *vnumaVal;
+ g_autoptr(virConfValue) vnumaVal = NULL;
size_t i;
size_t nr_nodes;
if (ret < 0)
return -1;
}
- VIR_FREE(vnumaVal);
return 0;
cleanup:
- virConfFreeValue(vnumaVal);
return -1;
}
static int
xenFormatXLDomainDisks(virConf *conf, virDomainDef *def)
{
- virConfValue *diskVal;
+ g_autoptr(virConfValue) diskVal = NULL;
size_t i;
diskVal = g_new0(virConfValue, 1);
if (ret < 0)
return -1;
}
- VIR_FREE(diskVal);
return 0;
cleanup:
- virConfFreeValue(diskVal);
return -1;
}
{
size_t i;
const char *devtype;
- virConfValue *usbdevices = NULL;
+ g_autoptr(virConfValue) usbdevices = NULL;
virConfValue *lastdev;
if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
* only one device present */
if (xenConfigSetString(conf, "usbdevice", usbdevices->list->str) < 0)
goto error;
- virConfFreeValue(usbdevices);
} else {
if (virConfSetValue(conf, "usbdevice", usbdevices) < 0) {
usbdevices = NULL;
}
usbdevices = NULL;
}
- } else {
- VIR_FREE(usbdevices);
}
}
return 0;
error:
- virConfFreeValue(usbdevices);
return -1;
}
xenFormatXLUSBController(virConf *conf,
virDomainDef *def)
{
- virConfValue *usbctrlVal = NULL;
+ g_autoptr(virConfValue) usbctrlVal = NULL;
int hasUSBCtrl = 0;
size_t i;
if (ret < 0)
return -1;
}
- VIR_FREE(usbctrlVal);
return 0;
error:
- virConfFreeValue(usbctrlVal);
return -1;
}
xenFormatXLUSB(virConf *conf,
virDomainDef *def)
{
- virConfValue *usbVal = NULL;
+ g_autoptr(virConfValue) usbVal = NULL;
int hasUSB = 0;
size_t i;
if (ret < 0)
return -1;
}
- VIR_FREE(usbVal);
return 0;
}
static int
xenFormatXLDomainChannels(virConf *conf, virDomainDef *def)
{
- virConfValue *channelVal = NULL;
+ g_autoptr(virConfValue) channelVal = NULL;
size_t i;
channelVal = g_new0(virConfValue, 1);
goto cleanup;
}
- VIR_FREE(channelVal);
return 0;
cleanup:
- virConfFreeValue(channelVal);
return -1;
}
xenFormatXLDomainNamespaceData(virConf *conf, virDomainDef *def)
{
libxlDomainXmlNsDef *nsdata = def->namespaceData;
- virConfValue *args = NULL;
+ g_autoptr(virConfValue) args = NULL;
size_t i;
if (!nsdata)
args->list = val;
}
- if (args->list != NULL)
- if (virConfSetValue(conf, "device_model_args", args) < 0)
+ if (args->list != NULL) {
+ if (virConfSetValue(conf, "device_model_args", args) < 0) {
+ args = NULL;
goto error;
+ }
+ args = NULL;
+ }
return 0;
error:
- virConfFreeValue(args);
return -1;
}