]> git.notmuchmail.org Git - notmuch/commitdiff
cli: for loop is more customary
authorJani Nikula <jani@nikula.org>
Sun, 19 Jan 2014 20:32:25 +0000 (22:32 +0200)
committerDavid Bremner <david@tethera.net>
Sun, 26 Jan 2014 13:41:29 +0000 (09:41 -0400)
With the happy day stop condition within the while, it was
confusing. Switch to the paradigm for loop. No functional changes.

notmuch-new.c

index e6ca8414a939bcb5915a55c060640766ccc5c441..f6d9c3a4508f52cbb2da594a030acee8acdb06b2 100644 (file)
@@ -704,8 +704,7 @@ count_files (const char *path, int *count, add_files_state_t *state)
     char *next;
     struct dirent **fs_entries = NULL;
     int num_fs_entries = scandir (path, &fs_entries, 0, dirent_sort_inode);
     char *next;
     struct dirent **fs_entries = NULL;
     int num_fs_entries = scandir (path, &fs_entries, 0, dirent_sort_inode);
-    int entry_type;
-    int i = 0;
+    int entry_type, i;
 
     if (num_fs_entries == -1) {
        fprintf (stderr, "Warning: failed to open directory %s: %s\n",
 
     if (num_fs_entries == -1) {
        fprintf (stderr, "Warning: failed to open directory %s: %s\n",
@@ -713,11 +712,8 @@ count_files (const char *path, int *count, add_files_state_t *state)
        goto DONE;
     }
 
        goto DONE;
     }
 
-    while (!interrupted) {
-        if (i == num_fs_entries)
-           break;
-
-        entry = fs_entries[i++];
+    for (i = 0; i < num_fs_entries && ! interrupted; i++) {
+        entry = fs_entries[i];
 
        /* Ignore special directories to avoid infinite recursion.
         * Also ignore the .notmuch directory and files/directories
 
        /* Ignore special directories to avoid infinite recursion.
         * Also ignore the .notmuch directory and files/directories