Do only one call to GetVersionEx in the common case.
[pspp] / lib / open.c
index 08ecaff44b49efb636931828e54b6b89861445d8..8027b473a5a385816248b638a486abce5071aaf5 100644 (file)
@@ -111,7 +111,7 @@ open (const char *filename, int flags, ...)
      override fstat() in fchdir.c to hide the fact that we have a
      dummy.  */
   if (REPLACE_OPEN_DIRECTORY && fd < 0 && errno == EACCES
-      && (mode & O_ACCMODE) == O_RDONLY)
+      && (flags & O_ACCMODE) == O_RDONLY)
     {
       struct stat statbuf;
       if (stat (filename, &statbuf) == 0 && S_ISDIR (statbuf.st_mode))
@@ -141,8 +141,9 @@ open (const char *filename, int flags, ...)
      with ENOTDIR.  */
   if (fd >= 0)
     {
+      /* We know len is positive, since open did not fail with ENOENT.  */
       size_t len = strlen (filename);
-      if (len > 0 && filename[len - 1] == '/')
+      if (filename[len - 1] == '/')
        {
          struct stat statbuf;