summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2020-05-25 17:31:00 +0200
committerGitHub <noreply@github.com>2020-05-25 17:31:00 +0200
commita177f05a5ca62af6a24de73416f248d86862e7e0 (patch)
tree5fb6bacc634997db42981f53c809c2ebdc3d43a8 /src
parent15dd451535e384b05fad96fb57cbd3a655ee7fb1 (diff)
parent10b20e5a936e28de47b8c42fab8d73bce528fa8e (diff)
downloadsystemd-a177f05a5ca62af6a24de73416f248d86862e7e0.tar.gz
Merge pull request #15872 from keszybz/networkd-types
Type and parsing fixes for networkd
Diffstat (limited to 'src')
-rw-r--r--src/libsystemd/sd-path/sd-path.c2
-rw-r--r--src/network/networkd-address.c8
-rw-r--r--src/network/networkd-dhcp-server.c38
-rw-r--r--src/network/networkd-dhcp4.c2
4 files changed, 19 insertions, 31 deletions
diff --git a/src/libsystemd/sd-path/sd-path.c b/src/libsystemd/sd-path/sd-path.c
index 2a9c04a84d..9f8397cd37 100644
--- a/src/libsystemd/sd-path/sd-path.c
+++ b/src/libsystemd/sd-path/sd-path.c
@@ -624,7 +624,7 @@ static int get_search(uint64_t type, char ***list) {
case SD_PATH_SYSTEMD_SYSTEM_GENERATOR_PATH:
case SD_PATH_SYSTEMD_USER_GENERATOR_PATH: {
char **t;
- const UnitFileScope scope = type == SD_PATH_SYSTEMD_SYSTEM_UNIT_PATH ?
+ const UnitFileScope scope = type == SD_PATH_SYSTEMD_SYSTEM_GENERATOR_PATH ?
UNIT_FILE_SYSTEM : UNIT_FILE_USER;
t = generator_binary_paths(scope);
diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c
index 1567bd7ee9..9b78530334 100644
--- a/src/network/networkd-address.c
+++ b/src/network/networkd-address.c
@@ -954,7 +954,7 @@ int config_parse_lifetime(const char *unit,
void *userdata) {
Network *network = userdata;
_cleanup_(address_free_or_set_invalidp) Address *n = NULL;
- unsigned k;
+ uint32_t k;
int r;
assert(filename);
@@ -967,8 +967,8 @@ int config_parse_lifetime(const char *unit,
if (r < 0)
return r;
- /* We accept only "forever", "infinity", or "0". */
- if (STR_IN_SET(rvalue, "forever", "infinity"))
+ /* We accept only "forever", "infinity", empty, or "0". */
+ if (STR_IN_SET(rvalue, "forever", "infinity", ""))
k = CACHE_INFO_INFINITY_LIFE_TIME;
else if (streq(rvalue, "0"))
k = 0;
@@ -979,7 +979,7 @@ int config_parse_lifetime(const char *unit,
}
n->cinfo.ifa_prefered = k;
- n = NULL;
+ TAKE_PTR(n);
return 0;
}
diff --git a/src/network/networkd-dhcp-server.c b/src/network/networkd-dhcp-server.c
index 2e9cef590f..3427c6642a 100644
--- a/src/network/networkd-dhcp-server.c
+++ b/src/network/networkd-dhcp-server.c
@@ -21,24 +21,15 @@ static Address* link_find_dhcp_server_address(Link *link) {
assert(link->network);
/* The first statically configured address if there is any */
- LIST_FOREACH(addresses, address, link->network->static_addresses) {
-
- if (address->family != AF_INET)
- continue;
-
- if (in_addr_is_null(address->family, &address->in_addr))
- continue;
-
- return address;
- }
+ LIST_FOREACH(addresses, address, link->network->static_addresses)
+ if (address->family == AF_INET &&
+ !in_addr_is_null(address->family, &address->in_addr))
+ return address;
/* If that didn't work, find a suitable address we got from the pool */
- LIST_FOREACH(addresses, address, link->pool_addresses) {
- if (address->family != AF_INET)
- continue;
-
- return address;
- }
+ LIST_FOREACH(addresses, address, link->pool_addresses)
+ if (address->family == AF_INET)
+ return address;
return NULL;
}
@@ -46,9 +37,8 @@ static Address* link_find_dhcp_server_address(Link *link) {
static int link_push_uplink_dns_to_dhcp_server(Link *link, sd_dhcp_server *s) {
_cleanup_free_ struct in_addr *addresses = NULL;
size_t n_addresses = 0, n_allocated = 0;
- unsigned i;
- for (i = 0; i < link->network->n_dns; i++) {
+ for (unsigned i = 0; i < link->network->n_dns; i++) {
struct in_addr ia;
/* Only look for IPv4 addresses */
@@ -68,16 +58,14 @@ static int link_push_uplink_dns_to_dhcp_server(Link *link, sd_dhcp_server *s) {
}
if (link->network->dhcp_use_dns && link->dhcp_lease) {
- const struct in_addr *da = NULL;
- int j, n;
+ const struct in_addr *da;
- n = sd_dhcp_lease_get_dns(link->dhcp_lease, &da);
+ int n = sd_dhcp_lease_get_dns(link->dhcp_lease, &da);
if (n > 0) {
-
if (!GREEDY_REALLOC(addresses, n_allocated, n_addresses + n))
return log_oom();
- for (j = 0; j < n; j++)
+ for (int j = 0; j < n; j++)
if (in4_addr_is_non_local(&da[j]))
addresses[n_addresses++] = da[j];
}
@@ -160,12 +148,12 @@ static int link_push_uplink_to_dhcp_server(
if (lease_condition && link->dhcp_lease) {
const struct in_addr *da;
- size_t n = sd_dhcp_lease_get_servers(link->dhcp_lease, what, &da);
+ int n = sd_dhcp_lease_get_servers(link->dhcp_lease, what, &da);
if (n > 0) {
if (!GREEDY_REALLOC(addresses, n_allocated, n_addresses + n))
return log_oom();
- for (unsigned i = 0; i < n; i++)
+ for (int i = 0; i < n; i++)
if (in4_addr_is_non_local(&da[i]))
addresses[n_addresses++] = da[i];
}
diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c
index 42e6b5aef2..8e2c775fcf 100644
--- a/src/network/networkd-dhcp4.c
+++ b/src/network/networkd-dhcp4.c
@@ -1691,7 +1691,7 @@ int config_parse_dhcp_fallback_lease_lifetime(const char *unit,
void *data,
void *userdata) {
Network *network = userdata;
- unsigned k;
+ uint32_t k;
assert(filename);
assert(section);