[pulseaudio-discuss] [PATCH 6/8] core-util: Avoid warnings when missing certain system calls

Peter Meerwald pmeerw at pmeerw.net
Wed Aug 13 01:15:33 PDT 2014


on systems lacking #defines HAVE_ACCEPT4, HAVE_PIPE2, SOCK_CLOEXEC

pulsecore/core-util.c: In function 'pa_open_cloexec':
pulsecore/core-util.c:3348:1: warning: label 'finish' defined but not used [-Wunused-label]
pulsecore/core-util.c: In function 'pa_socket_cloexec':
pulsecore/core-util.c:3370:1: warning: label 'finish' defined but not used [-Wunused-label]
pulsecore/core-util.c: In function 'pa_pipe_cloexec':
pulsecore/core-util.c:3393:1: warning: label 'finish' defined but not used [-Wunused-label]
pulsecore/core-util.c: In function 'pa_accept_cloexec':
pulsecore/core-util.c:3415:1: warning: label 'finish' defined but not used [-Wunused-label]

Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net>
---
 src/pulsecore/core-util.c | 28 ++++++++++++++++++++--------
 1 file changed, 20 insertions(+), 8 deletions(-)

diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index 1f902f4..d7a95d6 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -3342,8 +3342,11 @@ int pa_open_cloexec(const char *fn, int flags, mode_t mode) {
         return fd;
 #endif
 
-    if ((fd = open(fn, flags, mode)) < 0)
-        return fd;
+    if ((fd = open(fn, flags, mode)) >= 0)
+        goto finish;
+
+    /* return error */
+    return fd;
 
 finish:
     /* Some implementations might simply ignore O_CLOEXEC if it is not
@@ -3364,8 +3367,11 @@ int pa_socket_cloexec(int domain, int type, int protocol) {
         return fd;
 #endif
 
-    if ((fd = socket(domain, type, protocol)) < 0)
-        return fd;
+    if ((fd = socket(domain, type, protocol)) >= 0)
+        goto finish;
+
+    /* return error */
+    return fd;
 
 finish:
     /* Some implementations might simply ignore SOCK_CLOEXEC if it is
@@ -3387,8 +3393,11 @@ int pa_pipe_cloexec(int pipefd[2]) {
 
 #endif
 
-    if ((r = pipe(pipefd)) < 0)
-        return r;
+    if ((r = pipe(pipefd)) >= 0)
+        goto finish;
+
+    /* return error */
+    return r;
 
 finish:
     pa_make_fd_cloexec(pipefd[0]);
@@ -3409,8 +3418,11 @@ int pa_accept_cloexec(int sockfd, struct sockaddr *addr, socklen_t *addrlen) {
 
 #endif
 
-    if ((fd = accept(sockfd, addr, addrlen)) < 0)
-        return fd;
+    if ((fd = accept(sockfd, addr, addrlen)) >= 0)
+        goto finish;
+
+    /* return error */
+    return fd;
 
 finish:
     pa_make_fd_cloexec(fd);
-- 
1.9.1



More information about the pulseaudio-discuss mailing list