Problem reported by Grisha Levit in:
https://lists.gnu.org/r/bug-gnulib/2024-11/msg00137.html
* lib/savewd.c (savewd_finish):
Set errnum to 0 unless we were in an error state.
* lib/savewd.h (savewd_errno): Report final state errnum too.
+2024-11-17 Paul Eggert <eggert@cs.ucla.edu>
+
+ savewd: set errnum for FINAL_STATE too
+ Problem reported by Grisha Levit in:
+ https://lists.gnu.org/r/bug-gnulib/2024-11/msg00137.html
+ * lib/savewd.c (savewd_finish):
+ Set errnum to 0 unless we were in an error state.
+ * lib/savewd.h (savewd_errno): Report final state errnum too.
+
2024-11-17 Collin Funk <collin.funk1@gmail.com>
doc: Prefer https urls where possible.
{
switch (wd->state)
{
- case INITIAL_STATE:
case ERROR_STATE:
break;
case FD_STATE:
case FD_POST_CHDIR_STATE:
close (wd->val.fd);
+ FALLTHROUGH;
+ case INITIAL_STATE:
+ wd->val.errnum = 0;
break;
case FORKING_STATE:
assure (wd->val.child < 0);
+ wd->val.errnum = 0;
break;
default:
/* savewd_finish has been called, so the application no longer
cares whether the working directory is saved, and there is no
- more work to do. */
+ more work to do. val.errnum contains the error number if
+ there was a serious problem, 0 otherwise. */
FINAL_STATE
} state;
SAVEWD_INLINE int _GL_ATTRIBUTE_PURE
savewd_errno (struct savewd const *wd)
{
- return (wd->state == ERROR_STATE ? wd->val.errnum : 0);
+ return wd->state < ERROR_STATE ? 0 : wd->val.errnum;
}
/* Deallocate any resources associated with WD. A program that chdirs