]> granicus.if.org Git - zfs/commitdiff
Prefer `for (;;)` to `while (TRUE)`
authorRyan Moeller <ryan@freqlabs.com>
Wed, 28 Aug 2019 17:38:40 +0000 (13:38 -0400)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 28 Aug 2019 17:38:40 +0000 (10:38 -0700)
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

tests/zfs-tests/cmd/rm_lnkcnt_zero_file/rm_lnkcnt_zero_file.c

index 7986851efae291a3ac4fac5b40d6fc69159ae25a..e262ecefea92ab6d720b036d006ae5283473c178 100644 (file)
@@ -47,7 +47,6 @@
 #include <unistd.h>
 #include <strings.h>
 
-static const int TRUE = 1;
 static char *filebase;
 
 static int
@@ -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);
@@ -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);
@@ -102,7 +101,7 @@ writer(void *a)
        int *fd = (int *)a;
        int ret;
 
-       while (TRUE) {
+       for (;;) {
                if (*fd != -1)
                        (void) close (*fd);
 
@@ -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;