mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Fix various compiler warnings and minor issues (#362)
List of changes: - Fixed some -Wuninitialized warnings and removed some unused variables. - Removed the unused extern for B_login (re:d8eba9d1). - The libcmd builtins and the vmalloc memfatal function now handle memory errors with 'ERROR_SYSTEM|ERROR_PANIC' for consistency with how ksh itself handles out of memory errors. - Added usage of UNREACHABLE() where it was missing from error handling. - Extend many variables from short to int to prevent overflows (most variables involve file descriptors). - Backported a ksh2020 patch to fix unused value Coverity issues (https://github.com/att/ast/pull/740). - Note in src/cmd/ksh93/README that ksh compiles with Cygwin on Windows 10 and Windows 11, albeit with many test failures. - Add comments to detail some sections of code. Extensive list of commits related to this change:ca2443b5,7e7f1372,2db9953a,7003aba4,6f50ff64,b1a41311,222515bf,a0dcdeea,0aa9e03f,61437b27,352e68da,88e8fa67,bc8b36fa,6e515f1d,017d088c,035a4cb3,588a1ff7,6d63b57d,a2f13c19,794d1c86,ab98ec65,1026006d- Removed a lot of dead ifdef code. - edit/emacs.c: Hide an assignment to avoid a -Wunused warning. (See also https://github.com/att/ast/pull/753, which removed the assignment because ksh2020 removed the !SHOPT_MULTIBYTE code.) - sh/nvdisc.c: The sh_newof macro cannot return a null pointer because it will instead cause the shell to exit if memory cannot be allocated. That makes the if statement here a no-op, so remove it. - sh/xec.c: Fixed one unused variable warning in sh_funscope(). - sh/xec.c: Remove a fallthrough comment added in commited478ab7because the TFORK code doesn't fall through (GCC also produces no -Wimplicit-fallthrough warning here). - data/builtins.c: The cd and pwd man pages state that these builtins default to -P if PATH_RESOLVE is 'physical', which isn't accurate: $ /opt/ast/bin/getconf PATH_RESOLVE physical $ mkdir /tmp/dir; ln -s /tmp/dir /tmp/sym $ cd /tmp/sym $ pwd /tmp/sym $ cd -P /tmp/sym $ pwd /tmp/dir The behavior described by these man pages isn't specified in the ksh man page or by POSIX, so to avoid changing these builtin's behavior the inaccurate PATH_RESOLVE information has been removed. - Mamfiles: Preserve multi-line errors by quoting the $x variable. This fix was backported from 93v-. (See also <a7e9cc82>.) - sh/subshell.c: Remove set but not used sp->errcontext variable.
This commit is contained in:
parent
b3050769ea
commit
beccb93fd4
66 changed files with 148 additions and 265 deletions
|
|
@ -1063,16 +1063,6 @@ static char *setdisc_any(Namval_t *np, const char *event, Namval_t *action, Namf
|
|||
|
||||
static const Namdisc_t SH_MATH_disc = { 0, 0, get_math, 0, setdisc_any, create_math, };
|
||||
|
||||
#if SHOPT_NAMESPACE
|
||||
static char* get_nspace(Namval_t* np, Namfun_t *fp)
|
||||
{
|
||||
if(sh.namespace)
|
||||
return(nv_name(sh.namespace));
|
||||
return((char*)np->nvalue.cp);
|
||||
}
|
||||
static const Namdisc_t NSPACE_disc = { 0, 0, get_nspace };
|
||||
#endif /* SHOPT_NAMESPACE */
|
||||
|
||||
#ifdef _hdr_locale
|
||||
static const Namdisc_t LC_disc = { sizeof(Namfun_t), put_lang };
|
||||
#endif /* _hdr_locale */
|
||||
|
|
@ -1236,9 +1226,6 @@ Shell_t *sh_init(register int argc,register char *argv[], Shinit_f userinit)
|
|||
shgd->lim.clk_tck = getconf("CLK_TCK");
|
||||
shgd->lim.arg_max = getconf("ARG_MAX");
|
||||
shgd->lim.child_max = getconf("CHILD_MAX");
|
||||
shgd->lim.ngroups_max = getconf("NGROUPS_MAX");
|
||||
shgd->lim.posix_version = getconf("VERSION");
|
||||
shgd->lim.posix_jobcontrol = getconf("JOB_CONTROL");
|
||||
if(shgd->lim.arg_max <=0)
|
||||
shgd->lim.arg_max = ARG_MAX;
|
||||
if(shgd->lim.child_max <=0)
|
||||
|
|
@ -1310,7 +1297,7 @@ Shell_t *sh_init(register int argc,register char *argv[], Shinit_f userinit)
|
|||
sh_siginit(shp);
|
||||
stakinstall(NIL(Stak_t*),nomemory);
|
||||
/* set up memory for name-value pairs */
|
||||
shp->init_context = nv_init(shp);
|
||||
shp->init_context = nv_init(shp);
|
||||
/* initialize shell type */
|
||||
if(argc>0)
|
||||
{
|
||||
|
|
@ -1883,10 +1870,7 @@ Dt_t *sh_inittree(Shell_t *shp,const struct shtable2 *name_vals)
|
|||
n++;
|
||||
np = (Namval_t*)sh_calloc(n,sizeof(Namval_t));
|
||||
if(!shgd->bltin_nodes)
|
||||
{
|
||||
shgd->bltin_nodes = np;
|
||||
shgd->bltin_nnodes = n;
|
||||
}
|
||||
else if(name_vals==(const struct shtable2*)shtab_builtins)
|
||||
{
|
||||
shgd->bltin_cmds = np;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue