summaryrefslogtreecommitdiff
path: root/src/libsystemd-dhcp
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2013-12-18 10:52:22 +0100
committerTom Gundersen <teg@jklm.no>2013-12-22 14:42:12 +0100
commit23f30ed31218c6bc01d9a0ecebdace43e67e97ff (patch)
tree0192e3bf26a335eccb90d80c2e043d41ca3cf3b3 /src/libsystemd-dhcp
parent3dd714003534ab1588203f854ac4cb1a7a233262 (diff)
libsystemd-dhcp: add some asserts
Diffstat (limited to 'src/libsystemd-dhcp')
-rw-r--r--src/libsystemd-dhcp/dhcp-client.c2
-rw-r--r--src/libsystemd-dhcp/dhcp-network.c7
2 files changed, 8 insertions, 1 deletions
diff --git a/src/libsystemd-dhcp/dhcp-client.c b/src/libsystemd-dhcp/dhcp-client.c
index a8b9354d6e..68a7328348 100644
--- a/src/libsystemd-dhcp/dhcp-client.c
+++ b/src/libsystemd-dhcp/dhcp-client.c
@@ -1061,7 +1061,7 @@ int sd_dhcp_client_start(sd_dhcp_client *client)
int r;
assert_return(client, -EINVAL);
- assert_return(client->index >= 0, -EINVAL);
+ assert_return(client->index > 0, -EINVAL);
assert_return(client->state == DHCP_STATE_INIT ||
client->state == DHCP_STATE_INIT_REBOOT, -EBUSY);
diff --git a/src/libsystemd-dhcp/dhcp-network.c b/src/libsystemd-dhcp/dhcp-network.c
index ce27f425c3..b2de67e8a7 100644
--- a/src/libsystemd-dhcp/dhcp-network.c
+++ b/src/libsystemd-dhcp/dhcp-network.c
@@ -34,6 +34,9 @@ int dhcp_network_bind_raw_socket(int index, union sockaddr_union *link)
{
int s;
+ assert(index > 0);
+ assert(link);
+
s = socket(AF_PACKET, SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK,
htons(ETH_P_IP));
if (s < 0)
@@ -77,6 +80,10 @@ int dhcp_network_bind_udp_socket(int index, be32_t client_address)
int dhcp_network_send_raw_socket(int s, const union sockaddr_union *link,
const void *packet, size_t len)
{
+ assert(link);
+ assert(packet);
+ assert(len);
+
if (sendto(s, packet, len, 0, &link->sa, sizeof(link->ll)) < 0)
return -errno;