chiark / gitweb /
util: make gcc shut up by passing a 0 mode param to open()
authorLennart Poettering <lennart@poettering.net>
Wed, 17 Jul 2013 00:52:41 +0000 (02:52 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 17 Jul 2013 00:52:41 +0000 (02:52 +0200)
If we pass a variable to open()'s flags parameter it really wants a mode
parameter too, otherwise some gcc version whine. Hence, pass 0 in that
case.

src/shared/util.c

index f56d2a2d33750534bfb7368e45b46b2ea790a67d..5b602ea46d4f1da3c843e977eab1a8317cad199c 100644 (file)
@@ -1875,8 +1875,10 @@ int open_terminal(const char *name, int mode) {
          * https://bugs.launchpad.net/ubuntu/+source/linux/+bug/554172/comments/245
          */
 
+        assert(!(mode & O_CREAT));
+
         for (;;) {
-                fd = open(name, mode);
+                fd = open(name, mode, 0);
                 if (fd >= 0)
                         break;
 
@@ -3520,7 +3522,9 @@ DIR *xopendirat(int fd, const char *name, int flags) {
         int nfd;
         DIR *d;
 
-        nfd = openat(fd, name, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC|flags);
+        assert(!(flags & O_CREAT));
+
+        nfd = openat(fd, name, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC|flags, 0);
         if (nfd < 0)
                 return NULL;