From: Jani Nikula Date: Sun, 19 Jan 2014 20:32:25 +0000 (+0200) Subject: [PATCH 4/7] cli: for loop is more customary X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=34307df912c03ec82e7e7d33bad8f92695d75512;p=notmuch-archives.git [PATCH 4/7] cli: for loop is more customary --- diff --git a/0c/7ad52fbf5ee9796cf63caf038543dccae2865d b/0c/7ad52fbf5ee9796cf63caf038543dccae2865d new file mode 100644 index 000000000..ab866c295 --- /dev/null +++ b/0c/7ad52fbf5ee9796cf63caf038543dccae2865d @@ -0,0 +1,107 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 20C95431FC3 + for ; Sun, 19 Jan 2014 12:32:58 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 1Vpaw7i-x+3o for ; + Sun, 19 Jan 2014 12:32:52 -0800 (PST) +Received: from mail-ee0-f52.google.com (mail-ee0-f52.google.com + [74.125.83.52]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client + certificate requested) by olra.theworths.org (Postfix) with ESMTPS id + E9050431FBD for ; Sun, 19 Jan 2014 12:32:47 -0800 + (PST) +Received: by mail-ee0-f52.google.com with SMTP id e53so3028531eek.25 + for ; Sun, 19 Jan 2014 12:32:46 -0800 (PST) +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20130820; + h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to + :references:in-reply-to:references; + bh=N4dJMow4RocHa/7ftsQnHaKodfp8IRCU94eEfp8y7XI=; + b=cUzVfXWkxbhTV7Uw29NhgETgwWyhav+63cZc4J8+r1pP6oV9RtzFeDNyS2KGXXgDYV + yWuTYgu/nQGlVj7hQsN1xmGMWa59k/DrS26vv78V8inxa4D+VQXrnqqL0V5+tTd57cuC + q1fQ33Oc9bzZ6KUJ/5aVvHdoGvKTeSUdAAucorM2ZXYwbbQLKYhPK+y9X2YGzECtXh0K + 7sNEg6QA3x9pI6++U4KfOouPDmI2QEmDmzj+AbgwV54vTY+VZ8OBYF69eJ9x1g51Ge/G + VFSMwL3u07kvuTDUqwNGq+y85dhWCf8VlXAQtLi+3mDvjBAdr+arTJC1P1CExgLRg7y8 + 9v1w== +X-Gm-Message-State: + ALoCoQnkMrPceWf74/6fS2A6denev87Qdb5YwnCG6H45kMvflwgQcQekRNTAVJxMf/hKLXdWYAhz +X-Received: by 10.14.95.2 with SMTP id o2mr1143545eef.69.1390163566689; + Sun, 19 Jan 2014 12:32:46 -0800 (PST) +Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi. + [88.195.111.91]) + by mx.google.com with ESMTPSA id n7sm46526538eef.5.2014.01.19.12.32.45 + for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Sun, 19 Jan 2014 12:32:46 -0800 (PST) +From: Jani Nikula +To: notmuch@notmuchmail.org +Subject: [PATCH 4/7] cli: for loop is more customary +Date: Sun, 19 Jan 2014 22:32:25 +0200 +Message-Id: + +X-Mailer: git-send-email 1.8.5.2 +In-Reply-To: +References: +In-Reply-To: +References: +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sun, 19 Jan 2014 20:32:58 -0000 + +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 +