From: Lennart Poettering Date: Tue, 4 Dec 2018 17:20:12 +0000 (+0100) Subject: socket-util: shorten code a bit X-Git-Tag: v240~137^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=994b9d4e90ef0dcfa3697d8e6d5ca51372f946bd;p=thirdparty%2Fsystemd.git socket-util: shorten code a bit --- diff --git a/src/basic/socket-util.c b/src/basic/socket-util.c index 9bae1552fc4..104d6df4958 100644 --- a/src/basic/socket-util.c +++ b/src/basic/socket-util.c @@ -651,14 +651,10 @@ int sockaddr_pretty(const struct sockaddr *_sa, socklen_t salen, bool translate_ case AF_UNIX: if (salen <= offsetof(struct sockaddr_un, sun_path) || - (sa->un.sun_path[0] == 0 && salen == offsetof(struct sockaddr_un, sun_path) + 1)) { + (sa->un.sun_path[0] == 0 && salen == offsetof(struct sockaddr_un, sun_path) + 1)) /* The name must have at least one character (and the leading NUL does not count) */ - p = strdup(""); - if (!p) - return -ENOMEM; - - } else { + else { size_t path_len = salen - offsetof(struct sockaddr_un, sun_path); if (sa->un.sun_path[0] == 0) { @@ -681,9 +677,9 @@ int sockaddr_pretty(const struct sockaddr *_sa, socklen_t salen, bool translate_ p = cescape_length(sa->un.sun_path, path_len); } - if (!p) - return -ENOMEM; } + if (!p) + return -ENOMEM; break;