}
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;
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) {
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 */
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;