Skip to content

Commit 792222c

Browse files
committed
common/compat: resolve unused label warnings
Found from windows tests: /home/ubuntu/ceph/src/common/compat.cc:135:1: warning: unused label 'fail' [-Wunused-label] fail: ^~~~~ /home/ubuntu/ceph/src/common/compat.cc:159:1: warning: unused label 'fail' [-Wunused-label] fail: ^~~~~ /home/ubuntu/ceph/src/common/compat.cc:210:1: warning: unused label 'fail' [-Wunused-label] fail: ^~~~~ Signed-off-by: Patrick Donnelly <[email protected]>
1 parent 403f5d6 commit 792222c

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/common/compat.cc

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ int pipe_cloexec(int pipefd[2], int flags)
117117
if (pipe(pipefd) == -1)
118118
return -1;
119119

120-
#ifndef _WIN32
120+
# ifdef _WIN32
121+
return 0;
122+
# else
121123
/*
122124
* The old-fashioned, race-condition prone way that we have to fall
123125
* back on if pipe2 does not exist.
@@ -129,14 +131,15 @@ int pipe_cloexec(int pipefd[2], int flags)
129131
if (fcntl(pipefd[1], F_SETFD, FD_CLOEXEC) < 0) {
130132
goto fail;
131133
}
132-
#endif
133134

134135
return 0;
136+
135137
fail:
136138
int save_errno = errno;
137139
VOID_TEMP_FAILURE_RETRY(close(pipefd[0]));
138140
VOID_TEMP_FAILURE_RETRY(close(pipefd[1]));
139141
return (errno = save_errno, -1);
142+
# endif
140143
#endif
141144
}
142145

@@ -150,16 +153,17 @@ int socket_cloexec(int domain, int type, int protocol)
150153
if (fd == -1)
151154
return -1;
152155

153-
#ifndef _WIN32
156+
# ifdef _WIN32
157+
return fd;
158+
# else
154159
if (fcntl(fd, F_SETFD, FD_CLOEXEC) < 0)
155160
goto fail;
156-
#endif
157-
158161
return fd;
159162
fail:
160163
int save_errno = errno;
161164
VOID_TEMP_FAILURE_RETRY(close(fd));
162165
return (errno = save_errno, -1);
166+
# endif
163167
#endif
164168
}
165169

@@ -201,16 +205,18 @@ int accept_cloexec(int sockfd, struct sockaddr* addr, socklen_t* addrlen)
201205
if (fd == -1)
202206
return -1;
203207

204-
#ifndef _WIN32
208+
# ifdef _WIN32
209+
return fd;
210+
# else
205211
if (fcntl(fd, F_SETFD, FD_CLOEXEC) < 0)
206212
goto fail;
207-
#endif
208213

209214
return fd;
210215
fail:
211216
int save_errno = errno;
212217
VOID_TEMP_FAILURE_RETRY(close(fd));
213218
return (errno = save_errno, -1);
219+
# endif
214220
#endif
215221
}
216222

0 commit comments

Comments
 (0)