From 68f2eb5fb4263fb87061b3dd56b4de96575422ba Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Mon, 22 Sep 2014 11:54:56 +0200 Subject: [PATCH] [PATCH 05/11] cli/insert: clean up sync_dir --- 53/c12d713b2e8d1018d65b94e44a3a775f61d52f | 112 ++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 53/c12d713b2e8d1018d65b94e44a3a775f61d52f diff --git a/53/c12d713b2e8d1018d65b94e44a3a775f61d52f b/53/c12d713b2e8d1018d65b94e44a3a775f61d52f new file mode 100644 index 000000000..40dd055ed --- /dev/null +++ b/53/c12d713b2e8d1018d65b94e44a3a775f61d52f @@ -0,0 +1,112 @@ +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 09B41431FC0 + for ; Mon, 22 Sep 2014 02:55:10 -0700 (PDT) +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 uIELfe9UHaFi for ; + Mon, 22 Sep 2014 02:55:05 -0700 (PDT) +Received: from mail-wg0-f42.google.com (mail-wg0-f42.google.com + [74.125.82.42]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client + certificate requested) by olra.theworths.org (Postfix) with ESMTPS id + 689DD431FD6 for ; Mon, 22 Sep 2014 02:54:55 -0700 + (PDT) +Received: by mail-wg0-f42.google.com with SMTP id a1so2348556wgh.1 + for ; Mon, 22 Sep 2014 02:54:54 -0700 (PDT) +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=g252OVOEA7aR4wJyrkyAhoI1GVvMzteOx09BSIxMPzk=; + b=XMH63M7Fr9d17VNBQjKKbihD5tMCLGqZVq8G7pvNAy8kER4Xv00BSDOCWLarJw9Vmg + dV7SatSzeJV2MwvMNqniaSC7Ckui5N/bUotX9mbeVIIogfL/t1JMYfpyNQocMX9iH2ck + saMOO/+hgYUvbkBOxA20VHF1FqxPDTVq1o31cVElouhh2mTHkGCr5gjDw52gKQuRfDpd + zDoJIknVv5DjVPNu12W6o7YxtXrxOsbcoH2ahr01M2jwGGtf8Xf3cc9Gpd01DU6mSVYf + r65AJ8jUQlWB7uwoggJLZjR2yljkt6Y3KgaQKuY2gVqh/L0Ab1XfxvtB/PvUEVwrV/jo + 6CHw== +X-Gm-Message-State: + ALoCoQmE8xaQ1SjEe/i3zIsw92SFN0YbloD0bceJaWOx7H4Xvqiwj4QvZQEZjjCZkf9zVDWqf6Pf +X-Received: by 10.180.100.167 with SMTP id ez7mr13932016wib.14.1411379694347; + Mon, 22 Sep 2014 02:54:54 -0700 (PDT) +Received: from localhost ([2001:4b98:dc0:43:216:3eff:fe1b:25f3]) + by mx.google.com with ESMTPSA id + mx19sm11505404wic.3.2014.09.22.02.54.53 for + (version=TLSv1.1 cipher=RC4-SHA bits=128/128); + Mon, 22 Sep 2014 02:54:53 -0700 (PDT) +From: Jani Nikula +To: notmuch@notmuchmail.org +Subject: [PATCH 05/11] cli/insert: clean up sync_dir +Date: Mon, 22 Sep 2014 11:54:56 +0200 +Message-Id: + <7d3e24291b8d4cc0d11b1a87249bbebed4e78648.1411379395.git.jani@nikula.org> +X-Mailer: git-send-email 1.7.2.5 +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: Mon, 22 Sep 2014 09:55:10 -0000 + +Clarify the code slightly, improve error messages. Apart from the +error message changes, no functional changes. +--- + notmuch-insert.c | 17 +++++++++-------- + 1 files changed, 9 insertions(+), 8 deletions(-) + +diff --git a/notmuch-insert.c b/notmuch-insert.c +index 5d47806..7375c54 100644 +--- a/notmuch-insert.c ++++ b/notmuch-insert.c +@@ -67,20 +67,21 @@ safe_gethostname (char *hostname, size_t len) + static notmuch_bool_t + sync_dir (const char *dir) + { +- notmuch_bool_t ret; +- int fd; ++ int fd, r; + + fd = open (dir, O_RDONLY); + if (fd == -1) { +- fprintf (stderr, "Error: open() dir failed: %s\n", strerror (errno)); ++ fprintf (stderr, "Error: open %s: %s\n", dir, strerror (errno)); + return FALSE; + } +- ret = (fsync (fd) == 0); +- if (! ret) { +- fprintf (stderr, "Error: fsync() dir failed: %s\n", strerror (errno)); +- } ++ ++ r = fsync (fd); ++ if (r) ++ fprintf (stderr, "Error: fsync %s: %s\n", dir, strerror (errno)); ++ + close (fd); +- return ret; ++ ++ return r == 0; + } + + /* +-- +1.7.2.5 + -- 2.26.2