aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Jani Nikula <jani@nikula.org>2014-09-22 11:54:56 +0200
committerGravatar David Bremner <david@tethera.net>2014-09-24 20:22:21 +0200
commiteab18a61a9831d73f22b058d9003a683ef6c6462 (patch)
tree373a49250c240276c7b6921a1a5916bff8c5d6e6
parent9324e04a82e8d483e1cb334138ba64fc4b721513 (diff)
cli/insert: clean up sync_dir
Clarify the code slightly, improve error messages. Apart from the error message changes, no functional changes.
-rw-r--r--notmuch-insert.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/notmuch-insert.c b/notmuch-insert.c
index 5d478064..7375c548 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;
}
/*