From: Paul Eggert Date: Mon, 5 Jun 2017 06:52:10 +0000 (-0700) Subject: Remove easserts etc. from emacs-module.c X-Git-Tag: emacs-26.0.90~521^2~170^2~3 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=6e4abc9d100732b0825f72b402dda8912d3d1755;p=emacs.git Remove easserts etc. from emacs-module.c Most of these seem to run afoul of the comment "Do NOT use 'eassert' for checking validity of user code in the module." * src/emacs-module.c (MODULE_FUNCTION_BEGIN_NO_CATCH) (module_non_local_exit_check, module_non_local_exit_clear) (module_non_local_exit_get, module_non_local_exit_signal) (module_non_local_exit_throw, module_make_string): Remove unnecessary easserts that pointers are nonnull. Hardware checks this for us nowadays, and the checks just clutter up the code. (module_extract_integer): Remove unnecessary verify that a C signed integer is in the range INTMAX_MIN..INTMAX_MAX. The C standard guarantees this. (module_copy_string_contents): Remove unnecessary eassert that Lisp strings are null-terminated. (module_function_arity): Remove unnecessary easserts that function arities are in range. --- diff --git a/src/emacs-module.c b/src/emacs-module.c index 56105123ff4..8ddf157b39f 100644 --- a/src/emacs-module.c +++ b/src/emacs-module.c @@ -219,7 +219,6 @@ static emacs_value const module_nil = 0; #define MODULE_FUNCTION_BEGIN_NO_CATCH(error_retval) \ do { \ - eassert (env != NULL); \ check_main_thread (); \ if (module_non_local_exit_check (env) != emacs_funcall_exit_return) \ return error_retval; \ @@ -308,7 +307,6 @@ module_free_global_ref (emacs_env *env, emacs_value ref) static enum emacs_funcall_exit module_non_local_exit_check (emacs_env *env) { - eassert (env != NULL); check_main_thread (); return env->private_members->pending_non_local_exit; } @@ -316,7 +314,6 @@ module_non_local_exit_check (emacs_env *env) static void module_non_local_exit_clear (emacs_env *env) { - eassert (env != NULL); check_main_thread (); env->private_members->pending_non_local_exit = emacs_funcall_exit_return; } @@ -324,9 +321,6 @@ module_non_local_exit_clear (emacs_env *env) static enum emacs_funcall_exit module_non_local_exit_get (emacs_env *env, emacs_value *sym, emacs_value *data) { - eassert (env != NULL); - eassert (sym != NULL); - eassert (data != NULL); check_main_thread (); struct emacs_env_private *p = env->private_members; if (p->pending_non_local_exit != emacs_funcall_exit_return) @@ -342,7 +336,6 @@ module_non_local_exit_get (emacs_env *env, emacs_value *sym, emacs_value *data) static void module_non_local_exit_signal (emacs_env *env, emacs_value sym, emacs_value data) { - eassert (env != NULL); check_main_thread (); if (module_non_local_exit_check (env) == emacs_funcall_exit_return) module_non_local_exit_signal_1 (env, value_to_lisp (sym), @@ -352,7 +345,6 @@ module_non_local_exit_signal (emacs_env *env, emacs_value sym, emacs_value data) static void module_non_local_exit_throw (emacs_env *env, emacs_value tag, emacs_value value) { - eassert (env != NULL); check_main_thread (); if (module_non_local_exit_check (env) == emacs_funcall_exit_return) module_non_local_exit_throw_1 (env, value_to_lisp (tag), @@ -449,8 +441,6 @@ module_eq (emacs_env *env, emacs_value a, emacs_value b) static intmax_t module_extract_integer (emacs_env *env, emacs_value n) { - verify (MOST_NEGATIVE_FIXNUM >= INTMAX_MIN); - verify (MOST_POSITIVE_FIXNUM <= INTMAX_MAX); MODULE_FUNCTION_BEGIN (0); Lisp_Object l = value_to_lisp (n); CHECK_NUMBER (l); @@ -509,7 +499,6 @@ module_copy_string_contents (emacs_env *env, emacs_value value, char *buffer, } *length = required_buf_size; - eassert (SREF (lisp_str_utf8, raw_size) == '\0'); memcpy (buffer, SDATA (lisp_str_utf8), raw_size + 1); return true; @@ -519,7 +508,6 @@ static emacs_value module_make_string (emacs_env *env, const char *str, ptrdiff_t length) { MODULE_FUNCTION_BEGIN (module_nil); - eassert (str != NULL); if (! (0 <= length && length <= STRING_BYTES_BOUND)) xsignal0 (Qoverflow_error); AUTO_STRING_WITH_LEN (lstr, str, length); @@ -726,11 +714,7 @@ Lisp_Object module_function_arity (const struct Lisp_Module_Function *const function) { ptrdiff_t minargs = function->min_arity; - eassert (minargs >= 0); - eassert (minargs <= MOST_POSITIVE_FIXNUM); ptrdiff_t maxargs = function->max_arity; - eassert (maxargs >= minargs || maxargs == MANY); - eassert (maxargs <= MOST_POSITIVE_FIXNUM); return Fcons (make_number (minargs), maxargs == MANY ? Qmany : make_number (maxargs)); }