From a73c705b0c864a9ce042fca6e72e0c92d4ad8237 Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Fri, 16 Dec 2022 23:22:33 +0100 Subject: 51212: remove STOUC() macro This served as a workaround for ancient compilers where casts to unsigned char were broken. --- Src/module.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Src/module.c') diff --git a/Src/module.c b/Src/module.c index bab4d8d73..6cf442270 100644 --- a/Src/module.c +++ b/Src/module.c @@ -2474,7 +2474,7 @@ bin_zmodload(char *nam, char **args, Options ops, UNUSED(int func)) return 1; } for (fp = fonly; *fp; fp++) { - if (OPT_ISSET(ops,STOUC(*fp)) && !OPT_ISSET(ops,'F')) { + if (OPT_ISSET(ops,(unsigned char) *fp) && !OPT_ISSET(ops,'F')) { zwarnnam(nam, "-%c is only allowed with -F", *fp); return 1; } -- cgit v1.2.3 From ec4bd3169d0734ca8ec74ccc52235e71d7e59166 Mon Sep 17 00:00:00 2001 From: Bart Schaefer Date: Sun, 26 Feb 2023 18:54:10 -0800 Subject: 51460: avoid crash on bad parameter autofeature --- ChangeLog | 4 ++++ Src/module.c | 17 +++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) (limited to 'Src/module.c') diff --git a/ChangeLog b/ChangeLog index 1891b8b5a..2c07606c5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2023-02-26 Bart Schaefer + + * 51460: Src/module.c: avoid crash on bad parameter autofeature + 2023-02-24 Oliver Kiddle * Shohei YOSHIDA: 51473: Completion/Unix/Command/_cal: diff --git a/Src/module.c b/Src/module.c index 6cf442270..a6005f30b 100644 --- a/Src/module.c +++ b/Src/module.c @@ -1198,6 +1198,7 @@ add_autoparam(const char *module, const char *pnam, int flags) { Param pm; int ret; + int ne = noerrs; queue_signals(); if ((ret = checkaddparam(pnam, (flags & FEAT_IGNORE)))) { @@ -1212,14 +1213,18 @@ add_autoparam(const char *module, const char *pnam, int flags) return ret == 2 ? 0 : -1; } - pm = setsparam(dupstring(pnam), ztrdup(module)); - - pm->node.flags |= PM_AUTOLOAD; - if (flags & FEAT_AUTOALL) - pm->node.flags |= PM_AUTOALL; + noerrs = 2; + if ((pm = setsparam(dupstring(pnam), ztrdup(module)))) { + pm->node.flags |= PM_AUTOLOAD; + if (flags & FEAT_AUTOALL) + pm->node.flags |= PM_AUTOALL; + ret = 0; + } else + ret = -1; + noerrs = ne; unqueue_signals(); - return 0; + return ret; } /* Remove a parameter added with add_autoparam() */ -- cgit v1.2.3 From 4929910267a00b8f9958d9e1710580e30d1d5a18 Mon Sep 17 00:00:00 2001 From: Jörg Sommer Date: Mon, 1 Jan 2024 19:10:20 +0100 Subject: 52444: module: Mark name argument of some functions const --- ChangeLog | 3 +++ Src/module.c | 15 ++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) (limited to 'Src/module.c') diff --git a/ChangeLog b/ChangeLog index 16e012d5b..8cdd990d6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2024-01-28 Oliver Kiddle + * Jörg Sommer: 52444: Src/module.c: Mark name argument of some + functions const + * Jörg Sommer: 52441: Src/Zle/zle_vi.c: Mark variables as const * Jörg Sommer: 52440: Src/Zle/textobjects.c: Mark variables as const diff --git a/Src/module.c b/Src/module.c index a6005f30b..b4b5d0a2c 100644 --- a/Src/module.c +++ b/Src/module.c @@ -356,7 +356,7 @@ finish_(UNUSED(Module m)) /**/ void -register_module(char *n, Module_void_func setup, +register_module(const char *n, Module_void_func setup, Module_features_func features, Module_enables_func enables, Module_void_func boot, @@ -846,7 +846,7 @@ Hookdef hooktab; /**/ Hookdef -gethookdef(char *n) +gethookdef(const char *n) { Hookdef p; @@ -974,7 +974,7 @@ deletehookdeffunc(Hookdef h, Hookfn f) /**/ mod_export int -deletehookfunc(char *n, Hookfn f) +deletehookfunc(const char *n, Hookfn f) { Hookdef h = gethookdef(n); @@ -1766,7 +1766,7 @@ dyn_finish_module(Module m) #else static Module_generic_func -module_func(Module m, char *name) +module_func(Module m, const char *name) { #ifdef DYNAMIC_NAME_CLASH_OK return (Module_generic_func) dlsym(m->u.handle, name); @@ -2443,7 +2443,7 @@ bin_zmodload(char *nam, char **args, Options ops, UNUSED(int func)) int ops_au = OPT_ISSET(ops,'a') || OPT_ISSET(ops,'u'); int ret = 1, autoopts; /* options only allowed with -F */ - char *fonly = "lP", *fp; + const char *fonly = "lP", *fp; if (ops_bcpf && !ops_au) { zwarnnam(nam, "-b, -c, -f, and -p must be combined with -a or -u"); @@ -3182,7 +3182,7 @@ bin_zmodload_features(const char *nam, char **args, Options ops) } else if (OPT_ISSET(ops, 'L')) printf("zmodload -F %s ", m->node.nam); for (fp = features, ep = enables; *fp; fp++, ep++) { - char *onoff; + const char *onoff; int term; if (*args) { char **argp; @@ -3452,7 +3452,8 @@ autofeatures(const char *cmdnam, const char *module, char **features, defm = NULL; for (; *features; features++) { - char *fnam, *typnam, *feature; + char *fnam, *feature; + const char *typnam; int add, fchar, flags = defflags; autofeaturefn_t fn; -- cgit v1.2.3