summaryrefslogtreecommitdiff
path: root/src/libsystemd-network/sd-dhcp-lease.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-03-15 16:14:53 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-03-19 08:10:29 +0900
commit03677889f0ef42cdc534bf3b31265a054b20a354 (patch)
tree53caa0977a8afc5d0ee90e038ffd566e9e22451f /src/libsystemd-network/sd-dhcp-lease.c
parent40f35786b0030f1f7c4b88828776ada1dd74d03e (diff)
downloadsystemd-03677889f0ef42cdc534bf3b31265a054b20a354.tar.gz
list: declare iterator of LIST_FOREACH() in the loop
Diffstat (limited to 'src/libsystemd-network/sd-dhcp-lease.c')
-rw-r--r--src/libsystemd-network/sd-dhcp-lease.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/libsystemd-network/sd-dhcp-lease.c b/src/libsystemd-network/sd-dhcp-lease.c
index 84f3199076..e6e0e08ab2 100644
--- a/src/libsystemd-network/sd-dhcp-lease.c
+++ b/src/libsystemd-network/sd-dhcp-lease.c
@@ -916,13 +916,15 @@ int dhcp_lease_parse_search_domains(const uint8_t *option, size_t len, char ***d
}
int dhcp_lease_insert_private_option(sd_dhcp_lease *lease, uint8_t tag, const void *data, uint8_t len) {
- struct sd_dhcp_raw_option *cur, *option;
+ struct sd_dhcp_raw_option *option, *before = NULL;
assert(lease);
LIST_FOREACH(options, cur, lease->private_options) {
- if (tag < cur->tag)
+ if (tag < cur->tag) {
+ before = cur;
break;
+ }
if (tag == cur->tag) {
log_debug("Ignoring duplicate option, tagged %i.", tag);
return 0;
@@ -941,7 +943,7 @@ int dhcp_lease_insert_private_option(sd_dhcp_lease *lease, uint8_t tag, const vo
return -ENOMEM;
}
- LIST_INSERT_BEFORE(options, lease->private_options, cur, option);
+ LIST_INSERT_BEFORE(options, lease->private_options, before, option);
return 0;
}
@@ -961,7 +963,6 @@ int dhcp_lease_new(sd_dhcp_lease **ret) {
int dhcp_lease_save(sd_dhcp_lease *lease, const char *lease_file) {
_cleanup_(unlink_and_freep) char *temp_path = NULL;
_cleanup_fclose_ FILE *f = NULL;
- struct sd_dhcp_raw_option *option;
struct in_addr address;
const struct in_addr *addresses;
const void *client_id, *data;