From: Zbigniew Jędrzejewski-Szmek Date: Thu, 19 Jun 2014 13:08:37 +0000 (-0400) Subject: sd-dhcp6-client: Initialize fd to -1 and rename function X-Git-Tag: v215~300 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=c806ffb9592fa9a2b13a1f9f9be4c77cd5b211aa;p=elogind.git 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. --- diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c index 01d9ec454..ef5fb44c4 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);