X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Fsocket-util.c;h=5ef2e2244c0406874fd8b7cbdd067a610c853fb2;hb=76cf10dab7a36653a159f0e87c46a13df494474f;hp=45ada7eb3ff6ee04d314a8c583edb82a8bec9911;hpb=eff05270986a13e7de93ae16311f654d3f7c166f;p=elogind.git diff --git a/src/shared/socket-util.c b/src/shared/socket-util.c index 45ada7eb3..5ef2e2244 100644 --- a/src/shared/socket-util.c +++ b/src/shared/socket-util.c @@ -422,8 +422,7 @@ const char* socket_address_get_path(const SocketAddress *a) { } bool socket_ipv6_is_supported(void) { - char *l = 0; - bool enabled; + _cleanup_free_ char *l = NULL; if (access("/sys/module/ipv6", F_OK) != 0) return 0; @@ -433,10 +432,7 @@ bool socket_ipv6_is_supported(void) { return 1; /* If module was loaded with disable=1 no IPv6 available */ - enabled = l[0] == '0'; - free(l); - - return enabled; + return l[0] == '0'; } bool socket_address_matches_fd(const SocketAddress *a, int fd) { @@ -589,7 +585,7 @@ int getpeername_pretty(int fd, char **ret) { return -errno; if (sa.sa.sa_family == AF_UNIX) { - struct ucred ucred; + struct ucred ucred = {}; /* UNIX connection sockets are anonymous, so let's use * PID/UID as pretty credentials instead */ @@ -598,7 +594,7 @@ int getpeername_pretty(int fd, char **ret) { if (r < 0) return r; - if (asprintf(ret, "PID %lu/UID %lu", (unsigned long) ucred.pid, (unsigned long) ucred.pid) < 0) + if (asprintf(ret, "PID %lu/UID %lu", (unsigned long) ucred.pid, (unsigned long) ucred.uid) < 0) return -ENOMEM; return 0;