[PATCH 4/7] cli: for loop is more customary
authorJani Nikula <jani@nikula.org>
Sun, 19 Jan 2014 20:32:25 +0000 (22:32 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:59:10 +0000 (09:59 -0800)
0c/7ad52fbf5ee9796cf63caf038543dccae2865d [new file with mode: 0644]

diff --git a/0c/7ad52fbf5ee9796cf63caf038543dccae2865d b/0c/7ad52fbf5ee9796cf63caf038543dccae2865d
new file mode 100644 (file)
index 0000000..ab866c2
--- /dev/null
@@ -0,0 +1,107 @@
+Return-Path: <jani@nikula.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 20C95431FC3\r
+       for <notmuch@notmuchmail.org>; Sun, 19 Jan 2014 12:32:58 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id 1Vpaw7i-x+3o for <notmuch@notmuchmail.org>;\r
+       Sun, 19 Jan 2014 12:32:52 -0800 (PST)\r
+Received: from mail-ee0-f52.google.com (mail-ee0-f52.google.com\r
+ [74.125.83.52])       (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
+ certificate requested)        by olra.theworths.org (Postfix) with ESMTPS id\r
+ E9050431FBD   for <notmuch@notmuchmail.org>; Sun, 19 Jan 2014 12:32:47 -0800\r
+ (PST)\r
+Received: by mail-ee0-f52.google.com with SMTP id e53so3028531eek.25\r
+       for <notmuch@notmuchmail.org>; Sun, 19 Jan 2014 12:32:46 -0800 (PST)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+       d=1e100.net; s=20130820;\r
+       h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\r
+       :references:in-reply-to:references;\r
+       bh=N4dJMow4RocHa/7ftsQnHaKodfp8IRCU94eEfp8y7XI=;\r
+       b=cUzVfXWkxbhTV7Uw29NhgETgwWyhav+63cZc4J8+r1pP6oV9RtzFeDNyS2KGXXgDYV\r
+       yWuTYgu/nQGlVj7hQsN1xmGMWa59k/DrS26vv78V8inxa4D+VQXrnqqL0V5+tTd57cuC\r
+       q1fQ33Oc9bzZ6KUJ/5aVvHdoGvKTeSUdAAucorM2ZXYwbbQLKYhPK+y9X2YGzECtXh0K\r
+       7sNEg6QA3x9pI6++U4KfOouPDmI2QEmDmzj+AbgwV54vTY+VZ8OBYF69eJ9x1g51Ge/G\r
+       VFSMwL3u07kvuTDUqwNGq+y85dhWCf8VlXAQtLi+3mDvjBAdr+arTJC1P1CExgLRg7y8\r
+       9v1w==\r
+X-Gm-Message-State:\r
+ ALoCoQnkMrPceWf74/6fS2A6denev87Qdb5YwnCG6H45kMvflwgQcQekRNTAVJxMf/hKLXdWYAhz\r
+X-Received: by 10.14.95.2 with SMTP id o2mr1143545eef.69.1390163566689;\r
+       Sun, 19 Jan 2014 12:32:46 -0800 (PST)\r
+Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi.\r
+       [88.195.111.91])\r
+       by mx.google.com with ESMTPSA id n7sm46526538eef.5.2014.01.19.12.32.45\r
+       for <multiple recipients>\r
+       (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+       Sun, 19 Jan 2014 12:32:46 -0800 (PST)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 4/7] cli: for loop is more customary\r
+Date: Sun, 19 Jan 2014 22:32:25 +0200\r
+Message-Id:\r
+ <cc172ba32a28363d64018803a5dd98ec5381b2f7.1390163335.git.jani@nikula.org>\r
+X-Mailer: git-send-email 1.8.5.2\r
+In-Reply-To: <cover.1390163335.git.jani@nikula.org>\r
+References: <cover.1390163335.git.jani@nikula.org>\r
+In-Reply-To: <cover.1390163335.git.jani@nikula.org>\r
+References: <cover.1390163335.git.jani@nikula.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 19 Jan 2014 20:32:58 -0000\r
+\r
+With the happy day stop condition within the while, it was\r
+confusing. Switch to the paradigm for loop. No functional changes.\r
+---\r
+ notmuch-new.c | 10 +++-------\r
+ 1 file changed, 3 insertions(+), 7 deletions(-)\r
+\r
+diff --git a/notmuch-new.c b/notmuch-new.c\r
+index e6ca841..f6d9c3a 100644\r
+--- a/notmuch-new.c\r
++++ b/notmuch-new.c\r
+@@ -704,8 +704,7 @@ count_files (const char *path, int *count, add_files_state_t *state)\r
+     char *next;\r
+     struct dirent **fs_entries = NULL;\r
+     int num_fs_entries = scandir (path, &fs_entries, 0, dirent_sort_inode);\r
+-    int entry_type;\r
+-    int i = 0;\r
++    int entry_type, i;\r
\r
+     if (num_fs_entries == -1) {\r
+       fprintf (stderr, "Warning: failed to open directory %s: %s\n",\r
+@@ -713,11 +712,8 @@ count_files (const char *path, int *count, add_files_state_t *state)\r
+       goto DONE;\r
+     }\r
\r
+-    while (!interrupted) {\r
+-        if (i == num_fs_entries)\r
+-          break;\r
+-\r
+-        entry = fs_entries[i++];\r
++    for (i = 0; i < num_fs_entries && ! interrupted; i++) {\r
++        entry = fs_entries[i];\r
\r
+       /* Ignore special directories to avoid infinite recursion.\r
+        * Also ignore the .notmuch directory and files/directories\r
+-- \r
+1.8.5.2\r
+\r