chiark / gitweb /
mount: don't negate errno when passing it to strerror()
[elogind.git] / util.c
diff --git a/util.c b/util.c
index 8042214c8fae7fdd40494691d216624a26cfeee8..f8b3f44ad15d665aa4a25a48cf44fb62f087a665 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1597,7 +1597,7 @@ int flush_fd(int fd) {
 }
 
 int acquire_terminal(const char *name, bool fail, bool force) {
-        int fd = -1, notify = -1, r, wd;
+        int fd = -1, notify = -1, r, wd = -1;
 
         assert(name);
 
@@ -1627,8 +1627,9 @@ int acquire_terminal(const char *name, bool fail, bool force) {
         }
 
         for (;;) {
-                if ((r = flush_fd(notify)) < 0)
-                        goto fail;
+                if (notify >= 0)
+                        if ((r = flush_fd(notify)) < 0)
+                                goto fail;
 
                 /* We pass here O_NOCTTY only so that we can check the return
                  * value TIOCSCTTY and have a reliable way to figure out if we