]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
fprintftime: omit unnecessary errno restore
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 1 Nov 2025 04:10:58 +0000 (22:10 -0600)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 1 Nov 2025 04:26:29 +0000 (22:26 -0600)
* lib/strftime.c (__strftime_internal) [FPRINTFTIME]:
Do not restore errno if there is no error,
as the API does not promise this.

ChangeLog
lib/strftime.c

index 055b124247f298552081677326f3e80c14617aae..aaedd7a74cd25cc1ff891e61bd33e08beaa75ee4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2025-10-31  Paul Eggert  <eggert@cs.ucla.edu>
+
+       fprintftime: omit unnecessary errno restore
+       * lib/strftime.c (__strftime_internal) [FPRINTFTIME]:
+       Do not restore errno if there is no error,
+       as the API does not promise this.
+
 2025-10-31  Bruno Haible  <bruno@clisp.org>
 
        posix_spawn_file_actions_addclose: Ignore test failure on NetBSD 10.0.
index afb783778ee5d82d2ae2a8aaf3ecff102796b3d0..2d8eda562226f7eb67e3f8e1e205b1e50f12e681 100644 (file)
@@ -1199,9 +1199,9 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
 #endif
 #if FPRINTFTIME
   byte_count_t maxsize = SBYTE_COUNT_MAX;
-#endif
-
+#else
   int saved_errno = errno;
+#endif
 
 #ifdef _NL_CURRENT
   /* We cannot make the following values variables since we must delay
@@ -2415,8 +2415,8 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
 #if ! FPRINTFTIME
   if (p && maxsize != 0)
     *p = L_('\0');
+  errno = saved_errno;
 #endif
 
-  errno = saved_errno;
   return i;
 }