aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2017-06-04 23:52:10 -0700
committerPaul Eggert2017-06-04 23:53:47 -0700
commit6e4abc9d100732b0825f72b402dda8912d3d1755 (patch)
treed1c607279eda83b30b7ed72df9b119d6c7a3f54b /src
parent620d65370afd319b706cea0eccffd0ee0ffd2e26 (diff)
downloademacs-6e4abc9d100732b0825f72b402dda8912d3d1755.tar.gz
emacs-6e4abc9d100732b0825f72b402dda8912d3d1755.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/emacs-module.c16
1 files changed, 0 insertions, 16 deletions
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;
219 219
220#define MODULE_FUNCTION_BEGIN_NO_CATCH(error_retval) \ 220#define MODULE_FUNCTION_BEGIN_NO_CATCH(error_retval) \
221 do { \ 221 do { \
222 eassert (env != NULL); \
223 check_main_thread (); \ 222 check_main_thread (); \
224 if (module_non_local_exit_check (env) != emacs_funcall_exit_return) \ 223 if (module_non_local_exit_check (env) != emacs_funcall_exit_return) \
225 return error_retval; \ 224 return error_retval; \
@@ -308,7 +307,6 @@ module_free_global_ref (emacs_env *env, emacs_value ref)
308static enum emacs_funcall_exit 307static enum emacs_funcall_exit
309module_non_local_exit_check (emacs_env *env) 308module_non_local_exit_check (emacs_env *env)
310{ 309{
311 eassert (env != NULL);
312 check_main_thread (); 310 check_main_thread ();
313 return env->private_members->pending_non_local_exit; 311 return env->private_members->pending_non_local_exit;
314} 312}
@@ -316,7 +314,6 @@ module_non_local_exit_check (emacs_env *env)
316static void 314static void
317module_non_local_exit_clear (emacs_env *env) 315module_non_local_exit_clear (emacs_env *env)
318{ 316{
319 eassert (env != NULL);
320 check_main_thread (); 317 check_main_thread ();
321 env->private_members->pending_non_local_exit = emacs_funcall_exit_return; 318 env->private_members->pending_non_local_exit = emacs_funcall_exit_return;
322} 319}
@@ -324,9 +321,6 @@ module_non_local_exit_clear (emacs_env *env)
324static enum emacs_funcall_exit 321static enum emacs_funcall_exit
325module_non_local_exit_get (emacs_env *env, emacs_value *sym, emacs_value *data) 322module_non_local_exit_get (emacs_env *env, emacs_value *sym, emacs_value *data)
326{ 323{
327 eassert (env != NULL);
328 eassert (sym != NULL);
329 eassert (data != NULL);
330 check_main_thread (); 324 check_main_thread ();
331 struct emacs_env_private *p = env->private_members; 325 struct emacs_env_private *p = env->private_members;
332 if (p->pending_non_local_exit != emacs_funcall_exit_return) 326 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)
342static void 336static void
343module_non_local_exit_signal (emacs_env *env, emacs_value sym, emacs_value data) 337module_non_local_exit_signal (emacs_env *env, emacs_value sym, emacs_value data)
344{ 338{
345 eassert (env != NULL);
346 check_main_thread (); 339 check_main_thread ();
347 if (module_non_local_exit_check (env) == emacs_funcall_exit_return) 340 if (module_non_local_exit_check (env) == emacs_funcall_exit_return)
348 module_non_local_exit_signal_1 (env, value_to_lisp (sym), 341 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)
352static void 345static void
353module_non_local_exit_throw (emacs_env *env, emacs_value tag, emacs_value value) 346module_non_local_exit_throw (emacs_env *env, emacs_value tag, emacs_value value)
354{ 347{
355 eassert (env != NULL);
356 check_main_thread (); 348 check_main_thread ();
357 if (module_non_local_exit_check (env) == emacs_funcall_exit_return) 349 if (module_non_local_exit_check (env) == emacs_funcall_exit_return)
358 module_non_local_exit_throw_1 (env, value_to_lisp (tag), 350 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)
449static intmax_t 441static intmax_t
450module_extract_integer (emacs_env *env, emacs_value n) 442module_extract_integer (emacs_env *env, emacs_value n)
451{ 443{
452 verify (MOST_NEGATIVE_FIXNUM >= INTMAX_MIN);
453 verify (MOST_POSITIVE_FIXNUM <= INTMAX_MAX);
454 MODULE_FUNCTION_BEGIN (0); 444 MODULE_FUNCTION_BEGIN (0);
455 Lisp_Object l = value_to_lisp (n); 445 Lisp_Object l = value_to_lisp (n);
456 CHECK_NUMBER (l); 446 CHECK_NUMBER (l);
@@ -509,7 +499,6 @@ module_copy_string_contents (emacs_env *env, emacs_value value, char *buffer,
509 } 499 }
510 500
511 *length = required_buf_size; 501 *length = required_buf_size;
512 eassert (SREF (lisp_str_utf8, raw_size) == '\0');
513 memcpy (buffer, SDATA (lisp_str_utf8), raw_size + 1); 502 memcpy (buffer, SDATA (lisp_str_utf8), raw_size + 1);
514 503
515 return true; 504 return true;
@@ -519,7 +508,6 @@ static emacs_value
519module_make_string (emacs_env *env, const char *str, ptrdiff_t length) 508module_make_string (emacs_env *env, const char *str, ptrdiff_t length)
520{ 509{
521 MODULE_FUNCTION_BEGIN (module_nil); 510 MODULE_FUNCTION_BEGIN (module_nil);
522 eassert (str != NULL);
523 if (! (0 <= length && length <= STRING_BYTES_BOUND)) 511 if (! (0 <= length && length <= STRING_BYTES_BOUND))
524 xsignal0 (Qoverflow_error); 512 xsignal0 (Qoverflow_error);
525 AUTO_STRING_WITH_LEN (lstr, str, length); 513 AUTO_STRING_WITH_LEN (lstr, str, length);
@@ -726,11 +714,7 @@ Lisp_Object
726module_function_arity (const struct Lisp_Module_Function *const function) 714module_function_arity (const struct Lisp_Module_Function *const function)
727{ 715{
728 ptrdiff_t minargs = function->min_arity; 716 ptrdiff_t minargs = function->min_arity;
729 eassert (minargs >= 0);
730 eassert (minargs <= MOST_POSITIVE_FIXNUM);
731 ptrdiff_t maxargs = function->max_arity; 717 ptrdiff_t maxargs = function->max_arity;
732 eassert (maxargs >= minargs || maxargs == MANY);
733 eassert (maxargs <= MOST_POSITIVE_FIXNUM);
734 return Fcons (make_number (minargs), 718 return Fcons (make_number (minargs),
735 maxargs == MANY ? Qmany : make_number (maxargs)); 719 maxargs == MANY ? Qmany : make_number (maxargs));
736} 720}