mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 03:12:22 +00:00
virlease: Rework virLeaseReadCustomLeaseFile()
There are some variables which are used only inside the single loop the function has. Let's declare them inside the loop body to make that obvious. Also, fix indendation. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
c14bd64f3e
commit
8e5659ed12
@ -50,11 +50,7 @@ virLeaseReadCustomLeaseFile(virJSONValuePtr leases_array_new,
|
||||
{
|
||||
g_autofree char *lease_entries = NULL;
|
||||
g_autoptr(virJSONValue) leases_array = NULL;
|
||||
long long expirytime;
|
||||
int custom_lease_file_len = 0;
|
||||
virJSONValuePtr lease_tmp = NULL;
|
||||
const char *ip_tmp = NULL;
|
||||
const char *server_duid_tmp = NULL;
|
||||
size_t i;
|
||||
|
||||
/* Read entire contents */
|
||||
@ -83,7 +79,11 @@ virLeaseReadCustomLeaseFile(virJSONValuePtr leases_array_new,
|
||||
|
||||
i = 0;
|
||||
while (i < virJSONValueArraySize(leases_array)) {
|
||||
if (!(lease_tmp = virJSONValueArrayGet(leases_array, i))) {
|
||||
virJSONValuePtr lease_tmp = virJSONValueArrayGet(leases_array, i);
|
||||
long long expirytime;
|
||||
const char *ip_tmp = NULL;
|
||||
|
||||
if (!lease_tmp) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("failed to parse json"));
|
||||
return -1;
|
||||
@ -103,9 +103,10 @@ virLeaseReadCustomLeaseFile(virJSONValuePtr leases_array_new,
|
||||
}
|
||||
|
||||
if (server_duid && strchr(ip_tmp, ':')) {
|
||||
const char *server_duid_tmp = NULL;
|
||||
|
||||
/* This is an ipv6 lease */
|
||||
if ((server_duid_tmp
|
||||
= virJSONValueObjectGetString(lease_tmp, "server-duid"))) {
|
||||
if ((server_duid_tmp = virJSONValueObjectGetString(lease_tmp, "server-duid"))) {
|
||||
if (!*server_duid)
|
||||
*server_duid = g_strdup(server_duid_tmp);
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user