]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
coccinelle: s/while({1,true})/for(;;)/
authorChristian Brauner <christian.brauner@ubuntu.com>
Fri, 8 Feb 2019 22:57:06 +0000 (23:57 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Sat, 9 Feb 2019 10:05:12 +0000 (11:05 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
coccinelle/while-true.cocci [new file with mode: 0644]
src/lxc/cmd/lxc_init.c
src/lxc/lxccontainer.c
src/lxc/network.c
src/lxc/pam/pam_cgfs.c
src/lxc/storage/btrfs.c
src/lxc/storage/nbd.c
src/lxc/string_utils.c
src/lxc/tools/arguments.c
src/lxc/utils.c

diff --git a/coccinelle/while-true.cocci b/coccinelle/while-true.cocci
new file mode 100644 (file)
index 0000000..c23fb11
--- /dev/null
@@ -0,0 +1,12 @@
+@@
+statement s;
+@@
+- while (true)
++ for (;;)
+s
+@@
+statement s;
+@@
+- while (1)
++ for (;;)
+s
index b3849545aadee25d53f8b8b55d19460d3162230a..7b94f37b6e3952697d890537d08e57f44e42665d 100644 (file)
@@ -492,7 +492,7 @@ See the lxc-init man page for further information.\n\n");
 static int arguments_parse(struct arguments *args, int argc,
                           char *const argv[])
 {
-       while (true) {
+       for (;;) {
                int c;
                int index = 0;
 
index 3a6696039f6bafc383a4d1c0fccacae14a68186f..9875a58a373872ddade5bbbfc874ace92059f6fa 100644 (file)
@@ -3365,7 +3365,7 @@ static int copy_file(const char *old, const char *new)
                return -1;
        }
 
-       while (1) {
+       for (;;) {
                len = lxc_read_nointr(in, buf, 8096);
                if (len < 0) {
                        SYSERROR("Error reading old file %s", old);
@@ -4100,7 +4100,7 @@ static int get_next_index(const char *lxcpath, char *cname)
 
        fname = must_realloc(NULL, strlen(lxcpath) + 20);
 
-       while (1) {
+       for (;;) {
                sprintf(fname, "%s/snap%d", lxcpath, i);
 
                ret = stat(fname, &sb);
index 249d9d471f1e432ac37c7099b62d3cbbfc49b204..e05c5661577420bb2a7bd5f5059aba17c866ee9e 100644 (file)
@@ -1974,7 +1974,7 @@ char *lxc_mkifname(char *template)
        }
 
        /* Generate random names until we find one that doesn't exist. */
-       while (true) {
+       for (;;) {
                name[0] = '\0';
                (void)strlcpy(name, template, IFNAMSIZ);
 
index 1a377d7aa4fca195e9407041996ba97a782f42eb..2fb3f73786cb77d46ac4f91f36f15090b98280e7 100644 (file)
@@ -259,7 +259,7 @@ static bool mkdir_parent(const char *root, char *path)
                return true;
 
        b = path + strlen(root) + 1;
-       while (true) {
+       for (;;) {
                while (*b && (*b == '/'))
                        b++;
                if (!*b)
@@ -878,7 +878,7 @@ static char *cgv1_get_current_cgroup(char *basecginfo, char *controller)
 
        p = basecginfo;
 
-       while (true) {
+       for (;;) {
                p = strchr(p, ':');
                if (!p)
                        return NULL;
index bbfce61b9fef5d1a12a4acc8ca9a30f4ba0ef91b..06ec7e8c7dfd7f1ecc28e891d209edfdd90f8e32 100644 (file)
@@ -805,7 +805,7 @@ static int btrfs_recursive_destroy(const char *path)
        sk->max_transid = (u64)-1;
        sk->nr_items = 4096;
 
-       while(1) {
+       for (;;) {
                ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args);
                e = errno;
                if (ret < 0) {
index 8b19d63ac00f206fe49f723db181ccc4b112aae3..09990467ad9749a49780259b72c4b667e9e2c4c2 100644 (file)
@@ -72,7 +72,7 @@ bool attach_nbd(char *src, struct lxc_conf *conf)
        if (p)
                *p = '\0';
 
-       while (1) {
+       for (;;) {
                sprintf(path, "/dev/nbd%d", i);
 
                if (!file_exists(path))
index 184921c111751718dd7a75086fd3eaaa190acdae..eb83f55051a0546ad960b5bdd97c0b383bca45e2 100644 (file)
@@ -69,7 +69,7 @@ char **lxc_va_arg_list_to_argv(va_list ap, size_t skip, int do_strdup)
         * constantly...
         */
        va_copy(ap2, ap);
-       while (1) {
+       for (;;) {
                char *arg = va_arg(ap2, char *);
                if (!arg)
                        break;
@@ -82,7 +82,7 @@ char **lxc_va_arg_list_to_argv(va_list ap, size_t skip, int do_strdup)
                return NULL;
 
        count = skip;
-       while (1) {
+       for (;;) {
                char *arg = va_arg(ap, char *);
                if (!arg)
                        break;
index 99b3462070a1caa7be3e854c04fa2f56ed09c856..f335f62250bf9a980bfd664cb2af0758201d8457 100644 (file)
@@ -207,7 +207,7 @@ extern int lxc_arguments_parse(struct lxc_arguments *args, int argc,
                return ret;
        }
 
-       while (true) {
+       for (;;) {
                int c;
                int index = 0;
 
index 560e333ef64d466c923ea00c0038c71b66f0c805..be81727c3cd7032b5c5bac8390119c397cba65e8 100644 (file)
@@ -1101,7 +1101,7 @@ static int open_without_symlink(const char *target, const char *prefix_skip)
                goto out;
        }
 
-       while (1) {
+       for (;;) {
                int newfd, saved_errno;
                char *nextpath;