mirror of
				git://git.code.sf.net/p/cdesktopenv/code
				synced 2025-03-09 15:50:02 +00:00 
			
		
		
		
	Fix various possible uses of uninitialised variables
Patch from OpenSUSE, slightly adapted for 93u+m. Source: https://build.opensuse.org/package/view_file/shells/ksh/ksh93-uninitialized.dif
This commit is contained in:
		
							parent
							
								
									c52cb93999
								
							
						
					
					
						commit
						288b6c6517
					
				
					 15 changed files with 39 additions and 32 deletions
				
			
		|  | @ -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++) && dp<dpmax) | ||||
| 	{ | ||||
| 		ssize_t size; | ||||
| 		if((size = mbconv(dp, wc)) < 0) | ||||
| 		{ | ||||
| 			/* copy the character as is */ | ||||
|  |  | |||
|  | @ -1176,7 +1176,7 @@ Shell_t *sh_init(register int argc,register char *argv[], Shinit_f userinit) | |||
| 	static int beenhere; | ||||
| 	Shell_t	*shp; | ||||
| 	register int n; | ||||
| 	int type; | ||||
| 	int type = 0; | ||||
| 	char *save_envmarker; | ||||
| 	static char *login_files[2]; | ||||
| 	memfatal(); | ||||
|  | @ -1846,7 +1846,7 @@ Dt_t *sh_inittree(Shell_t *shp,const struct shtable2 *name_vals) | |||
| 	register const struct shtable2 *tp; | ||||
| 	register unsigned n = 0; | ||||
| 	register Dt_t *treep; | ||||
| 	Dt_t *base_treep, *dict; | ||||
| 	Dt_t *base_treep, *dict = 0; | ||||
| 	for(tp=name_vals;*tp->sh_name;tp++) | ||||
| 		n++; | ||||
| 	np = (Namval_t*)calloc(n,sizeof(Namval_t)); | ||||
|  |  | |||
|  | @ -1803,7 +1803,7 @@ retry2: | |||
| 		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) | ||||
|  |  | |||
|  | @ -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 */ | ||||
|  |  | |||
|  | @ -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; | ||||
|  |  | |||
|  | @ -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]==']') | ||||
|  |  | |||
|  | @ -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 <numnodes; i++) | ||||
| 	{ | ||||
| 		np=nodes[i]; | ||||
|  |  | |||
|  | @ -302,7 +302,7 @@ static Shnode_t *getanode(Lex_t *lp, struct argnod *ap) | |||
|  */ | ||||
| static Shnode_t	*makelist(Lex_t *lexp, int type, Shnode_t *l, Shnode_t *r) | ||||
| { | ||||
| 	register Shnode_t	*t; | ||||
| 	register Shnode_t	*t = NIL(Shnode_t*); | ||||
| 	if(!l || !r) | ||||
| 		sh_syntax(lexp); | ||||
| 	else | ||||
|  | @ -808,7 +808,7 @@ static Shnode_t *funct(Lex_t *lexp) | |||
| 		{ | ||||
| 			struct comnod	*ac; | ||||
| 			char		*cp, **argv, **argv0; | ||||
| 			int		c; | ||||
| 			int		c=-1; | ||||
| 			t->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); | ||||
|  |  | |||
|  | @ -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]; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue