socket-server: pa_socket_server_new() can't fail, so don't check its return value
authorTanu Kaskinen <tanu.kaskinen@linux.intel.com>
Mon, 3 Nov 2014 09:47:58 +0000 (11:47 +0200)
committerDavid Henningsson <david.henningsson@canonical.com>
Thu, 12 Feb 2015 19:33:44 +0000 (20:33 +0100)
An assertion was already used in pa_socket_server_new_unix(), this
makes the TCP variants consistent with that.

Even if pa_socket_server_new() could fail, the error handling wasn't
good, because there was no "goto fail", meaning that the fd would have
been leaked.

src/pulsecore/socket-server.c

index d1f83f4..ce61694 100644 (file)
@@ -298,10 +298,10 @@ pa_socket_server* pa_socket_server_new_ipv4(pa_mainloop_api *m, uint32_t address
         goto fail;
     }
 
-    if ((ss = pa_socket_server_new(m, fd))) {
-        ss->type = SOCKET_SERVER_IPV4;
-        ss->tcpwrap_service = pa_xstrdup(tcpwrap_service);
-    }
+    pa_assert_se(ss = pa_socket_server_new(m, fd));
+
+    ss->type = SOCKET_SERVER_IPV4;
+    ss->tcpwrap_service = pa_xstrdup(tcpwrap_service);
 
     return ss;
 
@@ -366,10 +366,10 @@ pa_socket_server* pa_socket_server_new_ipv6(pa_mainloop_api *m, const uint8_t ad
         goto fail;
     }
 
-    if ((ss = pa_socket_server_new(m, fd))) {
-        ss->type = SOCKET_SERVER_IPV6;
-        ss->tcpwrap_service = pa_xstrdup(tcpwrap_service);
-    }
+    pa_assert_se(ss = pa_socket_server_new(m, fd));
+
+    ss->type = SOCKET_SERVER_IPV6;
+    ss->tcpwrap_service = pa_xstrdup(tcpwrap_service);
 
     return ss;