mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-25 14:05:18 +00:00
util: macmap: Remove unused cleanup labels and 'ret' variables
Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
a2e64fc6af
commit
32def543d1
@ -133,31 +133,28 @@ virMacMapLoadFile(virMacMapPtr mgr,
|
|||||||
g_autoptr(virJSONValue) map = NULL;
|
g_autoptr(virJSONValue) map = NULL;
|
||||||
int map_str_len = 0;
|
int map_str_len = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
if (virFileExists(file) &&
|
if (virFileExists(file) &&
|
||||||
(map_str_len = virFileReadAll(file,
|
(map_str_len = virFileReadAll(file,
|
||||||
VIR_MAC_MAP_FILE_SIZE_MAX,
|
VIR_MAC_MAP_FILE_SIZE_MAX,
|
||||||
&map_str)) < 0)
|
&map_str)) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (map_str_len == 0) {
|
if (map_str_len == 0)
|
||||||
ret = 0;
|
return 0;
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(map = virJSONValueFromString(map_str))) {
|
if (!(map = virJSONValueFromString(map_str))) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("invalid json in file: %s"),
|
_("invalid json in file: %s"),
|
||||||
file);
|
file);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!virJSONValueIsArray(map)) {
|
if (!virJSONValueIsArray(map)) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Malformed file structure: %s"),
|
_("Malformed file structure: %s"),
|
||||||
file);
|
file);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < virJSONValueArraySize(map); i++) {
|
for (i = 0; i < virJSONValueArraySize(map); i++) {
|
||||||
@ -169,13 +166,13 @@ virMacMapLoadFile(virMacMapPtr mgr,
|
|||||||
if (!(domain = virJSONValueObjectGetString(tmp, "domain"))) {
|
if (!(domain = virJSONValueObjectGetString(tmp, "domain"))) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Missing domain"));
|
_("Missing domain"));
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(macs = virJSONValueObjectGetArray(tmp, "macs"))) {
|
if (!(macs = virJSONValueObjectGetArray(tmp, "macs"))) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Missing macs"));
|
_("Missing macs"));
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j = 0; j < virJSONValueArraySize(macs); j++) {
|
for (j = 0; j < virJSONValueArraySize(macs); j++) {
|
||||||
@ -183,13 +180,11 @@ virMacMapLoadFile(virMacMapPtr mgr,
|
|||||||
const char *mac = virJSONValueGetString(macJSON);
|
const char *mac = virJSONValueGetString(macJSON);
|
||||||
|
|
||||||
if (virMacMapAddLocked(mgr, domain, mac) < 0)
|
if (virMacMapAddLocked(mgr, domain, mac) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -202,7 +197,6 @@ virMACMapHashDumper(void *payload,
|
|||||||
g_autoptr(virJSONValue) arr = virJSONValueNewArray();
|
g_autoptr(virJSONValue) arr = virJSONValueNewArray();
|
||||||
const char **macs = payload;
|
const char **macs = payload;
|
||||||
size_t i;
|
size_t i;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
for (i = 0; macs[i]; i++) {
|
for (i = 0; macs[i]; i++) {
|
||||||
virJSONValuePtr m = virJSONValueNewString(macs[i]);
|
virJSONValuePtr m = virJSONValueNewString(macs[i]);
|
||||||
@ -210,22 +204,20 @@ virMACMapHashDumper(void *payload,
|
|||||||
if (!m ||
|
if (!m ||
|
||||||
virJSONValueArrayAppend(arr, m) < 0) {
|
virJSONValueArrayAppend(arr, m) < 0) {
|
||||||
virJSONValueFree(m);
|
virJSONValueFree(m);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virJSONValueObjectAppendString(obj, "domain", name) < 0 ||
|
if (virJSONValueObjectAppendString(obj, "domain", name) < 0 ||
|
||||||
virJSONValueObjectAppend(obj, "macs", arr) < 0)
|
virJSONValueObjectAppend(obj, "macs", arr) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
arr = NULL;
|
arr = NULL;
|
||||||
|
|
||||||
if (virJSONValueArrayAppend(data, obj) < 0)
|
if (virJSONValueArrayAppend(data, obj) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
obj = NULL;
|
obj = NULL;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -234,17 +226,14 @@ virMacMapDumpStrLocked(virMacMapPtr mgr,
|
|||||||
char **str)
|
char **str)
|
||||||
{
|
{
|
||||||
g_autoptr(virJSONValue) arr = virJSONValueNewArray();
|
g_autoptr(virJSONValue) arr = virJSONValueNewArray();
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
if (virHashForEachSorted(mgr->macs, virMACMapHashDumper, arr) < 0)
|
if (virHashForEachSorted(mgr->macs, virMACMapHashDumper, arr) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (!(*str = virJSONValueToString(arr, true)))
|
if (!(*str = virJSONValueToString(arr, true)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user