diff options
| author | Philipp Stephani | 2017-06-04 19:28:50 +0200 |
|---|---|---|
| committer | Philipp Stephani | 2017-06-04 19:50:51 +0200 |
| commit | d37201722e2151df1f6b6fa1e2f33b5f91e27e03 (patch) | |
| tree | 57d9436130f86cf2cf1f81b9e70369ffd00a16fc | |
| parent | 27445a82f04ff848993821de1596923441859838 (diff) | |
| download | emacs-d37201722e2151df1f6b6fa1e2f33b5f91e27e03.tar.gz emacs-d37201722e2151df1f6b6fa1e2f33b5f91e27e03.zip | |
Use more specific errors for module load failure
* src/emacs-module.c (syms_of_module): Add more specific error
symbols.
(Fmodule_load): Use them.
| -rw-r--r-- | src/emacs-module.c | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/src/emacs-module.c b/src/emacs-module.c index 187a620cc08..f2efc83d257 100644 --- a/src/emacs-module.c +++ b/src/emacs-module.c | |||
| @@ -626,15 +626,15 @@ DEFUN ("module-load", Fmodule_load, Smodule_load, 1, 1, 0, | |||
| 626 | CHECK_STRING (file); | 626 | CHECK_STRING (file); |
| 627 | handle = dynlib_open (SSDATA (file)); | 627 | handle = dynlib_open (SSDATA (file)); |
| 628 | if (!handle) | 628 | if (!handle) |
| 629 | error ("Cannot load file %s: %s", SDATA (file), dynlib_error ()); | 629 | xsignal2 (Qmodule_open_failed, file, build_string (dynlib_error ())); |
| 630 | 630 | ||
| 631 | gpl_sym = dynlib_sym (handle, "plugin_is_GPL_compatible"); | 631 | gpl_sym = dynlib_sym (handle, "plugin_is_GPL_compatible"); |
| 632 | if (!gpl_sym) | 632 | if (!gpl_sym) |
| 633 | error ("Module %s is not GPL compatible", SDATA (file)); | 633 | xsignal1 (Qmodule_not_gpl_compatible, file); |
| 634 | 634 | ||
| 635 | module_init = (emacs_init_function) dynlib_func (handle, "emacs_module_init"); | 635 | module_init = (emacs_init_function) dynlib_func (handle, "emacs_module_init"); |
| 636 | if (!module_init) | 636 | if (!module_init) |
| 637 | error ("Module %s does not have an init function.", SDATA (file)); | 637 | xsignal1 (Qmissing_module_init_function, file); |
| 638 | 638 | ||
| 639 | struct emacs_runtime_private rt; /* Includes the public emacs_env. */ | 639 | struct emacs_runtime_private rt; /* Includes the public emacs_env. */ |
| 640 | struct emacs_env_private priv; | 640 | struct emacs_env_private priv; |
| @@ -652,7 +652,7 @@ DEFUN ("module-load", Fmodule_load, Smodule_load, 1, 1, 0, | |||
| 652 | { | 652 | { |
| 653 | if (FIXNUM_OVERFLOW_P (r)) | 653 | if (FIXNUM_OVERFLOW_P (r)) |
| 654 | xsignal0 (Qoverflow_error); | 654 | xsignal0 (Qoverflow_error); |
| 655 | xsignal2 (Qmodule_load_failed, file, make_number (r)); | 655 | xsignal2 (Qmodule_init_failed, file, make_number (r)); |
| 656 | } | 656 | } |
| 657 | 657 | ||
| 658 | return Qt; | 658 | return Qt; |
| @@ -999,6 +999,34 @@ syms_of_module (void) | |||
| 999 | listn (CONSTYPE_PURE, 2, Qinvalid_module_call, Qerror)); | 999 | listn (CONSTYPE_PURE, 2, Qinvalid_module_call, Qerror)); |
| 1000 | Fput (Qinvalid_module_call, Qerror_message, | 1000 | Fput (Qinvalid_module_call, Qerror_message, |
| 1001 | build_pure_c_string ("Invalid module call")); | 1001 | build_pure_c_string ("Invalid module call")); |
| 1002 | DEFSYM (Qmodule_open_failed, "module-open-failed"); | ||
| 1003 | Fput (Qmodule_open_failed, Qerror_conditions, | ||
| 1004 | listn (CONSTYPE_PURE, 3, | ||
| 1005 | Qmodule_open_failed, Qmodule_load_failed, Qerror)); | ||
| 1006 | Fput (Qmodule_open_failed, Qerror_message, | ||
| 1007 | build_pure_c_string ("Module could not be opened")); | ||
| 1008 | |||
| 1009 | DEFSYM (Qmodule_not_gpl_compatible, "module-not-gpl-compatible"); | ||
| 1010 | Fput (Qmodule_not_gpl_compatible, Qerror_conditions, | ||
| 1011 | listn (CONSTYPE_PURE, 3, | ||
| 1012 | Qmodule_not_gpl_compatible, Qmodule_load_failed, Qerror)); | ||
| 1013 | Fput (Qmodule_not_gpl_compatible, Qerror_message, | ||
| 1014 | build_pure_c_string ("Module is not GPL compatible")); | ||
| 1015 | |||
| 1016 | DEFSYM (Qmissing_module_init_function, "missing-module-init-function"); | ||
| 1017 | Fput (Qmissing_module_init_function, Qerror_conditions, | ||
| 1018 | listn (CONSTYPE_PURE, 3, | ||
| 1019 | Qmissing_module_init_function, Qmodule_load_failed, Qerror)); | ||
| 1020 | Fput (Qmissing_module_init_function, Qerror_message, | ||
| 1021 | build_pure_c_string ("Module does not export an " | ||
| 1022 | "initialization function")); | ||
| 1023 | |||
| 1024 | DEFSYM (Qmodule_init_failed, "module-init-failed"); | ||
| 1025 | Fput (Qmodule_init_failed, Qerror_conditions, | ||
| 1026 | listn (CONSTYPE_PURE, 3, | ||
| 1027 | Qmodule_init_failed, Qmodule_load_failed, Qerror)); | ||
| 1028 | Fput (Qmodule_init_failed, Qerror_message, | ||
| 1029 | build_pure_c_string ("Module initialization failed")); | ||
| 1002 | 1030 | ||
| 1003 | DEFSYM (Qinvalid_arity, "invalid-arity"); | 1031 | DEFSYM (Qinvalid_arity, "invalid-arity"); |
| 1004 | Fput (Qinvalid_arity, Qerror_conditions, | 1032 | Fput (Qinvalid_arity, Qerror_conditions, |