Don't include "error.h".
(save_cwd): Don't call error. Ensure that errno is valid
when returning nonzero.
#endif
#include "save-cwd.h"
-#include "error.h"
#include "xgetcwd.h"
/* Record the location of the current working directory in CWD so that
#if HAVE_FCHDIR
cwd->desc = open (".", O_RDONLY | O_DIRECTORY);
if (cwd->desc < 0)
- {
- error (0, errno, "cannot open current directory");
- return 1;
- }
+ return 1;
# if __sun__ || sun
/* On SunOS 4 and IRIX 5.3, fchdir returns EINVAL when auditing
}
else
{
- error (0, errno, "current directory");
+ int saved_errno = errno;
close (cwd->desc);
cwd->desc = -1;
+ errno = saved_errno;
return 1;
}
}
{
cwd->name = xgetcwd ();
if (cwd->name == NULL)
- {
- error (0, errno, "cannot get current directory");
- return 1;
- }
+ return 1;
}
return 0;
}