bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-gnulib] makepath.c fixes for reporting errors and saving errno


From: Paul Eggert
Subject: [Bug-gnulib] makepath.c fixes for reporting errors and saving errno
Date: 14 Aug 2003 16:10:26 -0700
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

This merges changes from coreutils into makepath, and also fixes a bug
where it wasn't preserving errno.

2003-08-14  Paul Eggert  <address@hidden>

        * makepath.c (CLEANUP_CWD): Report an error if we failed to
        return to the initial working directory.  Preserve errno
        for caller.

Index: lib/makepath.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/makepath.c,v
retrieving revision 1.56
diff -p -u -r1.56 makepath.c
--- lib/makepath.c      15 Jul 2003 07:01:49 -0000      1.56
+++ lib/makepath.c      14 Aug 2003 23:05:00 -0000
@@ -105,10 +105,16 @@ extern int errno;
         Restore working directory.  */                 \
       if (do_chdir)                                    \
        {                                               \
-         int _fail = restore_cwd (&cwd, NULL, NULL);   \
+         if (restore_cwd (&cwd) != 0)                  \
+           {                                           \
+             int _saved_errno = errno;                 \
+             error (0, errno,                          \
+               _("failed to return to initial working directory")); \
+             free_cwd (&cwd);                          \
+             errno = _saved_errno;                     \
+             return 1;                                 \
+           }                                           \
          free_cwd (&cwd);                              \
-         if (_fail)                                    \
-           return 1;                                   \
        }                                               \
     }                                                  \
   while (0)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]