summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2016-02-23 09:42:05 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2016-02-23 09:42:28 -0800
commit82848cf689c24a8bc635449846250ea6edb757c4 (patch)
tree4263b19e46cf62711d40ec14ccd3173225d48f2a /src
parentf4152efd2f7db87134e5e1c50e312a431e81db23 (diff)
downloademacs-82848cf689c24a8bc635449846250ea6edb757c4.tar.gz
Minor cleanups for async DNS etc.
* src/frame.h (FRAME_WINDOW_CONFIGURATION_CHANGED): Omit unnecessary parens. * src/gnutls.c (gnutls_try_handshake, emacs_gnutls_deinit) (gnutls_verify_boot): Use bool for boolean. (ATTRIBUTE_FORMAT_PRINTF): Add printf attribute. * src/process.c (free_dns_request, Fmake_network_process): Allocate and free async request control block all in one go. (set_network_socket_coding_system, finish_after_tls_connection) (connect_network_socket): Now static. (conv_numerical_to_lisp): 2nd arg is now int, not unsigned. (Fmake_network_process): Use list1 for brevity. (wait_for_socket_fds): 2nd arg is now const ptr. * src/process.h (struct Lisp_Process.dns_request): Now struct gaicb *, not struct gaicb **, since there was always exactly one. All uses changed. * src/window.c, src/window.h (run_window_configuration_change_hook): Now static.
Diffstat (limited to 'src')
-rw-r--r--src/frame.h2
-rw-r--r--src/gnutls.c55
-rw-r--r--src/process.c233
-rw-r--r--src/process.h2
-rw-r--r--src/window.c13
-rw-r--r--src/window.h1
6 files changed, 146 insertions, 160 deletions
diff --git a/src/frame.h b/src/frame.h
index d9424ab5965..b83820a2084 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -832,7 +832,7 @@ default_pixels_per_inch_y (void)
/* True if the frame's window configuration has changed since last call
of run_window_size_change_functions. */
#define FRAME_WINDOW_CONFIGURATION_CHANGED(f) \
- ((f)->window_configuration_changed)
+ (f)->window_configuration_changed
/* The minibuffer window of frame F, if it has one; otherwise nil. */
#define FRAME_MINIBUF_WINDOW(f) f->minibuffer_window
diff --git a/src/gnutls.c b/src/gnutls.c
index ce4fbf9b7ef..d1b34c5bf7f 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -409,13 +409,13 @@ gnutls_try_handshake (struct Lisp_Process *proc)
emacs_gnutls_handle_error (state, ret);
QUIT;
}
- while (ret < 0 && gnutls_error_is_fatal (ret) == 0 &&
- ! proc->is_non_blocking_client);
+ while (ret < 0 && gnutls_error_is_fatal (ret) == 0
+ && ! proc->is_non_blocking_client);
proc->gnutls_initstage = GNUTLS_STAGE_HANDSHAKE_TRIED;
if (proc->is_non_blocking_client)
- proc->gnutls_p = 1;
+ proc->gnutls_p = true;
if (ret == GNUTLS_E_SUCCESS)
{
@@ -424,7 +424,7 @@ gnutls_try_handshake (struct Lisp_Process *proc)
}
else
{
- //check_memory_full (gnutls_alert_send_appropriate (state, ret));
+ /* check_memory_full (gnutls_alert_send_appropriate (state, ret)); */
}
return ret;
}
@@ -650,7 +650,7 @@ emacs_gnutls_deinit (Lisp_Object proc)
CHECK_PROCESS (proc);
- if (XPROCESS (proc)->gnutls_p == 0)
+ if (! XPROCESS (proc)->gnutls_p)
return Qnil;
log_level = XPROCESS (proc)->gnutls_log_level;
@@ -677,7 +677,7 @@ emacs_gnutls_deinit (Lisp_Object proc)
GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_INIT - 1;
}
- XPROCESS (proc)->gnutls_p = 0;
+ XPROCESS (proc)->gnutls_p = false;
return Qt;
}
@@ -1162,8 +1162,7 @@ emacs_gnutls_global_deinit (void)
}
#endif
-/* VARARGS 1 */
-static void
+static void ATTRIBUTE_FORMAT_PRINTF (2, 3)
boot_error (struct Lisp_Process *p, const char *m, ...)
{
va_list ap;
@@ -1184,7 +1183,7 @@ gnutls_verify_boot (Lisp_Object proc, Lisp_Object proplist)
Lisp_Object warnings;
int max_log_level = p->gnutls_log_level;
Lisp_Object hostname, verify_error;
- bool verify_error_all = 0;
+ bool verify_error_all = false;
char *c_hostname;
if (NILP (proplist))
@@ -1194,12 +1193,11 @@ gnutls_verify_boot (Lisp_Object proc, Lisp_Object proplist)
hostname = Fplist_get (proplist, QCgnutls_bootprop_hostname);
if (EQ (verify_error, Qt))
- {
- verify_error_all = 1;
- }
+ verify_error_all = true;
else if (NILP (Flistp (verify_error)))
{
- boot_error (p, "gnutls-boot: invalid :verify_error parameter (not a list)");
+ boot_error (p,
+ "gnutls-boot: invalid :verify_error parameter (not a list)");
return Qnil;
}
@@ -1225,8 +1223,7 @@ gnutls_verify_boot (Lisp_Object proc, Lisp_Object proplist)
warnings = Fplist_get (Fgnutls_peer_status (proc), intern (":warnings"));
if (!NILP (warnings))
{
- Lisp_Object tail;
- for (tail = warnings; CONSP (tail); tail = XCDR (tail))
+ for (Lisp_Object tail = warnings; CONSP (tail); tail = XCDR (tail))
{
Lisp_Object warning = XCAR (tail);
Lisp_Object message = Fgnutls_peer_status_warning_describe (warning);
@@ -1241,7 +1238,8 @@ gnutls_verify_boot (Lisp_Object proc, Lisp_Object proplist)
|| !NILP (Fmember (QCgnutls_bootprop_trustfiles, verify_error)))
{
emacs_gnutls_deinit (proc);
- boot_error (p, "Certificate validation failed %s, verification code %x",
+ boot_error (p,
+ "Certificate validation failed %s, verification code %x",
c_hostname, peer_verification);
return Qnil;
}
@@ -1265,8 +1263,8 @@ gnutls_verify_boot (Lisp_Object proc, Lisp_Object proplist)
if (ret < GNUTLS_E_SUCCESS)
return gnutls_make_error (ret);
- gnutls_verify_cert_list =
- gnutls_certificate_get_peers (state, &gnutls_verify_cert_list_size);
+ gnutls_verify_cert_list
+ = gnutls_certificate_get_peers (state, &gnutls_verify_cert_list_size);
if (gnutls_verify_cert_list == NULL)
{
@@ -1276,10 +1274,10 @@ gnutls_verify_boot (Lisp_Object proc, Lisp_Object proplist)
return Qnil;
}
- /* We only check the first certificate in the given chain. */
+ /* Check only the first certificate in the given chain. */
ret = gnutls_x509_crt_import (gnutls_verify_cert,
- &gnutls_verify_cert_list[0],
- GNUTLS_X509_FMT_DER);
+ &gnutls_verify_cert_list[0],
+ GNUTLS_X509_FMT_DER);
if (ret < GNUTLS_E_SUCCESS)
{
@@ -1294,26 +1292,25 @@ gnutls_verify_boot (Lisp_Object proc, Lisp_Object proplist)
check_memory_full (err);
if (!err)
{
- XPROCESS (proc)->gnutls_extra_peer_verification |=
- CERTIFICATE_NOT_MATCHING;
+ XPROCESS (proc)->gnutls_extra_peer_verification
+ |= CERTIFICATE_NOT_MATCHING;
if (verify_error_all
|| !NILP (Fmember (QCgnutls_bootprop_hostname, verify_error)))
{
gnutls_x509_crt_deinit (gnutls_verify_cert);
emacs_gnutls_deinit (proc);
- boot_error (p, "The x509 certificate does not match \"%s\"", c_hostname);
+ boot_error (p, "The x509 certificate does not match \"%s\"",
+ c_hostname);
return Qnil;
}
else
- {
- GNUTLS_LOG2 (1, max_log_level, "x509 certificate does not match:",
- c_hostname);
- }
+ GNUTLS_LOG2 (1, max_log_level, "x509 certificate does not match:",
+ c_hostname);
}
}
/* Set this flag only if the whole initialization succeeded. */
- XPROCESS (proc)->gnutls_p = 1;
+ XPROCESS (proc)->gnutls_p = true;
return gnutls_make_error (ret);
}
diff --git a/src/process.c b/src/process.c
index 5172518ac6b..41e821e145d 100644
--- a/src/process.c
+++ b/src/process.c
@@ -281,7 +281,7 @@ static int max_input_desc;
/* Indexed by descriptor, gives the process (if any) for that descriptor. */
static Lisp_Object chan_process[FD_SETSIZE];
-static void wait_for_socket_fds (Lisp_Object process, char *name);
+static void wait_for_socket_fds (Lisp_Object, char const *);
/* Alist of elements (NAME . PROCESS). */
static Lisp_Object Vprocess_alist;
@@ -745,14 +745,10 @@ free_dns_request (Lisp_Object proc)
{
struct Lisp_Process *p = XPROCESS (proc);
- if (p->dns_requests[0]->ar_result)
- freeaddrinfo (p->dns_requests[0]->ar_result);
- xfree ((void *)p->dns_requests[0]->ar_request);
- xfree ((void *)p->dns_requests[0]->ar_name);
- xfree ((void *)p->dns_requests[0]->ar_service);
- xfree (p->dns_requests[0]);
- xfree (p->dns_requests);
- p->dns_requests = NULL;
+ if (p->dns_request->ar_result)
+ freeaddrinfo (p->dns_request->ar_result);
+ xfree (p->dns_request);
+ p->dns_request = NULL;
}
#endif
@@ -847,9 +843,9 @@ nil, indicating the current buffer's process. */)
p = XPROCESS (process);
#ifdef HAVE_GETADDRINFO_A
- if (p->dns_requests)
+ if (p->dns_request)
{
- gai_cancel (p->dns_requests[0]);
+ gai_cancel (p->dns_request);
free_dns_request (process);
}
#endif
@@ -1063,13 +1059,10 @@ The string argument is normally a multibyte string, except:
- if `default-enable-multibyte-characters' is nil, it is a unibyte
string (the result of converting the decoded input multibyte
string to unibyte with `string-make-unibyte'). */)
- (register Lisp_Object process, Lisp_Object filter)
+ (Lisp_Object process, Lisp_Object filter)
{
- struct Lisp_Process *p;
-
CHECK_PROCESS (process);
-
- p = XPROCESS (process);
+ struct Lisp_Process *p = XPROCESS (process);
/* Don't signal an error if the process's input file descriptor
is closed. This could make debugging Lisp more difficult,
@@ -1217,7 +1210,7 @@ returned. See `make-network-process' or `make-serial-process' for a
list of keywords.
If PROCESS is a non-blocking network process that hasn't been fully
set up yet, this function will block until socket setup has completed. */)
- (register Lisp_Object process, Lisp_Object key)
+ (Lisp_Object process, Lisp_Object key)
{
Lisp_Object contact;
@@ -1263,8 +1256,8 @@ DEFUN ("process-plist", Fprocess_plist, Sprocess_plist,
DEFUN ("set-process-plist", Fset_process_plist, Sset_process_plist,
2, 2, 0,
- doc: /* Replace the plist of PROCESS with PLIST. Returns PLIST. */)
- (register Lisp_Object process, Lisp_Object plist)
+ doc: /* Replace the plist of PROCESS with PLIST. Return PLIST. */)
+ (Lisp_Object process, Lisp_Object plist)
{
CHECK_PROCESS (process);
CHECK_LIST (plist);
@@ -1304,7 +1297,7 @@ A 4 or 5 element vector represents an IPv4 address (with port number).
An 8 or 9 element vector represents an IPv6 address (with port number).
If optional second argument OMIT-PORT is non-nil, don't include a port
number in the string, even when present in ADDRESS.
-Returns nil if format of ADDRESS is invalid. */)
+Return nil if format of ADDRESS is invalid. */)
(Lisp_Object address, Lisp_Object omit_port)
{
if (NILP (address))
@@ -2474,7 +2467,7 @@ set up yet, this function will block until socket setup has completed. */)
DEFUN ("set-process-datagram-address", Fset_process_datagram_address, Sset_process_datagram_address,
2, 2, 0,
doc: /* Set the datagram address for PROCESS to ADDRESS.
-Returns nil upon error setting address, ADDRESS otherwise.
+Return nil upon error setting address, ADDRESS otherwise.
If PROCESS is a non-blocking network process that hasn't been fully
set up yet, this function will block until socket setup has completed. */)
@@ -2543,7 +2536,7 @@ static const struct socket_options {
/* Set option OPT to value VAL on socket S.
- Returns (1<<socket_options[OPT].optbit) if option is known, 0 otherwise.
+ Return (1<<socket_options[OPT].optbit) if option is known, 0 otherwise.
Signals an error if setting a known option fails.
*/
@@ -2955,10 +2948,9 @@ usage: (make-serial-process &rest ARGS) */)
return proc;
}
-void set_network_socket_coding_system (Lisp_Object proc,
- Lisp_Object host,
- Lisp_Object service,
- Lisp_Object name)
+static void
+set_network_socket_coding_system (Lisp_Object proc, Lisp_Object host,
+ Lisp_Object service, Lisp_Object name)
{
Lisp_Object tem;
struct Lisp_Process *p = XPROCESS (proc);
@@ -2981,9 +2973,10 @@ void set_network_socket_coding_system (Lisp_Object proc,
}
else if (!NILP (Vcoding_system_for_read))
val = Vcoding_system_for_read;
- else if ((!NILP (p->buffer) &&
- NILP (BVAR (XBUFFER (p->buffer), enable_multibyte_characters)))
- || (NILP (p->buffer) && NILP (BVAR (&buffer_defaults, enable_multibyte_characters))))
+ else if ((!NILP (p->buffer)
+ && NILP (BVAR (XBUFFER (p->buffer), enable_multibyte_characters)))
+ || (NILP (p->buffer)
+ && NILP (BVAR (&buffer_defaults, enable_multibyte_characters))))
/* We dare not decode end-of-line format by setting VAL to
Qraw_text, because the existing Emacs Lisp libraries
assume that they receive bare code including a sequence of
@@ -3045,7 +3038,7 @@ void set_network_socket_coding_system (Lisp_Object proc,
}
#ifdef HAVE_GNUTLS
-void
+static void
finish_after_tls_connection (Lisp_Object proc)
{
struct Lisp_Process *p = XPROCESS (proc);
@@ -3081,7 +3074,7 @@ finish_after_tls_connection (Lisp_Object proc)
}
#endif
-void
+static void
connect_network_socket (Lisp_Object proc, Lisp_Object ip_addresses)
{
ptrdiff_t count = SPECPDL_INDEX ();
@@ -3190,8 +3183,8 @@ connect_network_socket (Lisp_Object proc, Lisp_Object ip_addresses)
Lisp_Object service;
service = make_number (ntohs (sa1.sin_port));
contact = Fplist_put (contact, QCservice, service);
- // Save the port number so that we can stash it in
- // the process object later.
+ /* Save the port number so that we can stash it in
+ the process object later. */
((struct sockaddr_in *)sa)->sin_port = sa1.sin_port;
}
}
@@ -3422,15 +3415,14 @@ connect_network_socket (Lisp_Object proc, Lisp_Object ip_addresses)
#ifndef HAVE_GETADDRINFO
static Lisp_Object
-conv_numerical_to_lisp (unsigned char *number, unsigned int length, int port)
+conv_numerical_to_lisp (unsigned char *number, int length, int port)
{
Lisp_Object address = Fmake_vector (make_number (length + 1), Qnil);
- register struct Lisp_Vector *p = XVECTOR (address);
- int i;
+ struct Lisp_Vector *p = XVECTOR (address);
p->contents[length] = make_number (port);
- for (i = 0; i < length; i++)
- p->contents[i] = make_number (*(number + i));
+ for (int i = 0; i < length; i++)
+ p->contents[i] = make_number (number[i]);
return address;
}
@@ -3606,9 +3598,9 @@ usage: (make-network-process &rest ARGS) */)
Lisp_Object proc;
Lisp_Object contact;
struct Lisp_Process *p;
-#if defined(HAVE_GETADDRINFO) || defined(HAVE_GETADDRINFO_A)
- struct addrinfo *hints;
+#if defined HAVE_GETADDRINFO || defined HAVE_GETADDRINFO_A
const char *portstring;
+ ptrdiff_t portstringlen;
char portbuf[128];
#endif
#ifdef HAVE_LOCAL_SOCKETS
@@ -3623,7 +3615,7 @@ usage: (make-network-process &rest ARGS) */)
int family = -1;
int ai_protocol = 0;
#ifdef HAVE_GETADDRINFO_A
- struct gaicb **dns_requests = NULL;
+ struct gaicb *dns_request = NULL;
#endif
ptrdiff_t count = SPECPDL_INDEX ();
@@ -3673,7 +3665,7 @@ usage: (make-network-process &rest ARGS) */)
if (!get_lisp_to_sockaddr_size (address, &family))
error ("Malformed :address");
- ip_addresses = Fcons (address, Qnil);
+ ip_addresses = list1 (address);
goto open_socket;
}
@@ -3737,7 +3729,7 @@ usage: (make-network-process &rest ARGS) */)
CHECK_STRING (service);
if (sizeof address_un.sun_path <= SBYTES (service))
error ("Service name too long");
- ip_addresses = Fcons (service, Qnil);
+ ip_addresses = list1 (service);
goto open_socket;
}
#endif
@@ -3753,48 +3745,53 @@ usage: (make-network-process &rest ARGS) */)
}
#endif
-#if defined (HAVE_GETADDRINFO) || defined (HAVE_GETADDRINFO_A)
+#if defined HAVE_GETADDRINFO || defined HAVE_GETADDRINFO_A
if (!NILP (host))
{
-
/* SERVICE can either be a string or int.
Convert to a C string for later use by getaddrinfo. */
if (EQ (service, Qt))
- portstring = "0";
+ {
+ portstring = "0";
+ portstringlen = 1;
+ }
else if (INTEGERP (service))
{
- sprintf (portbuf, "%"pI"d", XINT (service));
portstring = portbuf;
+ portstringlen = sprintf (portbuf, "%"pI"d", XINT (service));
}
else
{
CHECK_STRING (service);
portstring = SSDATA (service);
+ portstringlen = SBYTES (service);
}
-
- hints = xzalloc (sizeof (struct addrinfo));
- hints->ai_flags = 0;
- hints->ai_family = family;
- hints->ai_socktype = socktype;
- hints->ai_protocol = 0;
}
-
#endif
#ifdef HAVE_GETADDRINFO_A
- if (!NILP (Fplist_get (contact, QCnowait)) &&
- !NILP (host))
+ if (!NILP (Fplist_get (contact, QCnowait)) && !NILP (host))
{
- int ret;
-
- dns_requests = xmalloc (sizeof (struct gaicb*));
- dns_requests[0] = xmalloc (sizeof (struct gaicb));
- dns_requests[0]->ar_name = strdup (SSDATA (host));
- dns_requests[0]->ar_service = strdup (portstring);
- dns_requests[0]->ar_request = hints;
- dns_requests[0]->ar_result = NULL;
-
- ret = getaddrinfo_a (GAI_NOWAIT, dns_requests, 1, NULL);
+ ptrdiff_t hostlen = SBYTES (host);
+ struct req
+ {
+ struct gaicb gaicb;
+ struct addrinfo hints;
+ char str[FLEXIBLE_ARRAY_MEMBER];
+ } *req = xmalloc (offsetof (struct req, str)
+ + hostlen + 1 + portstringlen + 1);
+ dns_request = &req->gaicb;
+ dns_request->ar_name = req->str;
+ dns_request->ar_service = req->str + hostlen + 1;
+ dns_request->ar_request = &req->hints;
+ dns_request->ar_result = NULL;
+ memset (&req->hints, 0, sizeof req->hints);
+ req->hints.ai_family = family;
+ req->hints.ai_socktype = socktype;
+ strcpy (req->str, SSDATA (host));
+ strcpy (req->str + hostlen + 1, portstring);
+
+ int ret = getaddrinfo_a (GAI_NOWAIT, &dns_request, 1, NULL);
if (ret)
error ("%s/%s getaddrinfo_a error %d", SSDATA (host), portstring, ret);
@@ -3818,7 +3815,12 @@ usage: (make-network-process &rest ARGS) */)
res_init ();
#endif
- ret = getaddrinfo (SSDATA (host), portstring, hints, &res);
+ struct addrinfo hints;
+ memset (&hints, 0, sizeof hints);
+ hints.ai_family = family;
+ hints.ai_socktype = socktype;
+
+ ret = getaddrinfo (SSDATA (host), portstring, &hints, &res);
if (ret)
#ifdef HAVE_GAI_STRERROR
error ("%s/%s %s", SSDATA (host), portstring, gai_strerror (ret));
@@ -3838,7 +3840,6 @@ usage: (make-network-process &rest ARGS) */)
ip_addresses = Fnreverse (ip_addresses);
freeaddrinfo (res);
- xfree (hints);
goto open_socket;
}
@@ -3866,6 +3867,8 @@ usage: (make-network-process &rest ARGS) */)
if (!NILP (host))
{
struct hostent *host_info_ptr;
+ unsigned char *addr;
+ int addrlen;
/* gethostbyname may fail with TRY_AGAIN, but we don't honor that,
as it may `hang' Emacs for a very long time. */
@@ -3881,11 +3884,8 @@ usage: (make-network-process &rest ARGS) */)
if (host_info_ptr)
{
- ip_addresses = Fcons (conv_numerical_to_lisp
- ((unsigned char *) host_info_ptr->h_addr,
- host_info_ptr->h_length,
- port),
- Qnil);
+ addr = (unsigned char *) host_info_ptr->h_addr;
+ addrlen = host_info_ptr->h_length;
}
else
/* Attempt to interpret host as numeric inet address. This
@@ -3896,11 +3896,11 @@ usage: (make-network-process &rest ARGS) */)
if (numeric_addr == -1)
error ("Unknown host \"%s\"", SDATA (host));
- ip_addresses = Fcons (conv_numerical_to_lisp
- ((unsigned char *) &numeric_addr, 4, port),
- Qnil);
+ addr = (unsigned char *) &numeric_addr;
+ addrlen = 4;
}
+ ip_addresses = list1 (conv_numerical_to_lisp (addr, addrlen, port));
}
#endif /* not HAVE_GETADDRINFO */
@@ -3930,7 +3930,7 @@ usage: (make-network-process &rest ARGS) */)
p->socktype = socktype;
p->ai_protocol = ai_protocol;
#ifdef HAVE_GETADDRINFO_A
- p->dns_requests = NULL;
+ p->dns_request = NULL;
#endif
#ifdef HAVE_GNUTLS
tem = Fplist_get (contact, QCtls_parameters);
@@ -3969,7 +3969,7 @@ usage: (make-network-process &rest ARGS) */)
here will be nil, so we postpone connecting to the server. */
if (!p->is_server && NILP (ip_addresses))
{
- p->dns_requests = dns_requests;
+ p->dns_request = dns_request;
p->status = Qconnect;
}
else
@@ -4693,10 +4693,10 @@ check_for_dns (Lisp_Object proc)
int ret = 0;
/* Sanity check. */
- if (! p->dns_requests)
+ if (! p->dns_request)
return Qnil;
- ret = gai_error (p->dns_requests[0]);
+ ret = gai_error (p->dns_request);
if (ret == EAI_INPROGRESS)
return Qt;
@@ -4705,7 +4705,7 @@ check_for_dns (Lisp_Object proc)
{
struct addrinfo *res;
- for (res = p->dns_requests[0]->ar_result; res; res = res->ai_next)
+ for (res = p->dns_request->ar_result; res; res = res->ai_next)
{
ip_addresses = Fcons (conv_sockaddr_to_lisp
(res->ai_addr, res->ai_addrlen),
@@ -4721,7 +4721,7 @@ check_for_dns (Lisp_Object proc)
pset_status (p, (list2
(Qfailed,
concat3 (build_string ("Name lookup of "),
- build_string (p->dns_requests[0]->ar_name),
+ build_string (p->dns_request->ar_name),
build_string (" failed")))));
}
@@ -4737,10 +4737,10 @@ check_for_dns (Lisp_Object proc)
#endif /* HAVE_GETADDRINFO_A */
static void
-wait_for_socket_fds (Lisp_Object process, char *name)
+wait_for_socket_fds (Lisp_Object process, char const *name)
{
- while (XPROCESS (process)->infd < 0 &&
- EQ (XPROCESS (process)->status, Qconnect))
+ while (XPROCESS (process)->infd < 0
+ && EQ (XPROCESS (process)->status, Qconnect))
{
add_to_log ("Waiting for socket from %s...", build_string (name));
wait_reading_process_output (0, 20 * 1000 * 1000, 0, 0, Qnil, NULL, 0);
@@ -4761,8 +4761,8 @@ static void
wait_for_tls_negotiation (Lisp_Object process)
{
#ifdef HAVE_GNUTLS
- while (XPROCESS (process)->gnutls_p &&
- XPROCESS (process)->gnutls_initstage != GNUTLS_STAGE_READY)
+ while (XPROCESS (process)->gnutls_p
+ && XPROCESS (process)->gnutls_initstage != GNUTLS_STAGE_READY)
{
add_to_log ("Waiting for TLS...");
wait_reading_process_output (0, 20 * 1000 * 1000, 0, 0, Qnil, NULL, 0);
@@ -4895,7 +4895,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell)))
break;
-#if defined (HAVE_GETADDRINFO_A) || defined (HAVE_GNUTLS)
+#if defined HAVE_GETADDRINFO_A || defined HAVE_GNUTLS
{
Lisp_Object ip_addresses;
Lisp_Object process_list_head, aproc;
@@ -4909,18 +4909,17 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
{
#ifdef HAVE_GETADDRINFO_A
/* Check for pending DNS requests. */
- if (p->dns_requests)
+ if (p->dns_request)
{
ip_addresses = check_for_dns (aproc);
- if (!NILP (ip_addresses) &&
- !EQ (ip_addresses, Qt))
+ if (!NILP (ip_addresses) && !EQ (ip_addresses, Qt))
connect_network_socket (aproc, ip_addresses);
}
#endif
#ifdef HAVE_GNUTLS
/* Continue TLS negotiation. */
- if (p->gnutls_initstage == GNUTLS_STAGE_HANDSHAKE_TRIED &&
- p->is_non_blocking_client)
+ if (p->gnutls_initstage == GNUTLS_STAGE_HANDSHAKE_TRIED
+ && p->is_non_blocking_client)
{
gnutls_try_handshake (p);
p->gnutls_handshakes_tried++;
@@ -4930,8 +4929,8 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
gnutls_verify_boot (aproc, Qnil);
finish_after_tls_connection (aproc);
}
- else if (p->gnutls_handshakes_tried >
- GNUTLS_EMACS_HANDSHAKES_LIMIT)
+ else if (p->gnutls_handshakes_tried
+ > GNUTLS_EMACS_HANDSHAKES_LIMIT)
{
deactivate_process (aproc);
pset_status (p, list2 (Qfailed,
@@ -5567,8 +5566,8 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
/* If we have an incompletely set up TLS connection,
then defer the sentinel signalling until
later. */
- if (NILP (p->gnutls_boot_parameters) &&
- !p->gnutls_p)
+ if (NILP (p->gnutls_boot_parameters)
+ && !p->gnutls_p)
#endif
{
pset_status (p, Qrun);
@@ -6034,10 +6033,11 @@ send_process (Lisp_Object proc, const char *buf, ptrdiff_t len,
ssize_t rv;
struct coding_system *coding;
- if (NETCONN_P (proc)) {
- wait_while_connecting (proc);
- wait_for_tls_negotiation (proc);
- }
+ if (NETCONN_P (proc))
+ {
+ wait_while_connecting (proc);
+ wait_for_tls_negotiation (proc);
+ }
if (p->raw_status_new)
update_status (p);
@@ -6295,10 +6295,8 @@ If PROCESS is a non-blocking network process that hasn't been fully
set up yet, this function will block until socket setup has completed. */)
(Lisp_Object process, Lisp_Object string)
{
- Lisp_Object proc;
CHECK_STRING (string);
- proc = get_process (process);
-
+ Lisp_Object proc = get_process (process);
send_process (proc, SSDATA (string),
SBYTES (string), string);
return Qnil;
@@ -6340,12 +6338,8 @@ process group. */)
{
/* Initialize in case ioctl doesn't exist or gives an error,
in a way that will cause returning t. */
- pid_t gid;
- Lisp_Object proc;
- struct Lisp_Process *p;
-
- proc = get_process (process);
- p = XPROCESS (proc);
+ Lisp_Object proc = get_process (process);
+ struct Lisp_Process *p = XPROCESS (proc);
if (!EQ (p->type, Qreal))
error ("Process %s is not a subprocess",
@@ -6354,7 +6348,7 @@ process group. */)
error ("Process %s is not active",
SDATA (p->name));
- gid = emacs_get_tty_pgrp (p);
+ pid_t gid = emacs_get_tty_pgrp (p);
if (gid == p->pid)
return Qnil;
@@ -7170,16 +7164,14 @@ encode subprocess input.
If PROCESS is a non-blocking network process that hasn't been fully
set up yet, this function will block until socket setup has completed. */)
- (register Lisp_Object process, Lisp_Object decoding, Lisp_Object encoding)
+ (Lisp_Object process, Lisp_Object decoding, Lisp_Object encoding)
{
- register struct Lisp_Process *p;
-
CHECK_PROCESS (process);
if (NETCONN_P (process))
wait_for_socket_fds (process, "set-process-coding-system");
- p = XPROCESS (process);
+ struct Lisp_Process *p = XPROCESS (process);
if (p->infd < 0)
error ("Input file descriptor of %s closed", SDATA (p->name));
@@ -7214,14 +7206,12 @@ all character code conversion except for end-of-line conversion is
suppressed. */)
(Lisp_Object process, Lisp_Object flag)
{
- register struct Lisp_Process *p;
-
CHECK_PROCESS (process);
if (NETCONN_P (process))
wait_for_socket_fds (process, "set-process-filter-multibyte");
- p = XPROCESS (process);
+ struct Lisp_Process *p = XPROCESS (process);
if (NILP (flag))
pset_decode_coding_system
(p, raw_text_coding_system (p->decode_coding_system));
@@ -7235,14 +7225,11 @@ DEFUN ("process-filter-multibyte-p", Fprocess_filter_multibyte_p,
doc: /* Return t if a multibyte string is given to PROCESS's filter.*/)
(Lisp_Object process)
{
- register struct Lisp_Process *p;
- struct coding_system *coding;
-
CHECK_PROCESS (process);
- p = XPROCESS (process);
+ struct Lisp_Process *p = XPROCESS (process);
if (p->infd < 0)
return Qnil;
- coding = proc_decode_coding_system[p->infd];
+ struct coding_system *coding = proc_decode_coding_system[p->infd];
return (CODING_FOR_UNIBYTE (coding) ? Qnil : Qt);
}
diff --git a/src/process.h b/src/process.h
index c7531576915..884c3041f67 100644
--- a/src/process.h
+++ b/src/process.h
@@ -179,7 +179,7 @@ struct Lisp_Process
#ifdef HAVE_GETADDRINFO_A
/* Whether the socket is waiting for response from an asynchronous
DNS call. */
- struct gaicb **dns_requests;
+ struct gaicb *dns_request;
#endif
#ifdef HAVE_GNUTLS
diff --git a/src/window.c b/src/window.c
index 29c35875039..be34c49135e 100644
--- a/src/window.c
+++ b/src/window.c
@@ -57,6 +57,7 @@ static bool foreach_window_1 (struct window *,
static bool window_resize_check (struct window *, bool);
static void window_resize_apply (struct window *, bool);
static void select_window_1 (Lisp_Object, bool);
+static void run_window_configuration_change_hook (struct frame *);
static struct window *set_window_fringes (struct window *, Lisp_Object,
Lisp_Object, Lisp_Object);
@@ -720,7 +721,8 @@ the height of the screen areas spanned by its children. */)
return make_number (decode_valid_window (window)->pixel_height);
}
-DEFUN ("window-pixel-width-before-size-change", Fwindow_pixel_width_before_size_change,
+DEFUN ("window-pixel-width-before-size-change",
+ Fwindow_pixel_width_before_size_change,
Swindow_pixel_width_before_size_change, 0, 1, 0,
doc: /* Return pixel width of window WINDOW before last size changes.
WINDOW must be a valid window and defaults to the selected one.
@@ -734,7 +736,8 @@ after that. */)
(decode_valid_window (window)->pixel_width_before_size_change));
}
-DEFUN ("window-pixel-height-before-size-change", Fwindow_pixel_height_before_size_change,
+DEFUN ("window-pixel-height-before-size-change",
+ Fwindow_pixel_height_before_size_change,
Swindow_pixel_height_before_size_change, 0, 1, 0,
doc: /* Return pixel height of window WINDOW before last size changes.
WINDOW must be a valid window and defaults to the selected one.
@@ -3184,7 +3187,7 @@ select_frame_norecord (Lisp_Object frame)
Fselect_frame (frame, Qt);
}
-void
+static void
run_window_configuration_change_hook (struct frame *f)
{
ptrdiff_t count = SPECPDL_INDEX ();
@@ -3310,8 +3313,8 @@ run_window_size_change_functions (Lisp_Object frame)
struct window *r = XWINDOW (FRAME_ROOT_WINDOW (f));
Lisp_Object functions = Vwindow_size_change_functions;
- if (FRAME_WINDOW_CONFIGURATION_CHANGED (f) ||
- window_size_changed (r))
+ if (FRAME_WINDOW_CONFIGURATION_CHANGED (f)
+ || window_size_changed (r))
{
while (CONSP (functions))
{
diff --git a/src/window.h b/src/window.h
index a4d4dfe3ff4..2c030335792 100644
--- a/src/window.h
+++ b/src/window.h
@@ -1020,7 +1020,6 @@ extern void grow_mini_window (struct window *, int, bool);
extern void shrink_mini_window (struct window *, bool);
extern int window_relative_x_coord (struct window *, enum window_part, int);
-void run_window_configuration_change_hook (struct frame *f);
void run_window_size_change_functions (Lisp_Object);
/* Make WINDOW display BUFFER. RUN_HOOKS_P means it's allowed