if (virStrToLong_i(values[i], NULL, 10, &wantvlan) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse vlan in '%s'"), val);
- virDomainNetDefFree(def);
- def = NULL;
- goto cleanup;
+ goto error;
}
} else if (def->type == VIR_DOMAIN_NET_TYPE_ETHERNET &&
STREQ(keywords[i], "script") && STRNEQ(values[i], "")) {
*/
nic = qemuFindNICForVLAN(nnics, nics, wantvlan);
- if (!nic) {
- virDomainNetDefFree(def);
- def = NULL;
- goto cleanup;
- }
+ if (!nic)
+ goto error;
if (!STRPREFIX(nic, "nic")) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse NIC definition '%s'"), nic);
- virDomainNetDefFree(def);
- def = NULL;
- goto cleanup;
+ goto error;
}
for (i = 0; i < nkeywords; i++) {
&values,
&nkeywords,
0) < 0) {
- virDomainNetDefFree(def);
- def = NULL;
- goto cleanup;
+ goto error;
}
} else {
nkeywords = 0;
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unable to parse mac address '%s'"),
values[i]);
- virDomainNetDefFree(def);
- def = NULL;
- goto cleanup;
+ goto error;
}
} else if (STREQ(keywords[i], "model")) {
def->model = values[i];
if (virStrToLong_ul(values[i], NULL, 10, &def->tune.sndbuf) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse sndbuf size in '%s'"), val);
- virDomainNetDefFree(def);
- def = NULL;
- goto cleanup;
+ goto error;
}
def->tune.sndbuf_specified = true;
}
VIR_FREE(keywords);
VIR_FREE(values);
return def;
+
+ error:
+ virDomainNetDefFree(def);
+ def = NULL;
+ goto cleanup;
}