patch 9.1.1692: global_functions are not constant Commit: https://github.com/vim/vim/commit/93160530c470c58a697b5e292e2c4916a88afd38 Author: Damien Lejay <dam...@lejay.be> Date: Tue Aug 26 21:03:31 2025 +0200
patch 9.1.1692: global_functions are not constant Problem: global_functions are not constant Solution: Place global_functions[] in read-only memory (Damien Lejay). Mark global_functions[] as `static const`. The table is never modified at runtime, so keeping it in writable `.data` has no benefit. Only a local pointer in func_check_arg_types() needed adjusting to `const`. No functional changes. closes: #18121 Signed-off-by: Damien Lejay <dam...@lejay.be> Signed-off-by: Christian Brabandt <c...@256bit.org> diff --git a/src/evalfunc.c b/src/evalfunc.c index 13f1823d3..3a0e9a77a 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -1934,7 +1934,7 @@ typedef struct # define TERM_FUNC(name) NULL #endif -static funcentry_T global_functions[] = +static const funcentry_T global_functions[] = { {"abs", 1, 1, FEARG_1, arg1_float_or_nr, ret_any, f_abs}, @@ -3360,7 +3360,7 @@ internal_func_check_arg_types( return FAIL; } - argcheck_T *argchecks = global_functions[idx].f_argcheck; + const argcheck_T *argchecks = global_functions[idx].f_argcheck; if (argchecks == NULL) return OK; diff --git a/src/testdir/test_function_lists.vim b/src/testdir/test_function_lists.vim index dd69b8326..bd79f7717 100644 --- a/src/testdir/test_function_lists.vim +++ b/src/testdir/test_function_lists.vim @@ -17,7 +17,7 @@ func Test_function_lists() " Create a file of the functions in evalfunc.c:global_functions[]. enew! read ../evalfunc.c - 1,/^static funcentry_T global_functions\[\] =$/d + 1,/^static const funcentry_T global_functions\[\] =$/d call search('^};$') .,$d v/^ {/d @@ -38,7 +38,7 @@ func Test_function_lists() " not obsolete, sorted in ASCII order. enew! read ../evalfunc.c - 1,/^static funcentry_T global_functions\[\] =$/d + 1,/^static const funcentry_T global_functions\[\] =$/d call search('^};$') .,$d v/^ {/d diff --git a/src/version.c b/src/version.c index db3a4b7ac..ec3bcc5de 100644 --- a/src/version.c +++ b/src/version.c @@ -724,6 +724,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1692, /**/ 1691, /**/ -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/vim_dev/E1uqz8J-003oPt-Mm%40256bit.org.