xmlNodePtr *disks = NULL;
size_t i;
bool details = false;
- char *type = NULL;
- char *device = NULL;
- char *target = NULL;
- char *source = NULL;
g_autoptr(vshTable) table = NULL;
if (vshCommandOptBool(cmd, "inactive"))
goto cleanup;
for (i = 0; i < ndisks; i++) {
+ g_autofree char *type = NULL;
+ g_autofree char *device = NULL;
+ g_autofree char *target = NULL;
+ g_autofree char *source = NULL;
+
ctxt->node = disks[i];
type = virXPathString("string(./@type)", ctxt);
NULLSTR_MINUS(source), NULL) < 0)
goto cleanup;
}
-
- VIR_FREE(source);
- VIR_FREE(target);
- VIR_FREE(device);
- VIR_FREE(type);
}
vshTablePrintToStdout(table, ctl);
ret = true;
cleanup:
- VIR_FREE(source);
- VIR_FREE(target);
- VIR_FREE(device);
- VIR_FREE(type);
VIR_FREE(disks);
return ret;
}
virDomainBlockStatsStruct stats;
virTypedParameterPtr params = NULL;
virTypedParameterPtr par = NULL;
- char *value = NULL;
const char *field = NULL;
int rc, nparams = 0;
size_t i;
/* at first print all known values in desired order */
for (i = 0; domblkstat_output[i].field != NULL; i++) {
+ g_autofree char *value = NULL;
+
if (!(par = virTypedParamsGet(params, nparams,
domblkstat_output[i].field)))
continue;
vshPrint(ctl, "%s %-*s %s\n", device,
human ? 31 : 0, field, value);
-
- VIR_FREE(value);
}
/* go through the fields again, for remaining fields */
for (i = 0; i < nparams; i++) {
+ g_autofree char *value = NULL;
+
if (!*params[i].field)
continue;
value = vshGetTypedParamValue(ctl, params+i);
vshPrint(ctl, "%s %s %s\n", device, params[i].field, value);
- VIR_FREE(value);
}
}
bool optName = vshCommandOptBool(cmd, "name");
bool optID = vshCommandOptBool(cmd, "id");
size_t i;
- char *title;
char uuid[VIR_UUID_STRING_BUFLEN];
int state;
bool ret = false;
state = -2;
if (optTitle) {
+ g_autofree char *title = NULL;
+
if (!(title = virshGetDomainDescription(ctl, dom, true, 0)))
goto cleanup;
if (vshTableRowAppend(table, id_buf,
: virshDomainStateToString(state),
title, NULL) < 0)
goto cleanup;
- VIR_FREE(title);
} else {
if (vshTableRowAppend(table, id_buf,
virDomainGetName(dom),
virDomainStatsRecordPtr record,
bool raw G_GNUC_UNUSED)
{
- char *param;
size_t i;
vshPrint(ctl, "Domain: '%s'\n", virDomainGetName(record->dom));
/* XXX: Implement pretty-printing */
for (i = 0; i < record->nparams; i++) {
+ g_autofree char *param = NULL;
+
if (!(param = vshGetTypedParamValue(ctl, record->params + i)))
return false;
vshPrint(ctl, " %s=%s\n", record->params[i].field, param);
-
- VIR_FREE(param);
}
return true;
for (i = 0; i < ifaces_count; i++) {
virDomainInterfacePtr iface = ifaces[i];
- char *ip_addr_str = NULL;
const char *type = NULL;
if (ifacestr && STRNEQ(ifacestr, iface->name))
for (j = 0; j < iface->naddrs; j++) {
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
+ g_autofree char *ip_addr_str = NULL;
switch (iface->addrs[j].type) {
case VIR_IP_ADDR_TYPE_IPV4:
else
vshPrint(ctl, " %-10s %-17s %s\n",
"-", "-", ip_addr_str);
-
- VIR_FREE(ip_addr_str);
}
}
g_autoptr(virshDomain) dom = NULL;
const char *iface;
const char *state;
- char *value;
virMacAddr macaddr;
const char *element;
const char *attr;
while (cur) {
if (cur->type == XML_ELEMENT_NODE &&
virXMLNodeNameEqual(cur, element)) {
- value = virXMLPropString(cur, attr);
+ g_autofree char *value = virXMLPropString(cur, attr);
- if (STRCASEEQ(value, iface)) {
- VIR_FREE(value);
+ if (STRCASEEQ(value, iface))
goto hit;
- }
- VIR_FREE(value);
}
cur = cur->next;
}
g_autoptr(xmlXPathContext) ctxt = NULL;
xmlNodePtr *vol_nodes = NULL; /* XML nodes of volumes of the guest */
int nvol_nodes;
- char *source = NULL;
- char *target = NULL;
- char *pool = NULL;
size_t i;
size_t j;
virshControl *priv = ctl->privData;
goto error;
for (i = 0; i < nvol_nodes; i++) {
+ g_autofree char *source = NULL;
+ g_autofree char *target = NULL;
+ g_autofree char *pool = NULL;
virshUndefineVolume vol;
ctxt->node = vol_nodes[i];
- VIR_FREE(source);
- VIR_FREE(target);
- VIR_FREE(pool);
-
/* get volume source and target paths */
if (!(target = virXPathString("string(./target/@dev)", ctxt)))
goto error;
}
cleanup:
- VIR_FREE(source);
- VIR_FREE(target);
- VIR_FREE(pool);
for (i = 0; i < nvols; i++) {
VIR_FREE(vols[i].source);
VIR_FREE(vols[i].target);
virTypedParameterPtr src_params, int nsrc_params,
virTypedParameterPtr *update_params)
{
- char *set_field = NULL;
char *set_val = NULL;
const char *val = NULL;
const vshCmdOpt *opt = NULL;
int rv;
while ((opt = vshCommandOptArgv(ctl, cmd, opt))) {
- set_field = g_strdup(opt->data);
+ g_autofree char *set_field = g_strdup(opt->data);
+
if (!(set_val = strchr(set_field, '='))) {
vshError(ctl, "%s", _("Invalid syntax for --set, "
"expecting name=value"));
¶ms, &nparams, &maxparams,
set_field, set_val) < 0)
goto cleanup;
-
- VIR_FREE(set_field);
}
rv = vshCommandOptStringReq(ctl, cmd, "cap", &val);
*update_params = g_steal_pointer(¶ms);
cleanup:
- VIR_FREE(set_field);
virTypedParamsFree(params, nparams);
return ret;
}
unsigned int curvcpus = 0;
unsigned int maxvcpus = 0;
unsigned int vcpuid;
- char *online = NULL;
if (inactive)
flags |= VIR_DOMAIN_XML_INACTIVE;
}
for (i = 0; i < nnodes; i++) {
+ g_autofree char *online = NULL;
+
ctxt->node = nodes[i];
if (virXPathUInt("string(@id)", ctxt, &vcpuid) < 0 ||
if (STREQ(online, "yes"))
ignore_value(virBitmapSetBit(ret, vcpuid));
-
- VIR_FREE(online);
}
if (virBitmapCountBits(ret) != curvcpus) {
}
cleanup:
- VIR_FREE(online);
VIR_FREE(nodes);
return ret;
}