aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
authorMattias EngdegÄrd2023-08-08 18:09:08 +0200
committerMattias EngdegÄrd2023-08-08 18:23:00 +0200
commit516736cfa6ce59a47709862daaebe066fa134b4a (patch)
tree817e9fe3323bee67cab1f7e45758b1bd4076067d /src/process.c
parent3e79fd3d4e810c2ef4cf9925a747c93e036fddca (diff)
downloademacs-516736cfa6ce59a47709862daaebe066fa134b4a.tar.gz
emacs-516736cfa6ce59a47709862daaebe066fa134b4a.zip
Better error for missing or bad :name arg in make-process etc
Improve on the famously bad error message given when the :name keyword parameter is missing or of the wrong type in calls to make-process, make-pipe-process and make-network-process (bug#65030). * src/process.c (get_required_string_keyword_param): New function. (Fmake_process, Fmake_pipe_process, Fmake_network_process): Use it.
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/process.c b/src/process.c
index 7738f1e4bcc..08cb810ec13 100644
--- a/src/process.c
+++ b/src/process.c
@@ -1737,6 +1737,18 @@ DEFUN ("process-list", Fprocess_list, Sprocess_list, 0, 0, 0,
1737} 1737}
1738 1738
1739 1739
1740static Lisp_Object
1741get_required_string_keyword_param (Lisp_Object kwargs, Lisp_Object keyword)
1742{
1743 Lisp_Object arg = plist_member (kwargs, keyword);
1744 if (NILP (arg) || !CONSP (arg) || !CONSP (XCDR (arg)))
1745 error ("Missing %s keyword parameter", SSDATA (SYMBOL_NAME (keyword)));
1746 Lisp_Object val = XCAR (XCDR (arg));
1747 if (!STRINGP (val))
1748 error ("%s value not a string", SSDATA (SYMBOL_NAME (keyword)));
1749 return val;
1750}
1751
1740/* Starting asynchronous inferior processes. */ 1752/* Starting asynchronous inferior processes. */
1741 1753
1742DEFUN ("make-process", Fmake_process, Smake_process, 0, MANY, 0, 1754DEFUN ("make-process", Fmake_process, Smake_process, 0, MANY, 0,
@@ -1801,7 +1813,7 @@ such handler, proceed as if FILE-HANDLER were nil.
1801usage: (make-process &rest ARGS) */) 1813usage: (make-process &rest ARGS) */)
1802 (ptrdiff_t nargs, Lisp_Object *args) 1814 (ptrdiff_t nargs, Lisp_Object *args)
1803{ 1815{
1804 Lisp_Object buffer, name, command, program, proc, contact, current_dir, tem; 1816 Lisp_Object buffer, command, program, proc, contact, current_dir, tem;
1805 Lisp_Object xstderr, stderrproc; 1817 Lisp_Object xstderr, stderrproc;
1806 specpdl_ref count = SPECPDL_INDEX (); 1818 specpdl_ref count = SPECPDL_INDEX ();
1807 1819
@@ -1830,8 +1842,7 @@ usage: (make-process &rest ARGS) */)
1830 chdir, since it's in a vfork. */ 1842 chdir, since it's in a vfork. */
1831 current_dir = get_current_directory (true); 1843 current_dir = get_current_directory (true);
1832 1844
1833 name = plist_get (contact, QCname); 1845 Lisp_Object name = get_required_string_keyword_param (contact, QCname);
1834 CHECK_STRING (name);
1835 1846
1836 command = plist_get (contact, QCcommand); 1847 command = plist_get (contact, QCcommand);
1837 if (CONSP (command)) 1848 if (CONSP (command))
@@ -2408,7 +2419,7 @@ usage: (make-pipe-process &rest ARGS) */)
2408{ 2419{
2409 Lisp_Object proc, contact; 2420 Lisp_Object proc, contact;
2410 struct Lisp_Process *p; 2421 struct Lisp_Process *p;
2411 Lisp_Object name, buffer; 2422 Lisp_Object buffer;
2412 Lisp_Object tem; 2423 Lisp_Object tem;
2413 int inchannel, outchannel; 2424 int inchannel, outchannel;
2414 2425
@@ -2417,8 +2428,7 @@ usage: (make-pipe-process &rest ARGS) */)
2417 2428
2418 contact = Flist (nargs, args); 2429 contact = Flist (nargs, args);
2419 2430
2420 name = plist_get (contact, QCname); 2431 Lisp_Object name = get_required_string_keyword_param (contact, QCname);
2421 CHECK_STRING (name);
2422 proc = make_process (name); 2432 proc = make_process (name);
2423 specpdl_ref specpdl_count = SPECPDL_INDEX (); 2433 specpdl_ref specpdl_count = SPECPDL_INDEX ();
2424 record_unwind_protect (remove_process, proc); 2434 record_unwind_protect (remove_process, proc);
@@ -3938,7 +3948,7 @@ usage: (make-network-process &rest ARGS) */)
3938#endif 3948#endif
3939 EMACS_INT port = 0; 3949 EMACS_INT port = 0;
3940 Lisp_Object tem; 3950 Lisp_Object tem;
3941 Lisp_Object name, buffer, host, service, address; 3951 Lisp_Object buffer, host, service, address;
3942 Lisp_Object filter, sentinel, use_external_socket_p; 3952 Lisp_Object filter, sentinel, use_external_socket_p;
3943 Lisp_Object addrinfos = Qnil; 3953 Lisp_Object addrinfos = Qnil;
3944 int socktype; 3954 int socktype;
@@ -3975,7 +3985,7 @@ usage: (make-network-process &rest ARGS) */)
3975 else 3985 else
3976 error ("Unsupported connection type"); 3986 error ("Unsupported connection type");
3977 3987
3978 name = plist_get (contact, QCname); 3988 Lisp_Object name = get_required_string_keyword_param (contact, QCname);
3979 buffer = plist_get (contact, QCbuffer); 3989 buffer = plist_get (contact, QCbuffer);
3980 filter = plist_get (contact, QCfilter); 3990 filter = plist_get (contact, QCfilter);
3981 sentinel = plist_get (contact, QCsentinel); 3991 sentinel = plist_get (contact, QCsentinel);
@@ -3985,7 +3995,6 @@ usage: (make-network-process &rest ARGS) */)
3985 3995
3986 if (!NILP (server) && nowait) 3996 if (!NILP (server) && nowait)
3987 error ("`:server' is incompatible with `:nowait'"); 3997 error ("`:server' is incompatible with `:nowait'");
3988 CHECK_STRING (name);
3989 3998
3990 /* :local ADDRESS or :remote ADDRESS */ 3999 /* :local ADDRESS or :remote ADDRESS */
3991 if (NILP (server)) 4000 if (NILP (server))