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
|
@ -679,7 +679,6 @@ static const char *mapformat(Sffmt_t *fe)
|
|||
static int extend(Sfio_t* sp, void* v, Sffmt_t* fe)
|
||||
{
|
||||
char* lastchar = "";
|
||||
register int neg = 0;
|
||||
Sfdouble_t d;
|
||||
Sfdouble_t longmin = LDBL_LLONG_MIN;
|
||||
Sfdouble_t longmax = LDBL_LLONG_MAX;
|
||||
|
@ -884,8 +883,6 @@ static int extend(Sfio_t* sp, void* v, Sffmt_t* fe)
|
|||
}
|
||||
break;
|
||||
}
|
||||
if(neg)
|
||||
value->ll = -value->ll;
|
||||
fe->size = sizeof(value->ll);
|
||||
break;
|
||||
case 'a':
|
||||
|
|
|
@ -73,6 +73,7 @@ int b_sleep(register int argc,char *argv[],Shbltin_t *context)
|
|||
Time_t now,ns;
|
||||
char* pp;
|
||||
now = TMX_NOW;
|
||||
ns = 0;
|
||||
if(*cp == 'P' || *cp == 'p')
|
||||
ns = tmxdate(cp, &last, now);
|
||||
else if(*last=='.' && shp->decomma && d==(unsigned long)d)
|
||||
|
|
|
@ -72,12 +72,6 @@ static int setall(char**, int, Dt_t*, struct tdata*);
|
|||
static void pushname(Namval_t*,void*);
|
||||
static void(*nullscan)(Namval_t*,void*);
|
||||
|
||||
static Namval_t *load_class(const char *name)
|
||||
{
|
||||
errormsg(SH_DICT,ERROR_exit(1),"%s: type not loadable",name);
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Note export and readonly are the same
|
||||
*/
|
||||
|
@ -131,7 +125,6 @@ int b_alias(int argc,register char *argv[],Shbltin_t *context)
|
|||
register Dt_t *troot;
|
||||
register int rflag=0, n;
|
||||
struct tdata tdata;
|
||||
Namval_t *np;
|
||||
NOT_USED(argc);
|
||||
memset((void*)&tdata,0,sizeof(tdata));
|
||||
tdata.sh = context->shp;
|
||||
|
@ -275,8 +268,8 @@ int b_typeset(int argc,register char *argv[],Shbltin_t *context)
|
|||
flag |= NV_HEXFLOAT;
|
||||
}
|
||||
else
|
||||
/* n=='F' Remove possible collision with NV_UNSIGN/NV_HEXFLOAT */
|
||||
flag &= ~NV_HEXFLOAT;
|
||||
/* n=='F' Remove possible collision with NV_UNSIGN/NV_HEXFLOAT */
|
||||
flag &= ~NV_HEXFLOAT;
|
||||
break;
|
||||
case 'b':
|
||||
flag |= NV_BINARY;
|
||||
|
@ -366,10 +359,10 @@ int b_typeset(int argc,register char *argv[],Shbltin_t *context)
|
|||
flag |= NV_TAGGED;
|
||||
break;
|
||||
case 'u':
|
||||
if(!isfloat)
|
||||
{
|
||||
tdata.wctname = e_toupper;
|
||||
flag |= NV_LTOU;
|
||||
if(!isfloat)
|
||||
{
|
||||
tdata.wctname = e_toupper;
|
||||
flag |= NV_LTOU;
|
||||
}
|
||||
break;
|
||||
case 'x':
|
||||
|
|
|
@ -1344,7 +1344,7 @@ static void search(Emacs_t* ep,genchar *out,int direction)
|
|||
#if SHOPT_MULTIBYTE
|
||||
ed_external(string,(char*)string);
|
||||
#endif /* SHOPT_MULTIBYTE */
|
||||
strncpy(lstring,((char*)string)+2,SEARCHSIZE);
|
||||
strncpy(lstring,((char*)string)+2,SEARCHSIZE-1);
|
||||
lstring[SEARCHSIZE-1] = 0;
|
||||
ep->prevdirection = direction;
|
||||
}
|
||||
|
|
|
@ -67,12 +67,10 @@
|
|||
# define iswprint(c) ((c&~0177) || isprint(c))
|
||||
# endif
|
||||
static int _isalph(int);
|
||||
static int _ismetach(int);
|
||||
static int _isblank(int);
|
||||
# undef isblank
|
||||
# define isblank(v) _isblank(virtual[v])
|
||||
# define isalph(v) _isalph(virtual[v])
|
||||
# define ismetach(v) _ismetach(virtual[v])
|
||||
#else
|
||||
static genchar _c;
|
||||
# define gencpy(a,b) strcpy((char*)(a),(char*)(b))
|
||||
|
@ -81,7 +79,6 @@
|
|||
# define isalph(v) ((_c=virtual[v])=='_'||isalnum(_c))
|
||||
# undef isblank
|
||||
# define isblank(v) isspace(virtual[v])
|
||||
# define ismetach(v) ismeta(virtual[v])
|
||||
# define digit(c) isdigit(c)
|
||||
# define is_print(c) isprint(c)
|
||||
#endif /* SHOPT_MULTIBYTE */
|
||||
|
@ -2098,6 +2095,7 @@ static void refresh(register Vi_t* vp, int mode)
|
|||
cursor(vp,ncur_phys);
|
||||
ed_flush(vp->ed);
|
||||
return;
|
||||
# undef w
|
||||
}
|
||||
|
||||
/*{ REPLACE( char, increment )
|
||||
|
@ -2323,7 +2321,7 @@ static int search(register Vi_t* vp,register int mode)
|
|||
location = hist_find(shgd->hist_ptr,((char*)virtual)+1, curhline, 1, new_direction);
|
||||
}
|
||||
cur_virt = i;
|
||||
strncpy(lsearch, ((char*)virtual)+1, SEARCHSIZE);
|
||||
strncpy(lsearch, ((char*)virtual)+1, SEARCHSIZE-1);
|
||||
lsearch[SEARCHSIZE-1] = 0;
|
||||
if( (curhline=location.hist_command) >=0 )
|
||||
{
|
||||
|
@ -2785,12 +2783,6 @@ yankeol:
|
|||
{
|
||||
return((v&~STRIP)==0 && isspace(v));
|
||||
}
|
||||
|
||||
static int _ismetach(register int v)
|
||||
{
|
||||
return((v&~STRIP)==0 && ismeta(v));
|
||||
}
|
||||
|
||||
#endif /* SHOPT_MULTIBYTE */
|
||||
|
||||
/*
|
||||
|
|
|
@ -122,6 +122,7 @@ eval `iffe $iffeflags -c "$cc" - num $nums $iffehdrs $iffelibs 2>&$stderr`
|
|||
|
||||
cat <<!
|
||||
#pragma prototyped
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
|
||||
/* : : generated by $command from $table : : */
|
||||
|
||||
|
|
|
@ -37,8 +37,17 @@
|
|||
# include <nval.h>
|
||||
#endif /* _SH_PRIVATE */
|
||||
|
||||
/*
|
||||
* This is a macro that can be used to silence "unused parameter" warnings from the compiler for
|
||||
* functions which need to accept parameters they do not use because they need to be compatible
|
||||
* with an interface.
|
||||
*/
|
||||
#undef NOT_USED
|
||||
#define NOT_USED(x) (&x,1)
|
||||
#define NOT_USED(expr) \
|
||||
do { \
|
||||
(void)(expr); \
|
||||
} while (0)
|
||||
|
||||
|
||||
/* options */
|
||||
typedef struct
|
||||
|
|
|
@ -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