Skip to content

Commit

Permalink
os-posix: replace goto again with a proper loop
Browse files Browse the repository at this point in the history
Eliminiate two fullwrite implementations with goto replacing them with
a proper do..while loop.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Gonglei <arei.gonglei@huawei.com>
  • Loading branch information
Michael Tokarev committed Nov 2, 2014
1 parent 0be5e43 commit ccea25f
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions os-posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,9 @@ void os_daemonize(void)

close(fds[1]);

again:
len = read(fds[0], &status, 1);
if (len == -1 && (errno == EINTR)) {
goto again;
}
do {
len = read(fds[0], &status, 1);
} while (len < 0 && errno == EINTR);
if (len != 1) {
exit(1);
}
Expand Down Expand Up @@ -264,11 +262,9 @@ void os_setup_post(void)
uint8_t status = 0;
ssize_t len;

again1:
len = write(daemon_pipe, &status, 1);
if (len == -1 && (errno == EINTR)) {
goto again1;
}
do {
len = write(daemon_pipe, &status, 1);
} while (len < 0 && errno == EINTR);
if (len != 1) {
exit(1);
}
Expand Down

0 comments on commit ccea25f

Please sign in to comment.