From 22626a856b520e4b092b2e4132f57adf8aaf7227 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 26 Nov 2012 21:17:07 -0800 Subject: [PATCH] Assume POSIX 1003.1-1988 or later for errno.h. * lib-src/movemail.c (main): Assume EAGAIN and EBUSY. * src/dired.c (directory_files_internal, file_name_completion): Assume EAGAIN and EINTR are defined. * src/fileio.c (Fcopy_file): Assume EISDIR is defined. * src/gmalloc.c (ENOMEM, EINVAL): Assume they're defined. * src/gnutls.c (emacs_gnutls_write): Assume EAGAIN is defined. * src/lread.c (readbyte_from_file): Assume EINTR is defined. * src/process.c (wait_reading_process_output, send_process) [subprocesses]: Assume EIO and EAGAIN are defined. * src/unexcoff.c (write_segment): Assume EFAULT is defined. Fixes: debbugs:12968 --- lib-src/ChangeLog | 5 +++++ lib-src/movemail.c | 18 +++--------------- src/ChangeLog | 13 +++++++++++++ src/dired.c | 42 ++++++++++++++++++------------------------ src/fileio.c | 2 -- src/gmalloc.c | 8 -------- src/gnutls.c | 14 +------------- src/keyboard.c | 5 +---- src/lread.c | 2 -- src/process.c | 13 ++----------- src/unexcoff.c | 6 +----- 11 files changed, 44 insertions(+), 84 deletions(-) diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index b85ba12a5b..a74d4b90b9 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog @@ -1,3 +1,8 @@ +2012-11-27 Paul Eggert + + Assume POSIX 1003.1-1988 or later for errno.h (Bug#12968). + * movemail.c (main): Assume EAGAIN and EBUSY. + 2012-11-23 Paul Eggert movemail: treat EACCES etc. failures as permanent diff --git a/lib-src/movemail.c b/lib-src/movemail.c index 264b3d292c..f2b2484c8e 100644 --- a/lib-src/movemail.c +++ b/lib-src/movemail.c @@ -430,22 +430,10 @@ main (int argc, char **argv) for certain failure codes. */ if (status < 0) { - if (++lockcount <= 5) + if (++lockcount <= 5 && (errno == EAGAIN || errno == EBUSY)) { -#ifdef EAGAIN - if (errno == EAGAIN) - { - sleep (1); - goto retry_lock; - } -#endif -#ifdef EBUSY - if (errno == EBUSY) - { - sleep (1); - goto retry_lock; - } -#endif + sleep (1); + goto retry_lock; } pfatal_with_name (inname); diff --git a/src/ChangeLog b/src/ChangeLog index d841812bce..0594f73540 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,16 @@ +2012-11-27 Paul Eggert + + Assume POSIX 1003.1-1988 or later for errno.h (Bug#12968). + * dired.c (directory_files_internal, file_name_completion): + Assume EAGAIN and EINTR are defined. + * fileio.c (Fcopy_file): Assume EISDIR is defined. + * gmalloc.c (ENOMEM, EINVAL): Assume they're defined. + * gnutls.c (emacs_gnutls_write): Assume EAGAIN is defined. + * lread.c (readbyte_from_file): Assume EINTR is defined. + * process.c (wait_reading_process_output, send_process) [subprocesses]: + Assume EIO and EAGAIN are defined. + * unexcoff.c (write_segment): Assume EFAULT is defined. + 2012-11-27 Eli Zaretskii * fontset.c (Finternal_char_font): Return nil on non-GUI frames. diff --git a/src/dired.c b/src/dired.c index 3530b74ecb..54bdc083f7 100644 --- a/src/dired.c +++ b/src/dired.c @@ -193,19 +193,15 @@ directory_files_internal (Lisp_Object directory, Lisp_Object full, errno = 0; dp = readdir (d); - - if (dp == NULL && (0 -#ifdef EAGAIN - || errno == EAGAIN -#endif -#ifdef EINTR - || errno == EINTR -#endif - )) - { QUIT; continue; } - - if (dp == NULL) - break; + if (!dp) + { + if (errno == EAGAIN || errno == EINTR) + { + QUIT; + continue; + } + break; + } len = dirent_namelen (dp); name = finalname = make_unibyte_string (dp->d_name, len); @@ -480,17 +476,15 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, bool all_flag, errno = 0; dp = readdir (d); - if (dp == NULL && (0 -# ifdef EAGAIN - || errno == EAGAIN -# endif -# ifdef EINTR - || errno == EINTR -# endif - )) - { QUIT; continue; } - - if (!dp) break; + if (!dp) + { + if (errno == EAGAIN || errno == EINTR) + { + QUIT; + continue; + } + break; + } len = dirent_namelen (dp); diff --git a/src/fileio.c b/src/fileio.c index 442c66550d..98b2703559 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -1995,10 +1995,8 @@ on the system, we copy the SELinux context of FILE to NEWNAME. */) { if (!(S_ISREG (st.st_mode)) && !(S_ISLNK (st.st_mode))) { -#if defined (EISDIR) /* Get a better looking error message. */ errno = EISDIR; -#endif /* EISDIR */ report_file_error ("Non-regular file", Fcons (file, Qnil)); } } diff --git a/src/gmalloc.c b/src/gmalloc.c index dc58495566..c325ca7991 100644 --- a/src/gmalloc.c +++ b/src/gmalloc.c @@ -1645,14 +1645,6 @@ memalign (size_t alignment, size_t size) return result; } -#ifndef ENOMEM -#define ENOMEM 12 -#endif - -#ifndef EINVAL -#define EINVAL 22 -#endif - int posix_memalign (void **memptr, size_t alignment, size_t size) { diff --git a/src/gnutls.c b/src/gnutls.c index e3d84a0b61..03f753fa8c 100644 --- a/src/gnutls.c +++ b/src/gnutls.c @@ -359,12 +359,7 @@ emacs_gnutls_write (struct Lisp_Process *proc, const char *buf, ptrdiff_t nbyte) if (proc->gnutls_initstage != GNUTLS_STAGE_READY) { -#ifdef EWOULDBLOCK - errno = EWOULDBLOCK; -#endif -#ifdef EAGAIN errno = EAGAIN; -#endif return 0; } @@ -384,14 +379,7 @@ emacs_gnutls_write (struct Lisp_Process *proc, const char *buf, ptrdiff_t nbyte) appropriately so that send_process retries the correct way instead of erroring out. */ if (rtnval == GNUTLS_E_AGAIN) - { -#ifdef EWOULDBLOCK - errno = EWOULDBLOCK; -#endif -#ifdef EAGAIN - errno = EAGAIN; -#endif - } + errno = EAGAIN; break; } } diff --git a/src/keyboard.c b/src/keyboard.c index 0ad6d18c04..60e6d71cdf 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -6960,10 +6960,7 @@ tty_read_avail_input (struct terminal *terminal, an EAGAIN error. Does anybody know of a situation where a retry is actually needed? */ #if 0 - nread < 0 && (errno == EAGAIN -#ifdef EFAULT - || errno == EFAULT -#endif + nread < 0 && (errno == EAGAIN || errno == EFAULT #ifdef EBADSLT || errno == EBADSLT #endif diff --git a/src/lread.c b/src/lread.c index 6d0ff9f780..6647382a25 100644 --- a/src/lread.c +++ b/src/lread.c @@ -440,7 +440,6 @@ readbyte_from_file (int c, Lisp_Object readcharfun) block_input (); c = getc (instream); -#ifdef EINTR /* Interrupted reads have been observed while reading over the network. */ while (c == EOF && ferror (instream) && errno == EINTR) { @@ -450,7 +449,6 @@ readbyte_from_file (int c, Lisp_Object readcharfun) clearerr (instream); c = getc (instream); } -#endif unblock_input (); diff --git a/src/process.c b/src/process.c index 0036ce595f..b23f06fd02 100644 --- a/src/process.c +++ b/src/process.c @@ -4432,14 +4432,8 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, total_nread += nread; got_some_input = 1; } -#ifdef EIO - else if (nread == -1 && EIO == errno) + else if (nread == -1 && (errno == EIO || errno == EAGAIN)) break; -#endif -#ifdef EAGAIN - else if (nread == -1 && EAGAIN == errno) - break; -#endif #ifdef EWOULDBLOCK else if (nread == -1 && EWOULDBLOCK == errno) break; @@ -5517,12 +5511,9 @@ send_process (Lisp_Object proc, const char *buf, ptrdiff_t len, if (rv < 0) { - if (0 + if (errno == EAGAIN #ifdef EWOULDBLOCK || errno == EWOULDBLOCK -#endif -#ifdef EAGAIN - || errno == EAGAIN #endif ) /* Buffer is full. Wait, accepting input; diff --git a/src/unexcoff.c b/src/unexcoff.c index 966dd58cb6..6e29951a96 100644 --- a/src/unexcoff.c +++ b/src/unexcoff.c @@ -332,11 +332,7 @@ write_segment (int new, const char *ptr, const char *end) a gap between the old text segment and the old data segment. This gap has probably been remapped into part of the text segment. So write zeros for it. */ - if (ret == -1 -#ifdef EFAULT - && errno == EFAULT -#endif - ) + if (ret == -1 && errno == EFAULT) { /* Write only a page of zeros at once, so that we don't overshoot the start -- 2.20.1