]> git.notmuchmail.org Git - notmuch/commitdiff
cli/insert: clean up sync_dir
authorJani Nikula <jani@nikula.org>
Mon, 22 Sep 2014 09:54:56 +0000 (11:54 +0200)
committerDavid Bremner <david@tethera.net>
Wed, 24 Sep 2014 18:22:21 +0000 (20:22 +0200)
Clarify the code slightly, improve error messages. Apart from the
error message changes, no functional changes.

notmuch-insert.c

index 5d478064540cce70940d21df729926710d20a48a..7375c54888987c062d841c0ab94456d782ec44c8 100644 (file)
@@ -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;
 }
 
 /*