aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Tokarev <mjt@tls.msk.ru>2014-10-30 17:37:16 +0300
committerMichael Tokarev <mjt@tls.msk.ru>2014-11-02 10:04:34 +0300
commitccea25f1c7cd3f0b12d878a5294620f5478729f8 (patch)
tree1556e08c8704f09a147dedac0e4795483924b8ac
parent0be5e436ff2cd6b8a1ff6782e3cfd09441ff3ec7 (diff)
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 <mjt@tls.msk.ru> Reviewed-by: Gonglei <arei.gonglei@huawei.com>
-rw-r--r--os-posix.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/os-posix.c b/os-posix.c
index d687896f91..eada8d4685 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -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);
}
@@ -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);
}