summaryrefslogtreecommitdiff
path: root/src/emacs-module.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2015-11-19 14:24:50 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2015-11-19 14:25:17 -0800
commitd9b300af5c7b07bd870046e73df53e19e860fdb9 (patch)
tree808f21f765c38490a164d2efe4c8af182299db6c /src/emacs-module.c
parent68d58e69738db41061812b10f2f3f50b6a1b9aa0 (diff)
downloademacs-d9b300af5c7b07bd870046e73df53e19e860fdb9.tar.gz
Omit ‘const’ on locals
Remove ‘const’ qualifier from locals that were newly added. We don’t normally bother declaring locals with ‘const’ even though they are not modified, for the same reason we don’t bother declaring them with ‘register’ even though their addresses are not taken; the advantage in compile-time checking isn’t worth the loss of readability. * modules/mod-test/mod-test.c (Fmod_test_non_local_exit_funcall) (Fmod_test_vector_fill, Fmod_test_vector_eq): * src/emacs-module.c (MODULE_SETJMP_1) (module_make_global_ref, module_free_global_ref) (module_non_local_exit_get, module_make_function) (module_extract_integer, module_extract_float) (module_get_user_ptr, module_set_user_ptr) (module_get_user_finalizer, module_set_user_finalizer) (module_vec_get, Fmodule_call) (module_non_local_exit_signal_1) (module_non_local_exit_throw_1, lisp_to_value) (finalize_storage, allocate_emacs_value, mark_modules) (module_handle_signal, module_handle_throw) (module_format_fun_env): * src/eval.c (push_handler, push_handler_nosignal) (init_handler): * src/lread.c (suffix_p): Omit unnecessary ‘const’.
Diffstat (limited to 'src/emacs-module.c')
-rw-r--r--src/emacs-module.c72
1 files changed, 37 insertions, 35 deletions
diff --git a/src/emacs-module.c b/src/emacs-module.c
index b39ac7df057..166f6ddf93c 100644
--- a/src/emacs-module.c
+++ b/src/emacs-module.c
@@ -141,7 +141,7 @@ static void check_main_thread (void);
static void finalize_environment (struct env_storage *);
static void initialize_environment (struct env_storage *);
static void module_args_out_of_range (emacs_env *, Lisp_Object, Lisp_Object);
-static void module_handle_signal (emacs_env *, const Lisp_Object);
+static void module_handle_signal (emacs_env *, Lisp_Object);
static void module_handle_throw (emacs_env *, Lisp_Object);
static void module_non_local_exit_signal_1 (emacs_env *, Lisp_Object, Lisp_Object);
static void module_non_local_exit_throw_1 (emacs_env *, Lisp_Object, Lisp_Object);
@@ -201,7 +201,7 @@ static void module_wrong_type (emacs_env *, Lisp_Object, Lisp_Object);
return retval; \
} \
verify (module_has_cleanup); \
- const int dummy __attribute__ ((cleanup (module_reset_handlerlist))); \
+ int dummy __attribute__ ((cleanup (module_reset_handlerlist))); \
if (sys_setjmp (c->jmp)) \
{ \
(handlerfunc) (env, c->val); \
@@ -263,7 +263,7 @@ module_make_global_ref (emacs_env *env, emacs_value ref)
{
Lisp_Object value = HASH_VALUE (h, i);
eassert (NATNUMP (value));
- const EMACS_UINT refcount = XFASTINT (value);
+ EMACS_UINT refcount = XFASTINT (value);
if (refcount >= MOST_POSITIVE_FIXNUM)
{
module_non_local_exit_signal_1 (env, Qoverflow_error, Qnil);
@@ -297,7 +297,7 @@ module_free_global_ref (emacs_env *env, emacs_value ref)
{
Lisp_Object value = HASH_VALUE (h, i);
eassert (NATNUMP (value));
- const EMACS_UINT refcount = XFASTINT (value);
+ EMACS_UINT refcount = XFASTINT (value);
eassert (refcount > 0);
if (refcount > 1)
{
@@ -329,7 +329,7 @@ static enum emacs_funcall_exit
module_non_local_exit_get (emacs_env *env, emacs_value *sym, emacs_value *data)
{
check_main_thread ();
- struct emacs_env_private *const p = env->private_members;
+ struct emacs_env_private *p = env->private_members;
if (p->pending_non_local_exit != emacs_funcall_exit_return)
{
*sym = &p->non_local_exit_symbol;
@@ -366,7 +366,7 @@ module_non_local_exit_throw (emacs_env *env, emacs_value tag, emacs_value value)
static emacs_value
module_make_function (emacs_env *env, int min_arity, int max_arity,
- emacs_subr subr, const char *const documentation,
+ emacs_subr subr, const char *documentation,
void *data)
{
check_main_thread ();
@@ -456,7 +456,7 @@ module_extract_integer (emacs_env *env, emacs_value n)
{
check_main_thread ();
eassert (module_non_local_exit_check (env) == emacs_funcall_exit_return);
- const Lisp_Object l = value_to_lisp (n);
+ Lisp_Object l = value_to_lisp (n);
if (! INTEGERP (l))
{
module_wrong_type (env, Qintegerp, l);
@@ -483,7 +483,7 @@ module_extract_float (emacs_env *env, emacs_value f)
{
check_main_thread ();
eassert (module_non_local_exit_check (env) == emacs_funcall_exit_return);
- const Lisp_Object lisp = value_to_lisp (f);
+ Lisp_Object lisp = value_to_lisp (f);
if (! FLOATP (lisp))
{
module_wrong_type (env, Qfloatp, lisp);
@@ -562,7 +562,7 @@ module_get_user_ptr (emacs_env *env, emacs_value uptr)
{
check_main_thread ();
eassert (module_non_local_exit_check (env) == emacs_funcall_exit_return);
- const Lisp_Object lisp = value_to_lisp (uptr);
+ Lisp_Object lisp = value_to_lisp (uptr);
if (! USER_PTRP (lisp))
{
module_wrong_type (env, Quser_ptr, lisp);
@@ -576,8 +576,9 @@ module_set_user_ptr (emacs_env *env, emacs_value uptr, void *ptr)
{
check_main_thread ();
eassert (module_non_local_exit_check (env) == emacs_funcall_exit_return);
- const Lisp_Object lisp = value_to_lisp (uptr);
- if (! USER_PTRP (lisp)) module_wrong_type (env, Quser_ptr, lisp);
+ Lisp_Object lisp = value_to_lisp (uptr);
+ if (! USER_PTRP (lisp))
+ module_wrong_type (env, Quser_ptr, lisp);
XUSER_PTR (lisp)->p = ptr;
}
@@ -586,7 +587,7 @@ module_get_user_finalizer (emacs_env *env, emacs_value uptr)
{
check_main_thread ();
eassert (module_non_local_exit_check (env) == emacs_funcall_exit_return);
- const Lisp_Object lisp = value_to_lisp (uptr);
+ Lisp_Object lisp = value_to_lisp (uptr);
if (! USER_PTRP (lisp))
{
module_wrong_type (env, Quser_ptr, lisp);
@@ -601,8 +602,9 @@ module_set_user_finalizer (emacs_env *env, emacs_value uptr,
{
check_main_thread ();
eassert (module_non_local_exit_check (env) == emacs_funcall_exit_return);
- const Lisp_Object lisp = value_to_lisp (uptr);
- if (! USER_PTRP (lisp)) module_wrong_type (env, Quser_ptr, lisp);
+ Lisp_Object lisp = value_to_lisp (uptr);
+ if (! USER_PTRP (lisp))
+ module_wrong_type (env, Quser_ptr, lisp);
XUSER_PTR (lisp)->finalizer = fin;
}
@@ -649,7 +651,7 @@ module_vec_get (emacs_env *env, emacs_value vec, size_t i)
return NULL;
}
/* Prevent error-prone comparison between types of different signedness. */
- const size_t size = ASIZE (lvec);
+ size_t size = ASIZE (lvec);
eassert (size >= 0);
if (i >= size)
{
@@ -734,8 +736,8 @@ ENVOBJ is a save pointer to a module_fun_env structure.
ARGLIST is a list of arguments passed to SUBRPTR. */)
(Lisp_Object envobj, Lisp_Object arglist)
{
- const struct module_fun_env *const envptr = XSAVE_POINTER (envobj, 0);
- const EMACS_INT len = XINT (Flength (arglist));
+ struct module_fun_env *envptr = XSAVE_POINTER (envobj, 0);
+ EMACS_INT len = XINT (Flength (arglist));
eassert (len >= 0);
if (len > MOST_POSITIVE_FIXNUM)
xsignal0 (Qoverflow_error);
@@ -771,14 +773,14 @@ ARGLIST is a list of arguments passed to SUBRPTR. */)
case emacs_funcall_exit_signal:
{
Lisp_Object symbol = value_to_lisp (&env.priv.non_local_exit_symbol);
- const Lisp_Object data = value_to_lisp (&env.priv.non_local_exit_data);
+ Lisp_Object data = value_to_lisp (&env.priv.non_local_exit_data);
finalize_environment (&env);
xsignal (symbol, data);
}
case emacs_funcall_exit_throw:
{
- const Lisp_Object tag = value_to_lisp (&env.priv.non_local_exit_symbol);
- const Lisp_Object value = value_to_lisp (&env.priv.non_local_exit_data);
+ Lisp_Object tag = value_to_lisp (&env.priv.non_local_exit_symbol);
+ Lisp_Object value = value_to_lisp (&env.priv.non_local_exit_data);
finalize_environment (&env);
Fthrow (tag, value);
}
@@ -810,7 +812,7 @@ static void
module_non_local_exit_signal_1 (emacs_env *env, Lisp_Object sym,
Lisp_Object data)
{
- struct emacs_env_private *const p = env->private_members;
+ struct emacs_env_private *p = env->private_members;
eassert (p->pending_non_local_exit == emacs_funcall_exit_return);
p->pending_non_local_exit = emacs_funcall_exit_signal;
p->non_local_exit_symbol.v = sym;
@@ -821,7 +823,7 @@ static void
module_non_local_exit_throw_1 (emacs_env *env, Lisp_Object tag,
Lisp_Object value)
{
- struct emacs_env_private *const p = env->private_members;
+ struct emacs_env_private *p = env->private_members;
eassert (p->pending_non_local_exit == emacs_funcall_exit_return);
p->pending_non_local_exit = emacs_funcall_exit_throw;
p->non_local_exit_symbol.v = tag;
@@ -869,7 +871,7 @@ value_to_lisp (emacs_value v)
static emacs_value
lisp_to_value (emacs_env *env, Lisp_Object o)
{
- struct emacs_env_private *const p = env->private_members;
+ struct emacs_env_private *p = env->private_members;
if (p->pending_non_local_exit != emacs_funcall_exit_return)
return NULL;
return allocate_emacs_value (env, &p->storage, o);
@@ -903,7 +905,7 @@ finalize_storage (struct emacs_value_storage *storage)
struct emacs_value_frame *next = storage->initial.next;
while (next != NULL)
{
- struct emacs_value_frame *const current = next;
+ struct emacs_value_frame *current = next;
next = current->next;
free (current);
}
@@ -929,7 +931,7 @@ allocate_emacs_value (emacs_env *env, struct emacs_value_storage *storage,
initialize_frame (storage->current->next);
storage->current = storage->current->next;
}
- const emacs_value value = storage->current->objects + storage->current->offset;
+ emacs_value value = storage->current->objects + storage->current->offset;
value->v = obj;
++storage->current->offset;
return value;
@@ -941,8 +943,8 @@ void mark_modules (void)
{
for (Lisp_Object tem = Vmodule_environments; CONSP (tem); tem = XCDR (tem))
{
- const struct env_storage *const env = XSAVE_POINTER (tem, 0);
- for (const struct emacs_value_frame *frame = &env->priv.storage.initial;
+ struct env_storage *env = XSAVE_POINTER (tem, 0);
+ for (struct emacs_value_frame *frame = &env->priv.storage.initial;
frame != NULL;
frame = frame->next)
for (size_t i = 0; i < frame->offset; ++i)
@@ -1016,7 +1018,7 @@ module_reset_handlerlist (const int *dummy)
/* Called on `signal'. ERR is a pair (SYMBOL . DATA), which gets
stored in the environment. Set the pending non-local exit flag. */
static void
-module_handle_signal (emacs_env *const env, const Lisp_Object err)
+module_handle_signal (emacs_env *env, Lisp_Object err)
{
module_non_local_exit_signal_1 (env, XCAR (err), XCDR (err));
}
@@ -1024,7 +1026,7 @@ module_handle_signal (emacs_env *const env, const Lisp_Object err)
/* Called on `throw'. TAG_VAL is a pair (TAG . VALUE), which gets
stored in the environment. Set the pending non-local exit flag. */
static void
-module_handle_throw (emacs_env *const env, const Lisp_Object tag_val)
+module_handle_throw (emacs_env *env, Lisp_Object tag_val)
{
module_non_local_exit_throw_1 (env, XCAR (tag_val), XCDR (tag_val));
}
@@ -1035,14 +1037,14 @@ module_handle_throw (emacs_env *const env, const Lisp_Object tag_val)
/* Return a string object that contains a user-friendly
representation of the function environment. */
static Lisp_Object
-module_format_fun_env (const struct module_fun_env *const env)
+module_format_fun_env (const struct module_fun_env *env)
{
/* Try to print a function name if possible. */
const char *path, *sym;
if (dynlib_addr (env->subr, &path, &sym))
{
- const char *const format = "#<module function %s from %s>";
- const int size = snprintf (NULL, 0, format, sym, path);
+ static char const format[] = "#<module function %s from %s>";
+ int size = snprintf (NULL, 0, format, sym, path);
eassert (size > 0);
char buffer[size + 1];
snprintf (buffer, sizeof buffer, format, sym, path);
@@ -1050,9 +1052,9 @@ module_format_fun_env (const struct module_fun_env *const env)
}
else
{
- const char *const format = "#<module function at %p>";
- const void *const subr = env->subr;
- const int size = snprintf (NULL, 0, format, subr);
+ static char const format[] = "#<module function at %p>";
+ void *subr = env->subr;
+ int size = snprintf (NULL, 0, format, subr);
eassert (size > 0);
char buffer[size + 1];
snprintf (buffer, sizeof buffer, format, subr);