summaryrefslogtreecommitdiffstats
path: root/src/shared/socket-util.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-10-12 18:15:49 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-10-13 23:56:54 +0200
commitb47d419c25ecc735615a1088060c1ec8bef1e41f (patch)
tree13940040841fbec3a928f82426390654e4b50fcc /src/shared/socket-util.c
parentNever call qsort on potentially NULL arrays (diff)
downloadsystemd-b47d419c25ecc735615a1088060c1ec8bef1e41f.tar.xz
systemd-b47d419c25ecc735615a1088060c1ec8bef1e41f.zip
Modernization
Fixes minor leak in error path in device.c.
Diffstat (limited to 'src/shared/socket-util.c')
-rw-r--r--src/shared/socket-util.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/shared/socket-util.c b/src/shared/socket-util.c
index 9224208244..954686f974 100644
--- a/src/shared/socket-util.c
+++ b/src/shared/socket-util.c
@@ -300,7 +300,8 @@ int socket_address_print(const SocketAddress *a, char **p) {
case AF_INET: {
char *ret;
- if (!(ret = new(char, INET_ADDRSTRLEN+1+5+1)))
+ ret = new(char, INET_ADDRSTRLEN+1+5+1);
+ if (!ret)
return -ENOMEM;
if (!inet_ntop(AF_INET, &a->sockaddr.in4.sin_addr, ret, INET_ADDRSTRLEN)) {
@@ -316,7 +317,8 @@ int socket_address_print(const SocketAddress *a, char **p) {
case AF_INET6: {
char *ret;
- if (!(ret = new(char, 1+INET6_ADDRSTRLEN+2+5+1)))
+ ret = new(char, 1+INET6_ADDRSTRLEN+2+5+1);
+ if (!ret)
return -ENOMEM;
ret[0] = '[';
@@ -334,8 +336,8 @@ int socket_address_print(const SocketAddress *a, char **p) {
char *ret;
if (a->size <= offsetof(struct sockaddr_un, sun_path)) {
-
- if (!(ret = strdup("<unnamed>")))
+ ret = strdup("<unnamed>");
+ if (!ret)
return -ENOMEM;
} else if (a->sockaddr.un.sun_path[0] == 0) {
@@ -346,7 +348,8 @@ int socket_address_print(const SocketAddress *a, char **p) {
* more than one NUL byte. That is
* actually an invalid assumption */
- if (!(ret = new(char, sizeof(a->sockaddr.un.sun_path)+1)))
+ ret = new(char, sizeof(a->sockaddr.un.sun_path)+1);
+ if (!ret)
return -ENOMEM;
ret[0] = '@';
@@ -354,8 +357,8 @@ int socket_address_print(const SocketAddress *a, char **p) {
ret[sizeof(a->sockaddr.un.sun_path)] = 0;
} else {
-
- if (!(ret = strdup(a->sockaddr.un.sun_path)))
+ ret = strdup(a->sockaddr.un.sun_path);
+ if (!ret)
return -ENOMEM;
}