diff options
Diffstat (limited to 'src/libsystemd/sd-netlink')
-rw-r--r-- | src/libsystemd/sd-netlink/generic-netlink.c | 3 | ||||
-rw-r--r-- | src/libsystemd/sd-netlink/local-addresses.c | 6 | ||||
-rw-r--r-- | src/libsystemd/sd-netlink/netlink-message.c | 3 | ||||
-rw-r--r-- | src/libsystemd/sd-netlink/netlink-socket.c | 11 | ||||
-rw-r--r-- | src/libsystemd/sd-netlink/sd-netlink.c | 18 |
5 files changed, 14 insertions, 27 deletions
diff --git a/src/libsystemd/sd-netlink/generic-netlink.c b/src/libsystemd/sd-netlink/generic-netlink.c index 771658d9ae..347bf4cbd5 100644 --- a/src/libsystemd/sd-netlink/generic-netlink.c +++ b/src/libsystemd/sd-netlink/generic-netlink.c @@ -58,8 +58,7 @@ static int genl_message_new(sd_netlink *nl, sd_genl_family family, uint16_t nlms genl->cmd = cmd; genl->version = genl_families[family].version; - *ret = m; - m = NULL; + *ret = TAKE_PTR(m); return 0; } diff --git a/src/libsystemd/sd-netlink/local-addresses.c b/src/libsystemd/sd-netlink/local-addresses.c index 81e55b6d9f..ff9d605ae3 100644 --- a/src/libsystemd/sd-netlink/local-addresses.c +++ b/src/libsystemd/sd-netlink/local-addresses.c @@ -158,8 +158,7 @@ int local_addresses(sd_netlink *context, int ifindex, int af, struct local_addre qsort_safe(list, n_list, sizeof(struct local_address), address_compare); - *ret = list; - list = NULL; + *ret = TAKE_PTR(list); return (int) n_list; } @@ -271,8 +270,7 @@ int local_gateways(sd_netlink *context, int ifindex, int af, struct local_addres if (n_list > 0) qsort(list, n_list, sizeof(struct local_address), address_compare); - *ret = list; - list = NULL; + *ret = TAKE_PTR(list); return (int) n_list; } diff --git a/src/libsystemd/sd-netlink/netlink-message.c b/src/libsystemd/sd-netlink/netlink-message.c index 3a5f9346aa..13d4f4d225 100644 --- a/src/libsystemd/sd-netlink/netlink-message.c +++ b/src/libsystemd/sd-netlink/netlink-message.c @@ -98,8 +98,7 @@ int message_new(sd_netlink *rtnl, sd_netlink_message **ret, uint16_t type) { m->hdr->nlmsg_len = size; m->hdr->nlmsg_type = type; - *ret = m; - m = NULL; + *ret = TAKE_PTR(m); return 0; } diff --git a/src/libsystemd/sd-netlink/netlink-socket.c b/src/libsystemd/sd-netlink/netlink-socket.c index 3474ad9ddb..7db9205d7d 100644 --- a/src/libsystemd/sd-netlink/netlink-socket.c +++ b/src/libsystemd/sd-netlink/netlink-socket.c @@ -433,8 +433,7 @@ int socket_read_message(sd_netlink *rtnl) { /* push the message onto the multi-part message stack */ if (first) m->next = first; - first = m; - m = NULL; + first = TAKE_PTR(m); } if (len > 0) @@ -449,8 +448,7 @@ int socket_read_message(sd_netlink *rtnl) { if (r < 0) return r; - rtnl->rqueue[rtnl->rqueue_size++] = first; - first = NULL; + rtnl->rqueue[rtnl->rqueue_size++] = TAKE_PTR(first); if (multi_part && (i < rtnl->rqueue_partial_size)) { /* remove the message form the partial read queue */ @@ -464,15 +462,14 @@ int socket_read_message(sd_netlink *rtnl) { /* we only got a partial multi-part message, push it on the partial read queue */ if (i < rtnl->rqueue_partial_size) - rtnl->rqueue_partial[i] = first; + rtnl->rqueue_partial[i] = TAKE_PTR(first); else { r = rtnl_rqueue_partial_make_room(rtnl); if (r < 0) return r; - rtnl->rqueue_partial[rtnl->rqueue_partial_size++] = first; + rtnl->rqueue_partial[rtnl->rqueue_partial_size++] = TAKE_PTR(first); } - first = NULL; return 0; } diff --git a/src/libsystemd/sd-netlink/sd-netlink.c b/src/libsystemd/sd-netlink/sd-netlink.c index 116e287bb6..e8fc2644c5 100644 --- a/src/libsystemd/sd-netlink/sd-netlink.c +++ b/src/libsystemd/sd-netlink/sd-netlink.c @@ -62,8 +62,7 @@ static int sd_netlink_new(sd_netlink **ret) { * responses with notifications from the kernel */ rtnl->serial = 1; - *ret = rtnl; - rtnl = NULL; + *ret = TAKE_PTR(rtnl); return 0; } @@ -90,8 +89,7 @@ int sd_netlink_new_from_netlink(sd_netlink **ret, int fd) { rtnl->fd = fd; - *ret = rtnl; - rtnl = NULL; + *ret = TAKE_PTR(rtnl); return 0; } @@ -133,8 +131,7 @@ int sd_netlink_open_fd(sd_netlink **ret, int fd) { return r; } - *ret = rtnl; - rtnl = NULL; + *ret = TAKE_PTR(rtnl); return 0; } @@ -425,8 +422,7 @@ static int process_running(sd_netlink *rtnl, sd_netlink_message **ret) { } if (ret) { - *ret = m; - m = NULL; + *ret = TAKE_PTR(m); return 1; } @@ -669,10 +665,8 @@ int sd_netlink_call(sd_netlink *rtnl, return 0; } - if (ret) { - *ret = incoming; - incoming = NULL; - } + if (ret) + *ret = TAKE_PTR(incoming); return 1; } |