changeset 12052:7891d97ab77c

open, openat: minor optimization * 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>
author Eric Blake <ebb9@byu.net>
date Mon, 21 Sep 2009 17:19:10 -0600
parents 01c9ffd58a51
children c86af738f753
files ChangeLog lib/open.c lib/openat.c
diffstat 3 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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
--- a/lib/open.c
+++ b/lib/open.c
@@ -141,8 +141,9 @@
      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;
 
--- a/lib/openat.c
+++ b/lib/openat.c
@@ -103,8 +103,9 @@
      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;