]> git.eshelyaron.com Git - emacs.git/commitdiff
Port --enable-gcc-warnings to GCC 6.2.1
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 12 Oct 2016 16:16:31 +0000 (09:16 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 12 Oct 2016 16:19:44 +0000 (09:19 -0700)
Backport from master.
* src/conf_post.h (GNUC_PREREQ): New macro.
* src/keyboard.c: Use it to work around GCC bug 54561.
* src/process.c (would_block): New function.
(server_accept_connection, wait_reading_process_output, send_process):
Use it.

src/conf_post.h
src/keyboard.c
src/process.c

index 209f60792cf1eb2aff47b6fa52aa484371d0c975..f83965bf8b1fb51cb72e93364f8dcfa965790cfb 100644 (file)
@@ -34,6 +34,17 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <stdbool.h>
 
+/* GNUC_PREREQ (V, W, X) is true if this is GNU C version V.W.X or later.
+   It can be used in a preprocessor expression.  */
+#ifndef __GNUC_MINOR__
+# define GNUC_PREREQ(v, w, x) false
+#elif ! defined __GNUC_PATCHLEVEL__
+# define GNUC_PREREQ(v, w, x) ((v) < __GNUC__ + ((w) <= __GNUC_MINOR__))
+#else
+# define GNUC_PREREQ(v, w, x) \
+    ((v) < __GNUC__ + ((w) <= __GNUC_MINOR__ + ((x) <= __GNUC_PATCHLEVEL__)))
+#endif
+
 /* The type of bool bitfields.  Needed to compile Objective-C with
    standard GCC.  It was also needed to port to pre-C99 compilers,
    although we don't care about that any more.  */
index 918424630f37d806939cf96713eb862b0b76bef9..f24d86e8833bc90e9a72ee9dc29ede2388e26055 100644 (file)
@@ -70,6 +70,11 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include TERM_HEADER
 #endif /* HAVE_WINDOW_SYSTEM */
 
+/* Work around GCC bug 54561.  */
+#if GNUC_PREREQ (4, 3, 0)
+# pragma GCC diagnostic ignored "-Wclobbered"
+#endif
+
 /* Variables for blockinput.h:  */
 
 /* Positive if interrupt input is blocked right now.  */
index 7ab92b0102cd1be2ee88bc79e50847d160defd24..e6ea2fbe8f7228b5dbc4a23ea433715b8ff97c72 100644 (file)
@@ -151,6 +151,18 @@ bool inhibit_sentinels;
 # define SOCK_CLOEXEC 0
 #endif
 
+/* True if ERRNUM represents an error where the system call would
+   block if a blocking variant were used.  */
+static bool
+would_block (int errnum)
+{
+#ifdef EWOULDBLOCK
+  if (EWOULDBLOCK != EAGAIN && errnum == EWOULDBLOCK)
+    return true;
+#endif
+  return errnum == EAGAIN;
+}
+
 #ifndef HAVE_ACCEPT4
 
 /* Emulate GNU/Linux accept4 and socket well enough for this module.  */
@@ -4262,15 +4274,7 @@ server_accept_connection (Lisp_Object server, int channel)
   if (s < 0)
     {
       int code = errno;
-
-      if (code == EAGAIN)
-       return;
-#ifdef EWOULDBLOCK
-      if (code == EWOULDBLOCK)
-       return;
-#endif
-
-      if (!NILP (ps->log))
+      if (!would_block (code) && !NILP (ps->log))
        call3 (ps->log, server, Qnil,
               concat3 (build_string ("accept failed with code"),
                        Fnumber_to_string (make_number (code)),
@@ -4687,12 +4691,8 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
                  int nread = read_process_output (proc, wait_proc->infd);
                  if (nread < 0)
                    {
-                   if (errno == EIO || errno == EAGAIN)
-                     break;
-#ifdef EWOULDBLOCK
-                   if (errno == EWOULDBLOCK)
-                     break;
-#endif
+                     if (errno == EIO || would_block (errno))
+                       break;
                    }
                  else
                    {
@@ -5073,11 +5073,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
                  if (do_display)
                    redisplay_preserve_echo_area (12);
                }
-#ifdef EWOULDBLOCK
-             else if (nread == -1 && errno == EWOULDBLOCK)
-               ;
-#endif
-             else if (nread == -1 && errno == EAGAIN)
+             else if (nread == -1 && would_block (errno))
                ;
 #ifdef WINDOWSNT
              /* FIXME: Is this special case still needed?  */
@@ -5801,11 +5797,7 @@ send_process (Lisp_Object proc, const char *buf, ptrdiff_t len,
 
          if (rv < 0)
            {
-             if (errno == EAGAIN
-#ifdef EWOULDBLOCK
-                 || errno == EWOULDBLOCK
-#endif
-                 )
+             if (would_block (errno))
                /* Buffer is full.  Wait, accepting input;
                   that may allow the program
                   to finish doing output and read more.  */