mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
virStorageBackendLogicalParseVolExtents: Move 'extents' inside the loop
It's used only inside the loop filling the extents, move it there and restructure the code so that 'extent.path' doesn't have to be freed. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
bbd89d7894
commit
e03e54c9a2
@ -128,11 +128,8 @@ virStorageBackendLogicalParseVolExtents(virStorageVolDef *vol,
|
|||||||
unsigned long long offset;
|
unsigned long long offset;
|
||||||
unsigned long long size;
|
unsigned long long size;
|
||||||
unsigned long long length;
|
unsigned long long length;
|
||||||
virStorageVolSourceExtent extent;
|
|
||||||
g_autofree char *regex = NULL;
|
g_autofree char *regex = NULL;
|
||||||
|
|
||||||
memset(&extent, 0, sizeof(extent));
|
|
||||||
|
|
||||||
/* Assume 1 extent (the regex for 'devices' is "(\\S+)") and only
|
/* Assume 1 extent (the regex for 'devices' is "(\\S+)") and only
|
||||||
* check the 'stripes' field if we have a striped, mirror, or one of
|
* check the 'stripes' field if we have a striped, mirror, or one of
|
||||||
* the raid (raid1, raid4, raid5*, raid6*, or raid10) segtypes in which
|
* the raid (raid1, raid4, raid5*, raid6*, or raid10) segtypes in which
|
||||||
@ -189,11 +186,12 @@ virStorageBackendLogicalParseVolExtents(virStorageVolDef *vol,
|
|||||||
* is the whole matched string.
|
* is the whole matched string.
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < nextents; i++) {
|
for (i = 0; i < nextents; i++) {
|
||||||
size_t j;
|
|
||||||
g_autofree char *offset_str = NULL;
|
g_autofree char *offset_str = NULL;
|
||||||
|
virStorageVolSourceExtent extent;
|
||||||
|
size_t j = (i * 2) + 1;
|
||||||
|
|
||||||
|
memset(&extent, 0, sizeof(extent));
|
||||||
|
|
||||||
j = (i * 2) + 1;
|
|
||||||
extent.path = g_match_info_fetch(info, j);
|
|
||||||
offset_str = g_match_info_fetch(info, j + 1);
|
offset_str = g_match_info_fetch(info, j + 1);
|
||||||
|
|
||||||
if (virStrToLong_ull(offset_str, NULL, 10, &offset) < 0) {
|
if (virStrToLong_ull(offset_str, NULL, 10, &offset) < 0) {
|
||||||
@ -201,6 +199,8 @@ virStorageBackendLogicalParseVolExtents(virStorageVolDef *vol,
|
|||||||
_("malformed volume extent offset value"));
|
_("malformed volume extent offset value"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extent.path = g_match_info_fetch(info, j);
|
||||||
extent.start = offset * size;
|
extent.start = offset * size;
|
||||||
extent.end = (offset * size) + length;
|
extent.end = (offset * size) + length;
|
||||||
|
|
||||||
@ -210,7 +210,6 @@ virStorageBackendLogicalParseVolExtents(virStorageVolDef *vol,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(extent.path);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user