aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
authorPaul Eggert2017-05-16 14:29:18 -0700
committerPaul Eggert2017-05-16 14:31:49 -0700
commitbe9e60fc3c43cc49cc5d749924c3e96737ae297c (patch)
treef29bee2a14c1aae78324eef68b1c0279a3af3dd8 /src/process.c
parentc4ac34f22794344d44022b9c497b2f12cdb0f4a6 (diff)
downloademacs-be9e60fc3c43cc49cc5d749924c3e96737ae297c.tar.gz
emacs-be9e60fc3c43cc49cc5d749924c3e96737ae297c.zip
Simplify procname code to avoid GCC bug
* src/process.c (server_accept_connection): Simplify and avoid multiple calls and struct literals in the last case of a switch. The old code ran afoul of GCC bug 80659, which caused an internal compiler error. Problem reported by Jim Meyering in: http://lists.gnu.org/archive/html/emacs-devel/2017-05/msg00182.html https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80659
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c53
1 files changed, 24 insertions, 29 deletions
diff --git a/src/process.c b/src/process.c
index 4a286391f88..fdea97722f2 100644
--- a/src/process.c
+++ b/src/process.c
@@ -4659,7 +4659,7 @@ static EMACS_INT connect_counter = 0;
4659static void 4659static void
4660server_accept_connection (Lisp_Object server, int channel) 4660server_accept_connection (Lisp_Object server, int channel)
4661{ 4661{
4662 Lisp_Object proc, caller, name, buffer; 4662 Lisp_Object buffer;
4663 Lisp_Object contact, host, service; 4663 Lisp_Object contact, host, service;
4664 struct Lisp_Process *ps = XPROCESS (server); 4664 struct Lisp_Process *ps = XPROCESS (server);
4665 struct Lisp_Process *p; 4665 struct Lisp_Process *p;
@@ -4701,49 +4701,43 @@ server_accept_connection (Lisp_Object server, int channel)
4701 information for this process. */ 4701 information for this process. */
4702 host = Qt; 4702 host = Qt;
4703 service = Qnil; 4703 service = Qnil;
4704 Lisp_Object args[11];
4705 int nargs = 0;
4706 AUTO_STRING (procname_format_in, "%s <%d.%d.%d.%d:%d>");
4707 AUTO_STRING (procname_format_in6, "%s <[%x:%x:%x:%x:%x:%x:%x:%x]:%d>");
4708 AUTO_STRING (procname_format_default, "%s <%d>");
4704 switch (saddr.sa.sa_family) 4709 switch (saddr.sa.sa_family)
4705 { 4710 {
4706 case AF_INET: 4711 case AF_INET:
4707 { 4712 {
4713 args[nargs++] = procname_format_in;
4714 nargs++;
4708 unsigned char *ip = (unsigned char *)&saddr.in.sin_addr.s_addr; 4715 unsigned char *ip = (unsigned char *)&saddr.in.sin_addr.s_addr;
4709
4710 AUTO_STRING (ipv4_format, "%d.%d.%d.%d");
4711 host = CALLN (Fformat, ipv4_format,
4712 make_number (ip[0]), make_number (ip[1]),
4713 make_number (ip[2]), make_number (ip[3]));
4714 service = make_number (ntohs (saddr.in.sin_port)); 4716 service = make_number (ntohs (saddr.in.sin_port));
4715 AUTO_STRING (caller_format, " <%s:%d>"); 4717 for (int i = 0; i < 4; i++)
4716 caller = CALLN (Fformat, caller_format, host, service); 4718 args[nargs++] = make_number (ip[i]);
4719 args[nargs++] = service;
4717 } 4720 }
4718 break; 4721 break;
4719 4722
4720#ifdef AF_INET6 4723#ifdef AF_INET6
4721 case AF_INET6: 4724 case AF_INET6:
4722 { 4725 {
4723 Lisp_Object args[9]; 4726 args[nargs++] = procname_format_in6;
4727 nargs++;
4724 uint16_t *ip6 = (uint16_t *)&saddr.in6.sin6_addr; 4728 uint16_t *ip6 = (uint16_t *)&saddr.in6.sin6_addr;
4725 int i;
4726
4727 AUTO_STRING (ipv6_format, "%x:%x:%x:%x:%x:%x:%x:%x");
4728 args[0] = ipv6_format;
4729 for (i = 0; i < 8; i++)
4730 args[i + 1] = make_number (ntohs (ip6[i]));
4731 host = CALLMANY (Fformat, args);
4732 service = make_number (ntohs (saddr.in.sin_port)); 4729 service = make_number (ntohs (saddr.in.sin_port));
4733 AUTO_STRING (caller_format, " <[%s]:%d>"); 4730 for (int i = 0; i < 8; i++)
4734 caller = CALLN (Fformat, caller_format, host, service); 4731 args[nargs++] = make_number (ip6[i]);
4732 args[nargs++] = service;
4735 } 4733 }
4736 break; 4734 break;
4737#endif 4735#endif
4738 4736
4739#ifdef HAVE_LOCAL_SOCKETS
4740 case AF_LOCAL:
4741#endif
4742 default: 4737 default:
4743 caller = Fnumber_to_string (make_number (connect_counter)); 4738 args[nargs++] = procname_format_default;
4744 AUTO_STRING (space_less_than, " <"); 4739 nargs++;
4745 AUTO_STRING (greater_than, ">"); 4740 args[nargs++] = make_number (connect_counter);
4746 caller = concat3 (space_less_than, caller, greater_than);
4747 break; 4741 break;
4748 } 4742 }
4749 4743
@@ -4764,16 +4758,17 @@ server_accept_connection (Lisp_Object server, int channel)
4764 buffer = ps->name; 4758 buffer = ps->name;
4765 if (!NILP (buffer)) 4759 if (!NILP (buffer))
4766 { 4760 {
4767 buffer = concat2 (buffer, caller); 4761 args[1] = buffer;
4768 buffer = Fget_buffer_create (buffer); 4762 buffer = Fget_buffer_create (Fformat (nargs, args));
4769 } 4763 }
4770 } 4764 }
4771 4765
4772 /* Generate a unique name for the new server process. Combine the 4766 /* Generate a unique name for the new server process. Combine the
4773 server process name with the caller identification. */ 4767 server process name with the caller identification. */
4774 4768
4775 name = concat2 (ps->name, caller); 4769 args[1] = ps->name;
4776 proc = make_process (name); 4770 Lisp_Object name = Fformat (nargs, args);
4771 Lisp_Object proc = make_process (name);
4777 4772
4778 chan_process[s] = proc; 4773 chan_process[s] = proc;
4779 4774