summaryrefslogtreecommitdiff
path: root/src/libsystemd-network
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2018-04-05 14:26:26 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2018-04-05 14:26:26 +0900
commit1cc6c93a9569a9f2664d0d26cd0e50408307c430 (patch)
tree57e115a1beb9b097f731da79c3192015ff35cc94 /src/libsystemd-network
parent3d282fff063c81893dc4bbd0282193d20dd5357e (diff)
downloadsystemd-1cc6c93a9569a9f2664d0d26cd0e50408307c430.tar.gz
tree-wide: use TAKE_PTR() and TAKE_FD() macros
Diffstat (limited to 'src/libsystemd-network')
-rw-r--r--src/libsystemd-network/lldp-neighbor.c3
-rw-r--r--src/libsystemd-network/ndisc-router.c6
-rw-r--r--src/libsystemd-network/sd-dhcp-client.c12
-rw-r--r--src/libsystemd-network/sd-dhcp-lease.c3
-rw-r--r--src/libsystemd-network/sd-dhcp-server.c6
-rw-r--r--src/libsystemd-network/sd-dhcp6-client.c3
-rw-r--r--src/libsystemd-network/sd-ipv4acd.c6
-rw-r--r--src/libsystemd-network/sd-ipv4ll.c3
-rw-r--r--src/libsystemd-network/sd-lldp.c3
-rw-r--r--src/libsystemd-network/sd-ndisc.c3
-rw-r--r--src/libsystemd-network/sd-radv.c14
11 files changed, 20 insertions, 42 deletions
diff --git a/src/libsystemd-network/lldp-neighbor.c b/src/libsystemd-network/lldp-neighbor.c
index 1a6ea288aa..84231091d0 100644
--- a/src/libsystemd-network/lldp-neighbor.c
+++ b/src/libsystemd-network/lldp-neighbor.c
@@ -674,8 +674,7 @@ _public_ int sd_lldp_neighbor_from_raw(sd_lldp_neighbor **ret, const void *raw,
if (r < 0)
return r;
- *ret = n;
- n = NULL;
+ *ret = TAKE_PTR(n);
return r;
}
diff --git a/src/libsystemd-network/ndisc-router.c b/src/libsystemd-network/ndisc-router.c
index 2954928d00..4584f59d1e 100644
--- a/src/libsystemd-network/ndisc-router.c
+++ b/src/libsystemd-network/ndisc-router.c
@@ -82,8 +82,7 @@ _public_ int sd_ndisc_router_from_raw(sd_ndisc_router **ret, const void *raw, si
if (r < 0)
return r;
- *ret = rt;
- rt = NULL;
+ *ret = TAKE_PTR(rt);
return r;
}
@@ -765,8 +764,7 @@ _public_ int sd_ndisc_router_dnssl_get_domains(sd_ndisc_router *rt, char ***ret)
return 0;
}
- *ret = l;
- l = NULL;
+ *ret = TAKE_PTR(l);
return k;
}
diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c
index 9cf49747e0..a8b0a81484 100644
--- a/src/libsystemd-network/sd-dhcp-client.c
+++ b/src/libsystemd-network/sd-dhcp-client.c
@@ -682,8 +682,7 @@ static int client_message_init(
*_optlen = optlen;
*_optoffset = optoffset;
- *ret = packet;
- packet = NULL;
+ *ret = TAKE_PTR(packet);
return 0;
}
@@ -1288,8 +1287,7 @@ static int client_handle_offer(sd_dhcp_client *client, DHCPMessage *offer, size_
}
sd_dhcp_lease_unref(client->lease);
- client->lease = lease;
- lease = NULL;
+ client->lease = TAKE_PTR(lease);
log_dhcp_client(client, "OFFER");
@@ -1370,8 +1368,7 @@ static int client_handle_ack(sd_dhcp_client *client, DHCPMessage *ack, size_t le
client->lease = sd_dhcp_lease_unref(client->lease);
}
- client->lease = lease;
- lease = NULL;
+ client->lease = TAKE_PTR(lease);
log_dhcp_client(client, "ACK");
@@ -1966,8 +1963,7 @@ int sd_dhcp_client_new(sd_dhcp_client **ret, int anonymize) {
if (!client->req_opts)
return -ENOMEM;
- *ret = client;
- client = NULL;
+ *ret = TAKE_PTR(client);
return 0;
}
diff --git a/src/libsystemd-network/sd-dhcp-lease.c b/src/libsystemd-network/sd-dhcp-lease.c
index 9db0a93898..d33e208a00 100644
--- a/src/libsystemd-network/sd-dhcp-lease.c
+++ b/src/libsystemd-network/sd-dhcp-lease.c
@@ -1235,8 +1235,7 @@ int dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file) {
return r;
}
- *ret = lease;
- lease = NULL;
+ *ret = TAKE_PTR(lease);
return 0;
}
diff --git a/src/libsystemd-network/sd-dhcp-server.c b/src/libsystemd-network/sd-dhcp-server.c
index 25f5b378bc..e88dcd0ac7 100644
--- a/src/libsystemd-network/sd-dhcp-server.c
+++ b/src/libsystemd-network/sd-dhcp-server.c
@@ -213,8 +213,7 @@ int sd_dhcp_server_new(sd_dhcp_server **ret, int ifindex) {
server->default_lease_time = DIV_ROUND_UP(DHCP_DEFAULT_LEASE_TIME_USEC, USEC_PER_SEC);
server->max_lease_time = DIV_ROUND_UP(DHCP_MAX_LEASE_TIME_USEC, USEC_PER_SEC);
- *ret = server;
- server = NULL;
+ *ret = TAKE_PTR(server);
return 0;
}
@@ -446,8 +445,7 @@ static int server_message_init(sd_dhcp_server *server, DHCPPacket **ret,
memcpy(&packet->dhcp.chaddr, &req->message->chaddr, ETH_ALEN);
*_optoffset = optoffset;
- *ret = packet;
- packet = NULL;
+ *ret = TAKE_PTR(packet);
return 0;
}
diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c
index 056bfa3d3d..ff88c2bca9 100644
--- a/src/libsystemd-network/sd-dhcp6-client.c
+++ b/src/libsystemd-network/sd-dhcp6-client.c
@@ -1466,8 +1466,7 @@ int sd_dhcp6_client_new(sd_dhcp6_client **ret) {
for (t = 0; t < client->req_opts_len; t++)
client->req_opts[t] = htobe16(default_req_opts[t]);
- *ret = client;
- client = NULL;
+ *ret = TAKE_PTR(client);
return 0;
}
diff --git a/src/libsystemd-network/sd-ipv4acd.c b/src/libsystemd-network/sd-ipv4acd.c
index 7cf4f031de..ff36f3eec1 100644
--- a/src/libsystemd-network/sd-ipv4acd.c
+++ b/src/libsystemd-network/sd-ipv4acd.c
@@ -153,8 +153,7 @@ int sd_ipv4acd_new(sd_ipv4acd **ret) {
acd->ifindex = -1;
acd->fd = -1;
- *ret = acd;
- acd = NULL;
+ *ret = TAKE_PTR(acd);
return 0;
}
@@ -207,8 +206,7 @@ static int ipv4acd_set_next_wakeup(sd_ipv4acd *acd, usec_t usec, usec_t random_u
(void) sd_event_source_set_description(timer, "ipv4acd-timer");
sd_event_source_unref(acd->timer_event_source);
- acd->timer_event_source = timer;
- timer = NULL;
+ acd->timer_event_source = TAKE_PTR(timer);
return 0;
}
diff --git a/src/libsystemd-network/sd-ipv4ll.c b/src/libsystemd-network/sd-ipv4ll.c
index f3d09eb30a..0ac4c88255 100644
--- a/src/libsystemd-network/sd-ipv4ll.c
+++ b/src/libsystemd-network/sd-ipv4ll.c
@@ -115,8 +115,7 @@ int sd_ipv4ll_new(sd_ipv4ll **ret) {
if (r < 0)
return r;
- *ret = ll;
- ll = NULL;
+ *ret = TAKE_PTR(ll);
return 0;
}
diff --git a/src/libsystemd-network/sd-lldp.c b/src/libsystemd-network/sd-lldp.c
index 2c05416184..54b5e975ad 100644
--- a/src/libsystemd-network/sd-lldp.c
+++ b/src/libsystemd-network/sd-lldp.c
@@ -402,8 +402,7 @@ _public_ int sd_lldp_new(sd_lldp **ret) {
if (r < 0)
return r;
- *ret = lldp;
- lldp = NULL;
+ *ret = TAKE_PTR(lldp);
return 0;
}
diff --git a/src/libsystemd-network/sd-ndisc.c b/src/libsystemd-network/sd-ndisc.c
index b5c6d6e84d..c17df429c1 100644
--- a/src/libsystemd-network/sd-ndisc.c
+++ b/src/libsystemd-network/sd-ndisc.c
@@ -166,8 +166,7 @@ _public_ int sd_ndisc_new(sd_ndisc **ret) {
nd->n_ref = 1;
nd->fd = -1;
- *ret = nd;
- nd = NULL;
+ *ret = TAKE_PTR(nd);
return 0;
}
diff --git a/src/libsystemd-network/sd-radv.c b/src/libsystemd-network/sd-radv.c
index f30d6164ea..06fc0fb746 100644
--- a/src/libsystemd-network/sd-radv.c
+++ b/src/libsystemd-network/sd-radv.c
@@ -51,8 +51,7 @@ _public_ int sd_radv_new(sd_radv **ret) {
LIST_HEAD_INIT(ra->prefixes);
- *ret = ra;
- ra = NULL;
+ *ret = TAKE_PTR(ra);
return 0;
}
@@ -670,9 +669,7 @@ _public_ int sd_radv_set_rdnss(sd_radv *ra, uint32_t lifetime,
memcpy(opt_rdnss + 1, dns, n_dns * sizeof(struct in6_addr));
- free(ra->rdnss);
- ra->rdnss = opt_rdnss;
- opt_rdnss = NULL;
+ free_and_replace(ra->rdnss, opt_rdnss);
ra->n_rdnss = n_dns;
@@ -724,9 +721,7 @@ _public_ int sd_radv_set_dnssl(sd_radv *ra, uint32_t lifetime,
len -= r;
}
- free(ra->dnssl);
- ra->dnssl = opt_dnssl;
- opt_dnssl = NULL;
+ free_and_replace(ra->dnssl, opt_dnssl);
return 0;
}
@@ -755,8 +750,7 @@ _public_ int sd_radv_prefix_new(sd_radv_prefix **ret) {
LIST_INIT(prefix, p);
- *ret = p;
- p = NULL;
+ *ret = TAKE_PTR(p);
return 0;
}