diff --git a/src/cmd/ksh93/bltins/print.c b/src/cmd/ksh93/bltins/print.c index 981ab642d..814f9fb8f 100644 --- a/src/cmd/ksh93/bltins/print.c +++ b/src/cmd/ksh93/bltins/print.c @@ -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': diff --git a/src/cmd/ksh93/bltins/sleep.c b/src/cmd/ksh93/bltins/sleep.c index aaf2f128b..4e128f9fb 100644 --- a/src/cmd/ksh93/bltins/sleep.c +++ b/src/cmd/ksh93/bltins/sleep.c @@ -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) diff --git a/src/cmd/ksh93/bltins/typeset.c b/src/cmd/ksh93/bltins/typeset.c index e93d75c49..5d2e08194 100644 --- a/src/cmd/ksh93/bltins/typeset.c +++ b/src/cmd/ksh93/bltins/typeset.c @@ -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': diff --git a/src/cmd/ksh93/edit/emacs.c b/src/cmd/ksh93/edit/emacs.c index e52be0fe0..aa6fcd315 100644 --- a/src/cmd/ksh93/edit/emacs.c +++ b/src/cmd/ksh93/edit/emacs.c @@ -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; } diff --git a/src/cmd/ksh93/edit/vi.c b/src/cmd/ksh93/edit/vi.c index bc0fa0d80..97bb5767c 100644 --- a/src/cmd/ksh93/edit/vi.c +++ b/src/cmd/ksh93/edit/vi.c @@ -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 */ /* diff --git a/src/cmd/ksh93/features/math.sh b/src/cmd/ksh93/features/math.sh index e2913d4f7..3bf554557 100644 --- a/src/cmd/ksh93/features/math.sh +++ b/src/cmd/ksh93/features/math.sh @@ -122,6 +122,7 @@ eval `iffe $iffeflags -c "$cc" - num $nums $iffehdrs $iffelibs 2>&$stderr` cat < #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 diff --git a/src/cmd/ksh93/sh/expand.c b/src/cmd/ksh93/sh/expand.c index 145306b29..39f81e0dc 100644 --- a/src/cmd/ksh93/sh/expand.c +++ b/src/cmd/ksh93/sh/expand.c @@ -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*); diff --git a/src/cmd/ksh93/sh/init.c b/src/cmd/ksh93/sh/init.c index 755da47ec..d1f4383f8 100644 --- a/src/cmd/ksh93/sh/init.c +++ b/src/cmd/ksh93/sh/init.c @@ -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 diff --git a/src/cmd/ksh93/sh/io.c b/src/cmd/ksh93/sh/io.c index 0665df7d8..583c3fb6d 100644 --- a/src/cmd/ksh93/sh/io.c +++ b/src/cmd/ksh93/sh/io.c @@ -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; diff --git a/src/cmd/ksh93/sh/jobs.c b/src/cmd/ksh93/sh/jobs.c index 49bebd5f3..6e72ae634 100644 --- a/src/cmd/ksh93/sh/jobs.c +++ b/src/cmd/ksh93/sh/jobs.c @@ -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); diff --git a/src/cmd/ksh93/sh/nvdisc.c b/src/cmd/ksh93/sh/nvdisc.c index 7db4a17fb..19be0dfdf 100644 --- a/src/cmd/ksh93/sh/nvdisc.c +++ b/src/cmd/ksh93/sh/nvdisc.c @@ -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)) diff --git a/src/cmd/ksh93/sh/xec.c b/src/cmd/ksh93/sh/xec.c index 6e7c7781a..ac23276fa 100644 --- a/src/cmd/ksh93/sh/xec.c +++ b/src/cmd/ksh93/sh/xec.c @@ -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 diff --git a/src/lib/libast/cdt/dtlist.c b/src/lib/libast/cdt/dtlist.c index 44ce73df9..6da88f3ae 100644 --- a/src/lib/libast/cdt/dtlist.c +++ b/src/lib/libast/cdt/dtlist.c @@ -203,7 +203,7 @@ int type; goto do_insert; } else if(type&(DT_INSERT|DT_INSTALL|DT_APPEND|DT_ATTACH)) - { dt_insert: + { if(!(r = _dtmake(dt, obj, type)) ) DTRETURN(obj, NIL(Void_t*)); dt->data->size += 1; diff --git a/src/lib/libast/comp/conf.sh b/src/lib/libast/comp/conf.sh index 9d0841154..f4dd68fa7 100644 --- a/src/lib/libast/comp/conf.sh +++ b/src/lib/libast/comp/conf.sh @@ -1195,7 +1195,7 @@ printf("#endif\n"); *:U*) cat >> $tmp.l <> $tmp.l < * * * ***********************************************************************/ +#pragma clang diagnostic ignored "-Wincompatible-library-redeclaration" /* * strtoll() implementation */ diff --git a/src/lib/libast/comp/strtoull.c b/src/lib/libast/comp/strtoull.c index 2837cc64c..21c695ae3 100644 --- a/src/lib/libast/comp/strtoull.c +++ b/src/lib/libast/comp/strtoull.c @@ -19,6 +19,7 @@ * Phong Vo * * * ***********************************************************************/ +#pragma clang diagnostic ignored "-Wincompatible-library-redeclaration" /* * strtoull() implementation */ diff --git a/src/lib/libast/features/signal.c b/src/lib/libast/features/signal.c index 9f0baa445..8506d84b1 100644 --- a/src/lib/libast/features/signal.c +++ b/src/lib/libast/features/signal.c @@ -20,6 +20,7 @@ * * ***********************************************************************/ #pragma prototyped +#pragma clang diagnostic ignored "-Wparentheses" /* * Glenn Fowler * AT&T Research diff --git a/src/lib/libast/include/ast.h b/src/lib/libast/include/ast.h index 5e4379798..d41015b86 100644 --- a/src/lib/libast/include/ast.h +++ b/src/lib/libast/include/ast.h @@ -20,9 +20,8 @@ * * ***********************************************************************/ #pragma prototyped -#pragma clang diagnostic ignored "-Wmacro-redefined" #pragma clang diagnostic ignored "-Wparentheses" -#pragma clang diagnostic ignored "-Wunused-value" +#pragma clang diagnostic ignored "-Wstring-plus-int" /* * Advanced Software Technology Library diff --git a/src/lib/libast/misc/magic.c b/src/lib/libast/misc/magic.c index 8ecdc13ed..a84fc507f 100644 --- a/src/lib/libast/misc/magic.c +++ b/src/lib/libast/misc/magic.c @@ -1183,24 +1183,24 @@ cklang(register Magic_t* mp, const char* file, char* buf, char* end, struct stat mp->multi['X']++; break; } - if (!mp->idtab) - { - if (mp->idtab = dtnew(mp->vm, &mp->dtdisc, Dtset)) - for (q = 0; q < elementsof(dict); q++) - dtinsert(mp->idtab, &dict[q]); - else if (mp->disc->errorf) - (*mp->disc->errorf)(mp, mp->disc, 3, "out of space"); - q = 0; - } - if (mp->idtab) - { - *(b - 1) = 0; - if (ip = (Info_t*)dtmatch(mp->idtab, s)) - mp->identifier[ip->value]++; - *(b - 1) = c; - } - s = 0; + if (!mp->idtab) + { + if (mp->idtab = dtnew(mp->vm, &mp->dtdisc, Dtset)) + for (q = 0; q < elementsof(dict); q++) + dtinsert(mp->idtab, &dict[q]); + else if (mp->disc->errorf) + (*mp->disc->errorf)(mp, mp->disc, 3, "out of space"); + q = 0; } + if (mp->idtab) + { + *(b - 1) = 0; + if (ip = (Info_t*)dtmatch(mp->idtab, s)) + mp->identifier[ip->value]++; + *(b - 1) = c; + } + s = 0; + } switch (c) { case '\t': diff --git a/src/lib/libast/misc/optget.c b/src/lib/libast/misc/optget.c index 5148947cb..009e3b51c 100644 --- a/src/lib/libast/misc/optget.c +++ b/src/lib/libast/misc/optget.c @@ -297,20 +297,6 @@ static const Attr_t attrs[] = static const char unknown[] = C("unknown option or attribute"); -static const char* heading[] = -{ - C("INDEX"), - C("USER COMMANDS"), - C("SYSTEM LIBRARY"), - C("USER LIBRARY"), - C("FILE FORMATS"), - C("MISCELLANEOUS"), - C("GAMES and DEMOS"), - C("SPECIAL FILES"), - C("ADMINISTRATIVE COMMANDS"), - C("GUIs"), -}; - /* * list of common man page strings * NOTE: add but do not delete from this table diff --git a/src/lib/libast/port/lcgen.c b/src/lib/libast/port/lcgen.c index 82eb88d00..fddb024b3 100644 --- a/src/lib/libast/port/lcgen.c +++ b/src/lib/libast/port/lcgen.c @@ -19,6 +19,7 @@ * Phong Vo * * * ***********************************************************************/ +#pragma clang diagnostic ignored "-Wparentheses" /* * generate implementation tables from lc.tab * this must make it through vanilla cc with no -last diff --git a/src/lib/libast/regex/regsubexec.c b/src/lib/libast/regex/regsubexec.c index faf62daad..d336906c5 100644 --- a/src/lib/libast/regex/regsubexec.c +++ b/src/lib/libast/regex/regsubexec.c @@ -219,11 +219,11 @@ regsubexec(const regex_t* p, const char* s, size_t nmatch, oldregmatch_t* oldmat if (!(match = oldof(0, regmatch_t, nmatch, 0))) return -1; - for (i = 0; i < nmatch; i++) - { - match[i].rm_so = oldmatch[i].rm_so; - match[i].rm_eo = oldmatch[i].rm_eo; - } + for (i = 0; i < nmatch; i++) + { + match[i].rm_so = oldmatch[i].rm_so; + match[i].rm_eo = oldmatch[i].rm_eo; + } if (!(r = regsubexec_20120528(p, s, nmatch, match))) for (i = 0; i < nmatch; i++) { diff --git a/src/lib/libast/sfio/sfpool.c b/src/lib/libast/sfio/sfpool.c index 2efb5710f..849fc5336 100644 --- a/src/lib/libast/sfio/sfpool.c +++ b/src/lib/libast/sfio/sfpool.c @@ -288,7 +288,8 @@ reg int mode; /* f already in the same pool with pf */ if(f == pf || (pf && f->pool == pf->pool && f->pool != &_Sfpool) ) - { if(f) + { + if(f) SFMTXUNLOCK(f); if(pf) SFMTXUNLOCK(pf); diff --git a/src/lib/libast/tm/tmxdate.c b/src/lib/libast/tm/tmxdate.c index a729b81b5..af7a5bb4b 100644 --- a/src/lib/libast/tm/tmxdate.c +++ b/src/lib/libast/tm/tmxdate.c @@ -836,7 +836,8 @@ tmxdate(register const char* s, char** e, Time_t now) } else { - for (u = t; isspace(*u); u++); + for (u = t; isspace(*u); u++) + ; message((-1, "AHA#%d n=%d u=\"%s\"", __LINE__, n, u)); if ((j = tmlex(u, NiL, tm_info.format, TM_NFORM, tm_info.format + TM_SUFFIXES, TM_PARTS - TM_SUFFIXES)) >= 0 && tm_data.lex[j] == TM_PARTS) s = u; @@ -978,7 +979,8 @@ tmxdate(register const char* s, char** e, Time_t now) } continue; } - for (s = t; skip[*s]; s++); + for (s = t; skip[*s]; s++) + ; message((-1, "AHA#%d s=\"%s\"", __LINE__, s)); if (*s == ':' || *s == '.' && ((set|state) & (YEAR|MONTH|DAY|HOUR)) == (YEAR|MONTH|DAY)) { diff --git a/src/lib/libast/vmalloc/vmbest.c b/src/lib/libast/vmalloc/vmbest.c index b689af643..2cb09ebfc 100644 --- a/src/lib/libast/vmalloc/vmbest.c +++ b/src/lib/libast/vmalloc/vmbest.c @@ -883,7 +883,8 @@ int local; CLRBITS(s); } else if(ISJUNK(s) ) - { if(!bestreclaim(vd,np,(int)C_INDEX(s)) ) + { + if(!bestreclaim(vd,np,(int)C_INDEX(s)) ) /**/ASSERT(0); /* oops: did not see np! */ s = SIZE(np); /**/ASSERT(s%ALIGN == 0); } diff --git a/src/lib/libast/vmalloc/vmmopen.c b/src/lib/libast/vmalloc/vmmopen.c index fdf8c1b3e..f1c5c60c0 100644 --- a/src/lib/libast/vmalloc/vmmopen.c +++ b/src/lib/libast/vmalloc/vmmopen.c @@ -354,7 +354,6 @@ Vmdisc_t* disc; #endif { int rv; - Void_t *base; Mmdisc_t *mmdc = (Mmdisc_t*)disc; if(type == VM_OPEN)