summaryrefslogtreecommitdiff
path: root/src/libsystemd-network/sd-dhcp6-client.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-06-19 09:08:37 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-06-19 09:09:56 -0400
commitc806ffb9592fa9a2b13a1f9f9be4c77cd5b211aa (patch)
tree1cd4f49c677f95516ae242a40b6755d0b0dd45ba /src/libsystemd-network/sd-dhcp6-client.c
parent08d555f347f154d08520a117b9769975cf302e38 (diff)
sd-dhcp6-client: Initialize fd to -1 and rename function
client_initialize name is misleading, since the function is actually useful at the *end*, to reinitialize the object. But reset is shorter, so rename it to client_reset.
Diffstat (limited to 'src/libsystemd-network/sd-dhcp6-client.c')
-rw-r--r--src/libsystemd-network/sd-dhcp6-client.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c
index 01d9ec454f..ef5fb44c4d 100644
--- a/src/libsystemd-network/sd-dhcp6-client.c
+++ b/src/libsystemd-network/sd-dhcp6-client.c
@@ -153,15 +153,13 @@ static sd_dhcp6_client *client_notify(sd_dhcp6_client *client, int event) {
return client;
}
-static int client_initialize(sd_dhcp6_client *client)
-{
+static int client_reset(sd_dhcp6_client *client) {
assert_return(client, -EINVAL);
client->receive_message =
sd_event_source_unref(client->receive_message);
- if (client->fd > 0)
- client->fd = safe_close(client->fd);
+ client->fd = safe_close(client->fd);
client->transaction_id = 0;
@@ -186,7 +184,7 @@ static sd_dhcp6_client *client_stop(sd_dhcp6_client *client, int error) {
client = client_notify(client, error);
if (client)
- client_initialize(client);
+ client_reset(client);
return client;
}
@@ -873,7 +871,7 @@ int sd_dhcp6_client_start(sd_dhcp6_client *client)
assert_return(client->event, -EINVAL);
assert_return(client->index > 0, -EINVAL);
- r = client_initialize(client);
+ r = client_reset(client);
if (r < 0)
return r;
@@ -925,7 +923,7 @@ sd_dhcp6_client *sd_dhcp6_client_ref(sd_dhcp6_client *client) {
sd_dhcp6_client *sd_dhcp6_client_unref(sd_dhcp6_client *client) {
if (client && REFCNT_DEC(client->n_ref) <= 0) {
- client_initialize(client);
+ client_reset(client);
sd_dhcp6_client_detach_event(client);
@@ -958,6 +956,8 @@ int sd_dhcp6_client_new(sd_dhcp6_client **ret)
client->index = -1;
+ client->fd = -1;
+
/* initialize DUID */
client->duid.type = htobe16(DHCP6_DUID_EN);
client->duid.pen = htobe32(SYSTEMD_PEN);