This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch master updated. glibc-2.26.9000-1044-g72f29e3


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  72f29e3aab56cf9bd11d60ae351fbf9d5c709ada (commit)
       via  54e4efc2876b329ba80a6965a2583a906d99e694 (commit)
       via  f8aa69be445f65bb36cb3ae9291423600da7d6d2 (commit)
      from  2bd86632b7cb97dc9002a23795e140fc880e1987 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=72f29e3aab56cf9bd11d60ae351fbf9d5c709ada

commit 72f29e3aab56cf9bd11d60ae351fbf9d5c709ada
Author: Aurelien Jarno <aurelien@aurel32.net>
Date:   Fri Dec 29 14:44:57 2017 +0100

    scandir: fix wrong assumption about errno [BZ #17804]
    
    malloc and realloc may set errno to ENOMEM even if they are successful.
    The scandir code wrongly assume that they do not change errno, this
    causes scandir to fail with ENOMEM even if malloc succeed.
    
    The code already handles that readdir might set errno by calling
    __set_errno (0) to clear the error. Move that part at the end of the
    loop to also take malloc and realloc into account.
    
    Changelog:
    	[BZ #17804]
    	* dirent/scandir-tail.c (SCANDIR_TAIL): Move __set_errno (0) at the
    	end of the loop. Improve comments.

diff --git a/ChangeLog b/ChangeLog
index f87bc14..fd9a8dd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2017-12-29  Aurelien Jarno  <aurelien@aurel32.net>
+
+	[BZ #17804]
+	* dirent/scandir-tail.c (SCANDIR_TAIL): Move __set_errno (0) at the
+	end of the loop. Improve comments.
+
 2017-12-29  Zack Weinberg  <zackw@panix.com>
 
 	[BZ #22615]
diff --git a/dirent/scandir-tail.c b/dirent/scandir-tail.c
index 068c644..a02c99a 100644
--- a/dirent/scandir-tail.c
+++ b/dirent/scandir-tail.c
@@ -53,16 +53,14 @@ SCANDIR_TAIL (DIR *dp,
         {
           int selected = (*select) (d);
 
-	  /* The SELECT function might have changed errno.  It was
-	     zero before and it need to be again to make the later
-	     tests work.  */
+	  /* The SELECT function might have set errno to non-zero on
+	     success.  It was zero before and it needs to be again to
+	     make the later tests work.  */
 	  __set_errno (0);
 
           if (!selected)
             continue;
         }
-      else
-        __set_errno (0);
 
       if (__glibc_unlikely (c.cnt == vsize))
         {
@@ -81,6 +79,11 @@ SCANDIR_TAIL (DIR *dp,
       if (vnew == NULL)
         break;
       v[c.cnt++] = (DIRENT_TYPE *) memcpy (vnew, d, dsize);
+
+      /* Ignore errors from readdir, malloc or realloc.  These functions
+	 might have set errno to non-zero on success.  It was zero before
+	 and it needs to be again to make the latter tests work.  */
+      __set_errno (0);
     }
 
   if (__glibc_likely (errno == 0))

http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=54e4efc2876b329ba80a6965a2583a906d99e694

commit 54e4efc2876b329ba80a6965a2583a906d99e694
Author: Aurelien Jarno <aurelien@aurel32.net>
Date:   Fri Dec 29 14:44:57 2017 +0100

    manual: clarify errno value on success [BZ #22615]
    
    The current glibc manual is ambiguous about the errno value on success
    and suggests that it is left unchanged. Some functions might and
    sometimes do change the errno value, however they never set it to 0.
    
    This patch from Zack Weinberg clarifies this section of the manual.
    
    Changelog:
    	[BZ #22615]
    	* manual/errno.texi (Checking for Errors): Explicitly say that errno
    	might be set on success.

diff --git a/ChangeLog b/ChangeLog
index 02f491b..f87bc14 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2017-12-29  Zack Weinberg  <zackw@panix.com>
+
+	[BZ #22615]
+	* manual/errno.texi (Checking for Errors): Explicitly say that errno
+	might be set on success.
+
 2017-12-29  Aurelien Jarno  <aurelien@aurel32.net>
 
 	[BZ #22611]
diff --git a/manual/errno.texi b/manual/errno.texi
index 3e0b862..73272fd 100644
--- a/manual/errno.texi
+++ b/manual/errno.texi
@@ -47,20 +47,20 @@ However, a properly written signal handler saves and restores the value
 of @code{errno}, so you generally do not need to worry about this
 possibility except when writing signal handlers.
 
-The initial value of @code{errno} at program startup is zero.  Many
-library functions are guaranteed to set it to certain nonzero values
-when they encounter certain kinds of errors.  These error conditions are
-listed for each function.  These functions do not change @code{errno}
-when they succeed; thus, the value of @code{errno} after a successful
-call is not necessarily zero, and you should not use @code{errno} to
-determine @emph{whether} a call failed.  The proper way to do that is
-documented for each function.  @emph{If} the call failed, you can
-examine @code{errno}.
-
-Many library functions can set @code{errno} to a nonzero value as a
-result of calling other library functions which might fail.  You should
-assume that any library function might alter @code{errno} when the
-function returns an error.
+The initial value of @code{errno} at program startup is zero.  In many
+cases, when a library function encounters an error, it will set
+@code{errno} to a non-zero value to indicate what specific error
+condition occurred.  The documentation for each function lists the
+error conditions that are possible for that function.  Not all library
+functions use this mechanism; some return an error code directly,
+instead.
+
+@strong{Warning:} Many library functions may set @code{errno} to some
+meaningless non-zero value even if they did not encounter any errors,
+and even if they return error codes directly.  Therefore, it is
+usually incorrect to check @emph{whether} an error occurred by
+inspecting the value of @code{errno}.  The proper way to check for
+error is documented for each function.
 
 @strong{Portability Note:} @w{ISO C} specifies @code{errno} as a
 ``modifiable lvalue'' rather than as a variable, permitting it to be

http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=f8aa69be445f65bb36cb3ae9291423600da7d6d2

commit f8aa69be445f65bb36cb3ae9291423600da7d6d2
Author: Aurelien Jarno <aurelien@aurel32.net>
Date:   Fri Dec 29 14:44:57 2017 +0100

    tst-realloc: do not check for errno on success [BZ #22611]
    
    POSIX explicitly says that applications should check errno only after
    failure, so the errno value can be clobbered on success as long as it
    is not set to zero.
    
    Changelog:
    	[BZ #22611]
    	* malloc/tst-realloc.c (do_test): Remove the test checking that errno
    	is unchanged on success.

diff --git a/ChangeLog b/ChangeLog
index a1e065e..02f491b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2017-12-29  Aurelien Jarno  <aurelien@aurel32.net>
+
+	[BZ #22611]
+	* malloc/tst-realloc.c (do_test): Remove the test checking that errno
+	is unchanged on success.
+
 2017-12-27  Dmitry V. Levin  <ldv@altlinux.org>
 
 	* elf/dl-dst.h (DL_DST_COUNT): Remove is_path argument, all callers
diff --git a/malloc/tst-realloc.c b/malloc/tst-realloc.c
index 31a58bd..d942c6e 100644
--- a/malloc/tst-realloc.c
+++ b/malloc/tst-realloc.c
@@ -66,10 +66,6 @@ do_test (void)
   if (p == NULL)
     merror ("realloc (NULL, 10) failed.");
 
-  /* errno should be clear on success (POSIX).  */
-  if (p != NULL && save != 0)
-    merror ("errno is set but should not be");
-
   free (p);
 
   p = calloc (20, 1);

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog             |   18 ++++++++++++++++++
 dirent/scandir-tail.c |   13 ++++++++-----
 malloc/tst-realloc.c  |    4 ----
 manual/errno.texi     |   26 +++++++++++++-------------
 4 files changed, 39 insertions(+), 22 deletions(-)


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]