diff options
Diffstat (limited to 'src/core/cgroup.c')
-rw-r--r-- | src/core/cgroup.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/core/cgroup.c b/src/core/cgroup.c index a44cf9368c..5453b5ae96 100644 --- a/src/core/cgroup.c +++ b/src/core/cgroup.c @@ -4,6 +4,7 @@ #include "sd-messages.h" +#include "af-list.h" #include "alloc-util.h" #include "blockdev-util.h" #include "bpf-devices.h" @@ -202,12 +203,10 @@ void cgroup_context_remove_bpf_foreign_program(CGroupContext *c, CGroupBPFForeig } void cgroup_context_remove_socket_bind(CGroupSocketBindItem **head) { - CGroupSocketBindItem *h; - assert(head); while (*head) { - h = *head; + CGroupSocketBindItem *h = *head; LIST_REMOVE(socket_bind_items, *head, h); free(h); } @@ -594,16 +593,18 @@ void cgroup_context_dump(Unit *u, FILE* f, const char *prefix) { } void cgroup_context_dump_socket_bind_item(const CGroupSocketBindItem *item, FILE *f) { - const char *family = item->address_family == AF_INET ? "IPv4:" : - item->address_family == AF_INET6 ? "IPv6:" : ""; + const char *family, *colon; + + family = strempty(af_to_ipv4_ipv6(item->address_family)); + colon = isempty(family) ? "" : ":"; if (item->nr_ports == 0) - fprintf(f, " %sany", family); + fprintf(f, " %s%sany", family, colon); else if (item->nr_ports == 1) - fprintf(f, " %s%" PRIu16, family, item->port_min); + fprintf(f, " %s%s%" PRIu16, family, colon, item->port_min); else { uint16_t port_max = item->port_min + item->nr_ports - 1; - fprintf(f, " %s%" PRIu16 "-%" PRIu16, family, item->port_min, port_max); + fprintf(f, " %s%s%" PRIu16 "-%" PRIu16, family, colon, item->port_min, port_max); } } @@ -1580,7 +1581,7 @@ static bool unit_get_needs_socket_bind(Unit *u) { if (!c) return false; - return c->socket_bind_allow != NULL || c->socket_bind_deny != NULL; + return c->socket_bind_allow || c->socket_bind_deny; } static CGroupMask unit_get_cgroup_mask(Unit *u) { |