open, openat: minor optimization
authorEric Blake <ebb9@byu.net>
Mon, 21 Sep 2009 23:19:10 +0000 (17:19 -0600)
committerEric Blake <ebb9@byu.net>
Tue, 22 Sep 2009 12:38:25 +0000 (06:38 -0600)
* lib/open.c (open): If open succeeded, len is non-zero.
* lib/openat.c (rpl_openat): Likewise.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
lib/open.c
lib/openat.c

index 33dc8ae..4abbe70 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2009-09-22  Eric Blake  <ebb9@byu.net>
 
+       open, openat: minor optimization
+       * lib/open.c (open): If open succeeded, len is non-zero.
+       * lib/openat.c (rpl_openat): Likewise.
+
        link-follow: ensure correct result
        * m4/fcntl_h.m4 (gl_FCNTL_H): Clean up temporary file.
        * m4/link-follow.m4 (gl_FUNC_LINK_FOLLOWS_SYMLINK): Likewise, and
index 08ecaff..7cc25bd 100644 (file)
@@ -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;
 
index 7e46a26..079039f 100644 (file)
@@ -103,8 +103,9 @@ rpl_openat (int dfd, char const *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;