diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-06-05 15:12:29 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-06-22 16:32:37 +0200 |
commit | de7fef4b6eb4f5ca1cd21a309c37d0a74d4d305b (patch) | |
tree | ead57ab4a03ef723497b65d0efd79ea8973aaaed /src/network/networkd-dhcp4.c | |
parent | basic/set: add set_ensure_put() (diff) | |
download | systemd-de7fef4b6eb4f5ca1cd21a309c37d0a74d4d305b.tar.xz systemd-de7fef4b6eb4f5ca1cd21a309c37d0a74d4d305b.zip |
tree-wide: use set_ensure_put()
Patch contains a coccinelle script, but it only works in some cases. Many
parts were converted by hand.
Note: I did not fix errors in return value handing. This will be done separate
to keep the patch comprehensible. No functional change is intended in this
patch.
Diffstat (limited to 'src/network/networkd-dhcp4.c')
-rw-r--r-- | src/network/networkd-dhcp4.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c index 8e2c775fcf..6103792771 100644 --- a/src/network/networkd-dhcp4.c +++ b/src/network/networkd-dhcp4.c @@ -1564,7 +1564,6 @@ int config_parse_dhcp_black_listed_ip_address( void *userdata) { Network *network = data; - const char *p; int r; assert(filename); @@ -1577,7 +1576,7 @@ int config_parse_dhcp_black_listed_ip_address( return 0; } - for (p = rvalue;;) { + for (const char *p = rvalue;;) { _cleanup_free_ char *n = NULL; union in_addr_union ip; @@ -1598,11 +1597,7 @@ int config_parse_dhcp_black_listed_ip_address( continue; } - r = set_ensure_allocated(&network->dhcp_black_listed_ip, NULL); - if (r < 0) - return log_oom(); - - r = set_put(network->dhcp_black_listed_ip, UINT32_TO_PTR(ip.in.s_addr)); + r = set_ensure_put(&network->dhcp_black_listed_ip, NULL, UINT32_TO_PTR(ip.in.s_addr)); if (r < 0) log_syntax(unit, LOG_ERR, filename, line, r, "Failed to store DHCP black listed ip address '%s', ignoring assignment: %m", n); |