diff --git a/src/cmd/builtin/pty.c b/src/cmd/builtin/pty.c index ad932a3747fe..b3f31ade07f9 100644 --- a/src/cmd/builtin/pty.c +++ b/src/cmd/builtin/pty.c @@ -512,7 +512,7 @@ masterline(Sfio_t* mp, Sfio_t* lp, char* prompt, int must, int timeout, Master_t char* t; ssize_t n; ssize_t a; - size_t promptlen; + size_t promptlen = 0; ptrdiff_t d; char promptbuf[64]; @@ -782,6 +782,8 @@ dialogue(Sfio_t* mp, Sfio_t* lp, int delay, int timeout) !(master->buf = vmnewof(vm, 0, char, 2 * SF_BUFSIZE, 0))) { error(ERROR_SYSTEM|2, "out of space"); + id = 0; + line = 0; goto done; } master->vm = vm; diff --git a/src/cmd/ksh93/edit/edit.c b/src/cmd/ksh93/edit/edit.c index ec9725b59f97..04d710b19ae4 100644 --- a/src/cmd/ksh93/edit/edit.c +++ b/src/cmd/ksh93/edit/edit.c @@ -1406,12 +1406,12 @@ int ed_internal(const char *src, genchar *dest) int ed_external(const genchar *src, char *dest) { register genchar wc; - register int c,size; register char *dp = dest; char *dpmax = dp+sizeof(genchar)*MAXLINE-2; if((char*)src == dp) { - char buffer[MAXLINE*sizeof(genchar)]; + int c; + char buffer[MAXLINE*sizeof(genchar)] = ""; c = ed_external(src,buffer); #ifdef _lib_wcscpy @@ -1423,6 +1423,7 @@ int ed_external(const genchar *src, char *dest) } while((wc = *src++) && dpsh_name;tp++) n++; np = (Namval_t*)calloc(n,sizeof(Namval_t)); diff --git a/src/cmd/ksh93/sh/macro.c b/src/cmd/ksh93/sh/macro.c index 9f051befa5e9..5a740b4f0f3f 100644 --- a/src/cmd/ksh93/sh/macro.c +++ b/src/cmd/ksh93/sh/macro.c @@ -1803,7 +1803,7 @@ static int varsub(Mac_t *mp) int ofs_size = 0; regoff_t match[2*(MATCH_MAX+1)]; int nmatch, nmatch_prev, vsize_last; - char *vlast; + char *vlast = NIL(char*); while(1) { if(!v) diff --git a/src/cmd/ksh93/sh/name.c b/src/cmd/ksh93/sh/name.c index 1b77537003b4..5ebf6abbed1d 100644 --- a/src/cmd/ksh93/sh/name.c +++ b/src/cmd/ksh93/sh/name.c @@ -1305,7 +1305,7 @@ Namval_t *nv_open(const char *name, Dt_t *root, int flags) const char *msg = e_varname; char *fname = 0; int offset = staktell(); - Dt_t *funroot; + Dt_t *funroot = NIL(Dt_t*); #if NVCACHE struct Cache_entry *xp; #endif @@ -1779,7 +1779,7 @@ void nv_putval(register Namval_t *np, const char *string, int flags) else { const char *tofree=0; - int offset,append; + int offset=0,append; #if _lib_pathnative char buff[PATH_MAX]; #endif /* _lib_pathnative */ diff --git a/src/cmd/ksh93/sh/nvdisc.c b/src/cmd/ksh93/sh/nvdisc.c index 70e65e2d0a7e..8de284f785e3 100644 --- a/src/cmd/ksh93/sh/nvdisc.c +++ b/src/cmd/ksh93/sh/nvdisc.c @@ -453,7 +453,7 @@ static Sfdouble_t lookupn(Namval_t *np, Namfun_t *handle) char *nv_setdisc(register Namval_t* np,register const char *event,Namval_t *action,register Namfun_t *fp) { register struct vardisc *vp = (struct vardisc*)np->nvfun; - register int type; + register int type = -1; char *empty = ""; while(vp) { @@ -509,6 +509,8 @@ char *nv_setdisc(register Namval_t* np,register const char *event,Namval_t *acti } return(NIL(char*)); } + if (type < 0) + return(NIL(char*)); /* Handle GET/SET/APPEND/UNSET disc */ if(vp && vp->fun.disc->putval!=assign) vp = 0; diff --git a/src/cmd/ksh93/sh/nvtree.c b/src/cmd/ksh93/sh/nvtree.c index dcfc9add68b3..4e5c375b6cf4 100644 --- a/src/cmd/ksh93/sh/nvtree.c +++ b/src/cmd/ksh93/sh/nvtree.c @@ -557,7 +557,7 @@ void nv_outnode(Namval_t *np, Sfio_t* out, int indent, int special) char *fmtq,*ep,*xp; Namval_t *mp; Namarr_t *ap = nv_arrayptr(np); - int scan,tabs=0,c,more,associative = 0; + int scan=0,tabs=0,c,more,associative = 0; int saveI = Indent; Indent = indent; if(ap) @@ -670,7 +670,7 @@ void nv_outnode(Namval_t *np, Sfio_t* out, int indent, int special) static void outval(char *name, const char *vname, struct Walk *wp) { - register Namval_t *np, *nq, *last_table=wp->shp->last_table; + register Namval_t *np, *nq=0, *last_table=wp->shp->last_table; register Namfun_t *fp; int isarray=0, special=0,mode=0; if(*name!='.' || vname[strlen(vname)-1]==']') diff --git a/src/cmd/ksh93/sh/nvtype.c b/src/cmd/ksh93/sh/nvtype.c index 040730c7f7dd..61cc371bc99c 100644 --- a/src/cmd/ksh93/sh/nvtype.c +++ b/src/cmd/ksh93/sh/nvtype.c @@ -826,9 +826,10 @@ void nv_newtype(Namval_t *mp) Namval_t *nv_mktype(Namval_t **nodes, int numnodes) { Namval_t *mp=nodes[0], *bp=0, *np, *nq, **mnodes=nodes; - int i,j,k,m,n,nd=0,nref=0,iref=0,inherit=0; + int i,j,k,nd=0,nref=0,iref=0,inherit=0; int size=sizeof(NV_DATA), dsize=0, nnodes; - size_t offset=0; + size_t offset=0,m; + ssize_t n; char *name=0, *cp, *sp, **help; Namtype_t *pp,*qp=0,*dp,*tp; Dt_t *root = nv_dict(mp); @@ -841,6 +842,7 @@ Namval_t *nv_mktype(Namval_t **nodes, int numnodes) _nv_unset(nodes[0],NV_RDONLY); errormsg(SH_DICT,ERROR_exit(1),e_badtypedef,cp); } + n=strlen(nodes[1]->nvname); for(nnodes=1,i=1; i funct.functargs = ac = (struct comnod*)simple(lexp,SH_NOIO|SH_FUNDEF,NIL(struct ionod*)); if(ac->comset || (ac->comtyp&COMSCAN)) errormsg(SH_DICT,ERROR_exit(3),e_lexsyntax4,lexp->sh->inlineno); diff --git a/src/cmd/ksh93/sh/xec.c b/src/cmd/ksh93/sh/xec.c index d460a9fa03a5..23526098ec20 100644 --- a/src/cmd/ksh93/sh/xec.c +++ b/src/cmd/ksh93/sh/xec.c @@ -1426,7 +1426,7 @@ int sh_exec(register const Shnode_t *t, int flags) Namval_t node; #endif /* SHOPT_NAMESPACE */ struct Namref nr; - long mode; + long mode = 0; register struct slnod *slp; if(!np->nvalue.ip) { @@ -1771,8 +1771,8 @@ int sh_exec(register const Shnode_t *t, int flags) * don't create a new process, just * save and restore io-streams */ - pid_t pid; - int jmpval, waitall; + pid_t pid = 0; + int jmpval, waitall = 0; int simple = (t->fork.forktre->tre.tretyp&COMMSK)==TCOM; struct checkpt *buffp = (struct checkpt*)stkalloc(shp->stk,sizeof(struct checkpt)); if(shp->subshell) @@ -2162,7 +2162,7 @@ int sh_exec(register const Shnode_t *t, int flags) Shnode_t *tt = t->wh.whtre; #if SHOPT_FILESCAN Sfio_t *iop=0; - int savein; + int savein=-1; #endif /*SHOPT_FILESCAN*/ #if SHOPT_OPTIMIZE int jmpval = ((struct checkpt*)shp->jmplist)->mode; @@ -2579,7 +2579,7 @@ int sh_exec(register const Shnode_t *t, int flags) else { register int traceon=0; - register char *right; + register char *right = 0; register char *trap; char *argv[6]; n = type>>TSHIFT; @@ -2613,7 +2613,7 @@ int sh_exec(register const Shnode_t *t, int flags) } else if(type&TBINARY) { - char *op; + char *op = 0; int pattern = 0; if(trap || traceon) op = (char*)(shtab_testops+(n&037)-1)->sh_name; @@ -3277,11 +3277,11 @@ static void sh_funct(Shell_t *shp,Namval_t *np,int argn, char *argv[],struct arg int sh_fun(Namval_t *np, Namval_t *nq, char *argv[]) { Shell_t *shp = sh_getinterp(); - register int offset; + register int offset = 0; register char *base; Namval_t node; struct Namref nr; - long mode; + long mode = 0; char *prefix = shp->prefix; int n=0; char *av[3]; diff --git a/src/lib/libast/sfio/sfstrtof.h b/src/lib/libast/sfio/sfstrtof.h index 4b2f40076079..4d41e79d31b1 100644 --- a/src/lib/libast/sfio/sfstrtof.h +++ b/src/lib/libast/sfio/sfstrtof.h @@ -211,8 +211,8 @@ S2F_function(str, end) char* str; char** end; int decimal = 0; int thousand = 0; int part = 0; - int back_part; - S2F_batch back_n; + int back_part = 0; + S2F_batch back_n = 0; S2F_number v; S2F_number p; S2F_part_t parts[16]; diff --git a/src/lib/libast/sfio/sftable.c b/src/lib/libast/sfio/sftable.c index 9c0de46e6896..b7395d776b4a 100644 --- a/src/lib/libast/sfio/sftable.c +++ b/src/lib/libast/sfio/sftable.c @@ -53,7 +53,7 @@ int type; /* >0: scanf, =0: printf, -1: internal */ #endif { int base, fmt, flags, dot, width, precis; - ssize_t n_str, size; + ssize_t n_str, size = 0; char *t_str, *sp; int v, n, skip, dollar, decimal, thousand; Sffmt_t savft; diff --git a/src/lib/libast/sfio/sfvprintf.c b/src/lib/libast/sfio/sfvprintf.c index 90014f24c52c..227fd0f350e9 100644 --- a/src/lib/libast/sfio/sfvprintf.c +++ b/src/lib/libast/sfio/sfvprintf.c @@ -101,7 +101,7 @@ char* form; /* format to use */ va_list args; /* arg list if !argf */ #endif { - int n, v, w, k, n_s, base, fmt, flags; + int n, v=0, w, k, n_s, base, fmt, flags; Sflong_t lv; char *sp, *ssp, *endsp, *ep, *endep; int dot, width, precis, sign, decpt; @@ -129,7 +129,7 @@ va_list args; /* arg list if !argf */ int decimal = 0, thousand = 0; #if _has_multibyte - wchar_t* wsp; + wchar_t* wsp = 0; SFMBDCL(fmbs) /* state of format string */ SFMBDCL(mbs) /* state of some string */ #ifdef mbwidth diff --git a/src/lib/libast/string/stropt.c b/src/lib/libast/string/stropt.c index 91bd35138040..12664a8a9082 100644 --- a/src/lib/libast/string/stropt.c +++ b/src/lib/libast/string/stropt.c @@ -60,13 +60,13 @@ stropt(const char* as, const void* tab, int siz, int(*f)(void*, const void*, int register char* v; register char* t; char** p; - char* u; + char* u = 0; char* x; char* e; int n; int ql; int qr; - int qc; + int qc = 0; if (!as) n = 0; else if (!(x = s = strdup(as))) n = -1; diff --git a/src/lib/libast/string/strtoi.h b/src/lib/libast/string/strtoi.h index 91799c6f6c12..6275c23c8d61 100644 --- a/src/lib/libast/string/strtoi.h +++ b/src/lib/libast/string/strtoi.h @@ -230,13 +230,13 @@ S2I_function(a, e, base) const char* a; char** e; int base; #endif register S2I_unumber n; register S2I_unumber x; - register int c; + register int c = 0; register int shift; register unsigned char* p; register unsigned char* cv; unsigned char* b; unsigned char* k; - S2I_unumber v; + S2I_unumber v = 0; #if S2I_multiplier register int base; #endif