Skip to content

Commit

Permalink
chore: use for(;;) instead of while
Browse files Browse the repository at this point in the history
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: #3128
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Santiago Gimeno <[email protected]>
  • Loading branch information
yashLadha authored and santigimeno committed Apr 4, 2021
1 parent 59118e9 commit 97709e1
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion include/uv/tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down
2 changes: 1 addition & 1 deletion src/unix/linux-inotify.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/unix/os390-syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/unix/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion src/win/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion test/run-tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 97709e1

Please sign in to comment.