mirror of https://github.com/xemu-project/xemu.git
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>
This commit is contained in:
parent
0be5e436ff
commit
ccea25f1c7
12
os-posix.c
12
os-posix.c
|
@ -218,11 +218,9 @@ void os_daemonize(void)
|
||||||
|
|
||||||
close(fds[1]);
|
close(fds[1]);
|
||||||
|
|
||||||
again:
|
do {
|
||||||
len = read(fds[0], &status, 1);
|
len = read(fds[0], &status, 1);
|
||||||
if (len == -1 && (errno == EINTR)) {
|
} while (len < 0 && errno == EINTR);
|
||||||
goto again;
|
|
||||||
}
|
|
||||||
if (len != 1) {
|
if (len != 1) {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -264,11 +262,9 @@ void os_setup_post(void)
|
||||||
uint8_t status = 0;
|
uint8_t status = 0;
|
||||||
ssize_t len;
|
ssize_t len;
|
||||||
|
|
||||||
again1:
|
do {
|
||||||
len = write(daemon_pipe, &status, 1);
|
len = write(daemon_pipe, &status, 1);
|
||||||
if (len == -1 && (errno == EINTR)) {
|
} while (len < 0 && errno == EINTR);
|
||||||
goto again1;
|
|
||||||
}
|
|
||||||
if (len != 1) {
|
if (len != 1) {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue