mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Fix many compiler warnings and remove unused variables (#191)
Most of these changes remove unused variables, functions and labels
to fix -Wunused compiler warnings. Somewhat notable changes:
src/cmd/ksh93/bltins/print.c:
- Removed the unused 'neg' variable.
Patch from ksh2020: https://github.com/att/ast/pull/725
src/cmd/ksh93/bltins/sleep.c:
- Initialized ns to fix three -Wsometimes-uninitialized warnings.
src/cmd/ksh93/edit/{emacs,vi}.c:
- Adjust strncpy size to fix two -Wstringop-truncation warnings.
src/cmd/ksh93/include/shell.h:
- The NOT_USED macro caused many -Wunused-value warnings,
so it has been replaced with ksh2020's macro:
19d0620a
src/cmd/ksh93/sh/expand.c:
- Removed an unnecessary 'ap = ' since 'ap' is never read
between stakseek and stakfreeze.
src/cmd/ksh93/edit/vi.c: refresh():
- Undef this function's 'w' macro at the end of it to stop it
potentially interfering with future code changes.
src/cmd/ksh93/sh/nvdisc.c,
src/lib/libast/misc/magic.c,
src/lib/libast/regex/regsubexec.c,
src/lib/libast/sfio/sfpool.c,
src/lib/libast/vmalloc/vmbest.c:
- Fixed some indentation to silence -Wmisleading-indentation
warnings.
src/lib/libast/include/ast.h:
- For clang, now only suppress hundreds of -Wparentheses warnings
as well as a few -Wstring-plus-int warnings.
Clang's -Wparentheses warns about things like
if(foo = bar())
which assigns to foo and checks the assigned value.
Clang wants us to change this into
if((foo = bar()))
Clang's -Wstring-plus-int warns about things like
"string"+x
where x is an integer, e.g. "string"+3 represents the string
"ing". Clang wants us to change that to
"string"[3]
The original versions represent a perfectly valid coding style
that was common in the 1980s and 1990s and is not going to change
in this historic code base. (gcc does not complain about these.)
Co-authored-by: Martijn Dekker <martijn@inlv.org>
This commit is contained in:
parent
83630f9d1c
commit
733f70e94b
27 changed files with 64 additions and 113 deletions
|
|
@ -65,11 +65,6 @@
|
|||
# define GLOB_AUGMENTED 0
|
||||
#endif
|
||||
|
||||
#define GLOB_RESCAN 1
|
||||
#define globptr() ((struct glob*)membase)
|
||||
|
||||
static struct glob *membase;
|
||||
|
||||
static char *nextdir(glob_t *gp, char *dir)
|
||||
{
|
||||
Shell_t *shp = sh_getinterp();
|
||||
|
|
@ -143,7 +138,7 @@ static int scantree(Dt_t *tree, const char *pattern, struct argnod **arghead)
|
|||
{
|
||||
if(strmatch(cp=nv_name(np),pattern))
|
||||
{
|
||||
ap = (struct argnod*)stakseek(ARGVAL);
|
||||
(void)stakseek(ARGVAL);
|
||||
stakputs(cp);
|
||||
ap = (struct argnod*)stakfreeze(1);
|
||||
ap->argbegin = NIL(char*);
|
||||
|
|
|
|||
|
|
@ -383,16 +383,6 @@ static void put_cdpath(register Namval_t* np,const char *val,int flags,Namfun_t
|
|||
}
|
||||
|
||||
#ifdef _hdr_locale
|
||||
/*
|
||||
* This function needs to be modified to handle international
|
||||
* error message translations
|
||||
*/
|
||||
static char* msg_translate(const char* catalog, const char* message)
|
||||
{
|
||||
NOT_USED(catalog);
|
||||
return((char*)message);
|
||||
}
|
||||
|
||||
/* Trap for LC_ALL, LC_CTYPE, LC_MESSAGES, LC_COLLATE and LANG */
|
||||
static void put_lang(Namval_t* np,const char *val,int flags,Namfun_t *fp)
|
||||
{
|
||||
|
|
@ -731,13 +721,6 @@ static void put_lastarg(Namval_t* np,const char *val,int flags,Namfun_t *fp)
|
|||
np->nvenv = 0;
|
||||
}
|
||||
|
||||
static int hasgetdisc(register Namfun_t *fp)
|
||||
{
|
||||
while(fp && !fp->disc->getnum && !fp->disc->getval)
|
||||
fp = fp->next;
|
||||
return(fp!=0);
|
||||
}
|
||||
|
||||
/*
|
||||
* store the most recent value for use in .sh.match
|
||||
* treat .sh.match as a two dimensional array
|
||||
|
|
@ -1034,7 +1017,6 @@ static const Namdisc_t SH_MATH_disc = { 0, 0, get_math, 0, setdisc_any, create_
|
|||
return((char*)np->nvalue.cp);
|
||||
}
|
||||
static const Namdisc_t NSPACE_disc = { 0, 0, get_nspace };
|
||||
static Namfun_t NSPACE_init = { &NSPACE_disc, 1};
|
||||
#endif /* SHOPT_NAMESPACE */
|
||||
|
||||
#ifdef _hdr_locale
|
||||
|
|
|
|||
|
|
@ -387,14 +387,6 @@ struct Match
|
|||
char *base;
|
||||
};
|
||||
|
||||
static int matchf(void *handle, char *ptr, size_t size)
|
||||
{
|
||||
struct Match *mp = (struct Match*)handle;
|
||||
mp->offset += (ptr-mp->base);
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
static struct fdsave *filemap;
|
||||
static short filemapsize;
|
||||
|
||||
|
|
|
|||
|
|
@ -1092,8 +1092,6 @@ int job_kill(register struct process *pw,register int sig)
|
|||
int job_hup(struct process *pw, int sig)
|
||||
{
|
||||
struct process *px;
|
||||
pid_t pid;
|
||||
int r;
|
||||
NOT_USED(sig);
|
||||
if(pw->p_pgrp == 0 || (pw->p_flag & P_DISOWN))
|
||||
return(0);
|
||||
|
|
|
|||
|
|
@ -947,11 +947,11 @@ int nv_clone(Namval_t *np, Namval_t *mp, int flags)
|
|||
if(flags&NV_APPEND)
|
||||
return(1);
|
||||
if(mp->nvsize == size)
|
||||
nv_setsize(mp,nv_size(np));
|
||||
nv_setsize(mp,nv_size(np));
|
||||
if(mp->nvflag == flag)
|
||||
mp->nvflag = (np->nvflag&~(NV_MINIMAL))|(mp->nvflag&NV_MINIMAL);
|
||||
if(nv_isattr(np,NV_EXPORT))
|
||||
mp->nvflag |= (np->nvflag&NV_MINIMAL);
|
||||
mp->nvflag = (np->nvflag&~(NV_MINIMAL))|(mp->nvflag&NV_MINIMAL);
|
||||
if(nv_isattr(np,NV_EXPORT))
|
||||
mp->nvflag |= (np->nvflag&NV_MINIMAL);
|
||||
if(mp->nvalue.cp==val && !nv_isattr(np,NV_INTEGER))
|
||||
{
|
||||
if(np->nvalue.cp && np->nvalue.cp!=Empty && (flags&NV_COMVAR) && !(flags&NV_MOVE))
|
||||
|
|
|
|||
|
|
@ -70,7 +70,6 @@ static void coproc_init(Shell_t*, int pipes[]);
|
|||
static void *timeout;
|
||||
static char nlock;
|
||||
static char pipejob;
|
||||
static char nopost;
|
||||
static int restorefd;
|
||||
|
||||
struct funenv
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue