From e7375432c53e899d3cc6358c65e6cfd44035ddcf Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Tue, 14 Jan 2025 21:36:46 +0100 Subject: [PATCH] Use calln instead of calling Ffuncall directly * src/bytecode.c (bcall0): * src/comp.c (bcall0): * src/eval.c (apply1): * src/lisp.h (call0): * src/thread.c (invoke_thread_function): Use calln instead of calling Ffuncall directly. * admin/coccinelle/calln.cocci: New semantic patch. (cherry picked from commit 16c89c5ae5ec0c002c327793e783f0a943bacb0d) --- admin/coccinelle/calln.cocci | 21 +++++++++++++++++++++ src/bytecode.c | 2 +- src/comp.c | 2 +- src/eval.c | 2 +- src/lisp.h | 2 +- src/thread.c | 2 +- 6 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 admin/coccinelle/calln.cocci diff --git a/admin/coccinelle/calln.cocci b/admin/coccinelle/calln.cocci new file mode 100644 index 00000000000..5e720931fb5 --- /dev/null +++ b/admin/coccinelle/calln.cocci @@ -0,0 +1,21 @@ +// Use the calln macro where possible. +@@ +@@ +- CALLN ( Ffuncall, ++ calln ( + ...) + +@@ +constant c; +expression e; +@@ +- Ffuncall ( c, &e ) ++ calln ( e ) + +@@ +constant c; +expression e; +@@ +- Ffuncall ( c, &e, ++ calln ( e, + ...) diff --git a/src/bytecode.c b/src/bytecode.c index fcf369400b9..d62d7d067b1 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -327,7 +327,7 @@ If the third argument is incorrect, Emacs may crash. */) static void bcall0 (Lisp_Object f) { - Ffuncall (1, &f); + calln (f); } /* The bytecode stack size in bytes. diff --git a/src/comp.c b/src/comp.c index 96b314b2709..97c7ea2efac 100644 --- a/src/comp.c +++ b/src/comp.c @@ -862,7 +862,7 @@ freloc_check_fill (void) static void bcall0 (Lisp_Object f) { - Ffuncall (1, &f); + calln (f); } static gcc_jit_block * diff --git a/src/eval.c b/src/eval.c index b0cc2505a35..941d121c2fb 100644 --- a/src/eval.c +++ b/src/eval.c @@ -2967,7 +2967,7 @@ run_hook_with_args_2 (Lisp_Object hook, Lisp_Object arg1, Lisp_Object arg2) Lisp_Object apply1 (Lisp_Object fn, Lisp_Object arg) { - return NILP (arg) ? Ffuncall (1, &fn) : CALLN (Fapply, fn, arg); + return NILP (arg) ? calln (fn) : CALLN (Fapply, fn, arg); } DEFUN ("functionp", Ffunctionp, Sfunctionp, 1, 1, 0, diff --git a/src/lisp.h b/src/lisp.h index e3142f3b8cc..a8fe2e9f6bc 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -3528,7 +3528,7 @@ enum maxargs INLINE Lisp_Object call0 (Lisp_Object fn) { - return Ffuncall (1, &fn); + return calln (fn); } extern void defvar_lisp (struct Lisp_Objfwd const *, char const *); diff --git a/src/thread.c b/src/thread.c index bb62283dd21..5610f8be0dd 100644 --- a/src/thread.c +++ b/src/thread.c @@ -741,7 +741,7 @@ invoke_thread_function (void) { specpdl_ref count = SPECPDL_INDEX (); - current_thread->result = Ffuncall (1, ¤t_thread->function); + current_thread->result = calln (current_thread->function); return unbind_to (count, Qnil); } -- 2.39.5