Skip to content

Commit ccea25f

Browse files
author
Michael Tokarev
committed
os-posix: replace goto again with a proper loop
Eliminiate two fullwrite implementations with goto replacing them with a proper do..while loop. Signed-off-by: Michael Tokarev <[email protected]> Reviewed-by: Gonglei <[email protected]>
1 parent 0be5e43 commit ccea25f

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

os-posix.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,9 @@ void os_daemonize(void)
218218

219219
close(fds[1]);
220220

221-
again:
222-
len = read(fds[0], &status, 1);
223-
if (len == -1 && (errno == EINTR)) {
224-
goto again;
225-
}
221+
do {
222+
len = read(fds[0], &status, 1);
223+
} while (len < 0 && errno == EINTR);
226224
if (len != 1) {
227225
exit(1);
228226
}
@@ -264,11 +262,9 @@ void os_setup_post(void)
264262
uint8_t status = 0;
265263
ssize_t len;
266264

267-
again1:
268-
len = write(daemon_pipe, &status, 1);
269-
if (len == -1 && (errno == EINTR)) {
270-
goto again1;
271-
}
265+
do {
266+
len = write(daemon_pipe, &status, 1);
267+
} while (len < 0 && errno == EINTR);
272268
if (len != 1) {
273269
exit(1);
274270
}

0 commit comments

Comments
 (0)