From 97709e185f241b19540c48cd54e6ea6769db06eb Mon Sep 17 00:00:00 2001 From: Yash Ladha Date: Wed, 3 Mar 2021 09:24:36 +0530 Subject: [PATCH] chore: use for(;;) instead of while In the codebase we have used empty for loop for infinite conditions, so to bring consistency replaced other occurrences of while in the codebase with for loop. PR-URL: https://github.com/libuv/libuv/pull/3128 Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig Reviewed-By: Santiago Gimeno --- include/uv/tree.h | 2 +- src/unix/linux-inotify.c | 2 +- src/unix/os390-syscalls.c | 2 +- src/unix/stream.c | 4 ++-- src/win/process.c | 2 +- test/run-tests.c | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/uv/tree.h b/include/uv/tree.h index f936416e..2b28835f 100644 --- a/include/uv/tree.h +++ b/include/uv/tree.h @@ -251,7 +251,7 @@ void name##_SPLAY_MINMAX(struct name *head, int __comp) \ SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL; \ __left = __right = &__node; \ \ - while (1) { \ + for (;;) { \ if (__comp < 0) { \ __tmp = SPLAY_LEFT((head)->sph_root, field); \ if (__tmp == NULL) \ diff --git a/src/unix/linux-inotify.c b/src/unix/linux-inotify.c index 42b601ad..c1bd260e 100644 --- a/src/unix/linux-inotify.c +++ b/src/unix/linux-inotify.c @@ -178,7 +178,7 @@ static void uv__inotify_read(uv_loop_t* loop, /* needs to be large enough for sizeof(inotify_event) + strlen(path) */ char buf[4096]; - while (1) { + for (;;) { do size = read(loop->inotify_fd, buf, sizeof(buf)); while (size == -1 && errno == EINTR); diff --git a/src/unix/os390-syscalls.c b/src/unix/os390-syscalls.c index 2fc85299..c1915533 100644 --- a/src/unix/os390-syscalls.c +++ b/src/unix/os390-syscalls.c @@ -49,7 +49,7 @@ int scandir(const char* maindir, struct dirent*** namelist, if (!mdir) return -1; - while (1) { + for (;;) { dirent = readdir(mdir); if (!dirent) break; diff --git a/src/unix/stream.c b/src/unix/stream.c index 106785e4..c0cb2094 100644 --- a/src/unix/stream.c +++ b/src/unix/stream.c @@ -164,7 +164,7 @@ static void uv__stream_osx_select(void* arg) { else max_fd = s->int_fd; - while (1) { + for (;;) { /* Terminate on semaphore */ if (uv_sem_trywait(&s->close_sem) == 0) break; @@ -195,7 +195,7 @@ static void uv__stream_osx_select(void* arg) { /* Empty socketpair's buffer in case of interruption */ if (FD_ISSET(s->int_fd, s->sread)) - while (1) { + for (;;) { r = read(s->int_fd, buf, sizeof(buf)); if (r == sizeof(buf)) diff --git a/src/win/process.c b/src/win/process.c index 73543c6e..4038fbfd 100644 --- a/src/win/process.c +++ b/src/win/process.c @@ -642,7 +642,7 @@ int env_strncmp(const wchar_t* a, int na, const wchar_t* b) { assert(r==nb); B[nb] = L'\0'; - while (1) { + for (;;) { wchar_t AA = *A++; wchar_t BB = *B++; if (AA < BB) { diff --git a/test/run-tests.c b/test/run-tests.c index 0d6bce1a..5e53aaa8 100644 --- a/test/run-tests.c +++ b/test/run-tests.c @@ -163,7 +163,7 @@ static int maybe_run_test(int argc, char **argv) { if (strcmp(argv[1], "spawn_helper4") == 0) { notify_parent_process(); /* Never surrender, never return! */ - while (1) uv_sleep(10000); + for (;;) uv_sleep(10000); } if (strcmp(argv[1], "spawn_helper5") == 0) {