unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Jani Nikula <jani@nikula.org>
To: notmuch@notmuchmail.org
Subject: [PATCH 4/7] cli: for loop is more customary
Date: Sun, 19 Jan 2014 22:32:25 +0200	[thread overview]
Message-ID: <cc172ba32a28363d64018803a5dd98ec5381b2f7.1390163335.git.jani@nikula.org> (raw)
In-Reply-To: <cover.1390163335.git.jani@nikula.org>
In-Reply-To: <cover.1390163335.git.jani@nikula.org>

With the happy day stop condition within the while, it was
confusing. Switch to the paradigm for loop. No functional changes.
---
 notmuch-new.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/notmuch-new.c b/notmuch-new.c
index e6ca841..f6d9c3a 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -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);
-    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",
@@ -713,11 +712,8 @@ count_files (const char *path, int *count, add_files_state_t *state)
 	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
-- 
1.8.5.2

  parent reply	other threads:[~2014-01-19 20:32 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-19 20:32 [PATCH 0/7] cli: notmuch new improvements Jani Nikula
2014-01-19 20:32 ` [PATCH 1/7] cli: extract single message addition in notmuch new to clarify code Jani Nikula
2014-01-19 20:32 ` [PATCH 2/7] cli: only check the ignore list if needed Jani Nikula
2014-01-19 20:32 ` [PATCH 3/7] cli: use dirent_type in count_files too Jani Nikula
2014-01-19 20:32 ` Jani Nikula [this message]
2014-01-19 20:32 ` [PATCH 5/7] cli: abstract notmuch new result printing Jani Nikula
2014-01-19 20:32 ` [PATCH 6/7] cli: add --quiet option to notmuch new Jani Nikula
2014-01-24  8:58   ` Mark Walters
2014-01-24  9:54     ` Jani Nikula
2014-01-19 20:32 ` [PATCH 7/7] man: document notmuch new --quiet option Jani Nikula
2014-01-25  8:38 ` [PATCH 0/7] cli: notmuch new improvements Mark Walters
2014-01-25 14:59   ` automatic database upgrades (was: Re: [PATCH 0/7] cli: notmuch new improvements) Jani Nikula
2014-01-25 17:32     ` Mark Walters
2014-01-25 19:29       ` Jani Nikula
2014-01-25 17:29 ` [PATCH 0/7] cli: notmuch new improvements Tomi Ollila
2014-01-26 14:06 ` David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cc172ba32a28363d64018803a5dd98ec5381b2f7.1390163335.git.jani@nikula.org \
    --to=jani@nikula.org \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).