Skip to content

Commit

Permalink
Prefer for (;;) to while (TRUE)
Browse files Browse the repository at this point in the history
Defining a special constant to make an infinite loop is excessive,
especially when the name clashes with symbols commonly defined on
some platforms (ie FreeBSD).

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: John Kennedy <john.kennedy@delphix.com
Signed-off-by: Ryan Moeller <ryan@ixsystems.com>
Closes #9219
  • Loading branch information
Ryan Moeller authored and behlendorf committed Aug 28, 2019
1 parent e6203d2 commit 9c9dcd6
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions tests/zfs-tests/cmd/rm_lnkcnt_zero_file/rm_lnkcnt_zero_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
#include <unistd.h>
#include <strings.h>

static const int TRUE = 1;
static char *filebase;

static int
Expand All @@ -65,7 +64,7 @@ mover(void *a)

len = strlen(filebase) + 5;

while (TRUE) {
for (;;) {
idx = pickidx();
(void) snprintf(buf, len, "%s.%03d", filebase, idx);
ret = rename(filebase, buf);
Expand All @@ -85,7 +84,7 @@ cleaner(void *a)

len = strlen(filebase) + 5;

while (TRUE) {
for (;;) {
idx = pickidx();
(void) snprintf(buf, len, "%s.%03d", filebase, idx);
ret = remove(buf);
Expand All @@ -102,7 +101,7 @@ writer(void *a)
int *fd = (int *)a;
int ret;

while (TRUE) {
for (;;) {
if (*fd != -1)
(void) close (*fd);

Expand Down Expand Up @@ -143,7 +142,7 @@ main(int argc, char **argv)
(void) pthread_create(&tid, NULL, cleaner, NULL);
(void) pthread_create(&tid, NULL, writer, (void *) &fd);

while (TRUE) {
for (;;) {
int ret;
struct stat st;

Expand Down

0 comments on commit 9c9dcd6

Please sign in to comment.