svn commit: trunk/busybox/shell

vda at busybox.net vda at busybox.net
Thu Feb 21 04:32:09 UTC 2008


Author: vda
Date: 2008-02-20 20:32:08 -0800 (Wed, 20 Feb 2008)
New Revision: 21084

Log:
ash: sprinkle a bit more of zeroed allocations.



Modified:
   trunk/busybox/shell/ash.c


Changeset:
Modified: trunk/busybox/shell/ash.c
===================================================================
--- trunk/busybox/shell/ash.c	2008-02-21 00:12:07 UTC (rev 21083)
+++ trunk/busybox/shell/ash.c	2008-02-21 04:32:08 UTC (rev 21084)
@@ -8063,7 +8063,7 @@
 	struct var *vp;
 
 	INT_OFF;
-	lvp = ckmalloc(sizeof(struct localvar));
+	lvp = ckzalloc(sizeof(struct localvar));
 	if (LONE_DASH(name)) {
 		char *p;
 		p = ckmalloc(sizeof(optlist));
@@ -8887,7 +8887,7 @@
 	INT_OFF;
 /*dprintf("*** calling pushstring: %s, %d\n", s, len);*/
 	if (parsefile->strpush) {
-		sp = ckmalloc(sizeof(struct strpush));
+		sp = ckzmalloc(sizeof(struct strpush));
 		sp->prev = parsefile->strpush;
 		parsefile->strpush = sp;
 	} else
@@ -9520,7 +9520,7 @@
 
 struct heredoc {
 	struct heredoc *next;   /* next here document in list */
-	union node *here;               /* redirection node */
+	union node *here;       /* redirection node */
 	char *eofmark;          /* string indicating end of input */
 	int striptabs;          /* if set, strip leading tabs */
 };
@@ -9564,7 +9564,7 @@
 		if (n1 == NULL) {
 			n1 = n2;
 		} else {
-			n3 = stalloc(sizeof(struct nbinary));
+			n3 = stzalloc(sizeof(struct nbinary));
 			n3->type = NSEMI;
 			n3->nbinary.ch1 = n1;
 			n3->nbinary.ch2 = n2;
@@ -9621,7 +9621,7 @@
 		}
 		checkkwd = CHKNL | CHKKWD | CHKALIAS;
 		n2 = pipeline();
-		n3 = stalloc(sizeof(struct nbinary));
+		n3 = stzalloc(sizeof(struct nbinary));
 		n3->type = t;
 		n3->nbinary.ch1 = n1;
 		n3->nbinary.ch2 = n2;
@@ -9648,12 +9648,12 @@
 		pipenode = stzalloc(sizeof(struct npipe));
 		pipenode->type = NPIPE;
 		/*pipenode->npipe.backgnd = 0; - stzalloc did it */
-		lp = stalloc(sizeof(struct nodelist));
+		lp = stzalloc(sizeof(struct nodelist));
 		pipenode->npipe.cmdlist = lp;
 		lp->n = n1;
 		do {
 			prev = lp;
-			lp = stalloc(sizeof(struct nodelist));
+			lp = stzalloc(sizeof(struct nodelist));
 			checkkwd = CHKNL | CHKKWD | CHKALIAS;
 			lp->n = parse_command();
 			prev->next = lp;
@@ -9663,7 +9663,7 @@
 	}
 	tokpushback = 1;
 	if (negate) {
-		n2 = stalloc(sizeof(struct nnot));
+		n2 = stzalloc(sizeof(struct nnot));
 		n2->type = NNOT;
 		n2->nnot.com = n1;
 		return n2;
@@ -9747,7 +9747,8 @@
 		if (heredoclist == NULL)
 			heredoclist = here;
 		else {
-			for (p = heredoclist; p->next; p = p->next);
+			for (p = heredoclist; p->next; p = p->next)
+				continue;
 			p->next = here;
 		}
 	} else if (n->type == NTOFD || n->type == NFROMFD) {
@@ -9828,7 +9829,7 @@
 	*app = NULL;
 	*vpp = NULL;
 	*rpp = NULL;
-	n = stalloc(sizeof(struct ncmd));
+	n = stzalloc(sizeof(struct ncmd));
 	n->type = NCMD;
 	n->ncmd.args = args;
 	n->ncmd.assign = vars;
@@ -9854,7 +9855,7 @@
 		raise_error_unexpected_syntax(-1);
 		/* NOTREACHED */
 	case TIF:
-		n1 = stalloc(sizeof(struct nif));
+		n1 = stzalloc(sizeof(struct nif));
 		n1->type = NIF;
 		n1->nif.test = list(0);
 		if (readtoken() != TTHEN)
@@ -9862,7 +9863,7 @@
 		n1->nif.ifpart = list(0);
 		n2 = n1;
 		while (readtoken() == TELIF) {
-			n2->nif.elsepart = stalloc(sizeof(struct nif));
+			n2->nif.elsepart = stzalloc(sizeof(struct nif));
 			n2 = n2->nif.elsepart;
 			n2->type = NIF;
 			n2->nif.test = list(0);
@@ -9881,7 +9882,7 @@
 	case TWHILE:
 	case TUNTIL: {
 		int got;
-		n1 = stalloc(sizeof(struct nbinary));
+		n1 = stzalloc(sizeof(struct nbinary));
 		n1->type = (lasttoken == TWHILE) ? NWHILE : NUNTIL;
 		n1->nbinary.ch1 = list(0);
 		got = readtoken();
@@ -9897,7 +9898,7 @@
 	case TFOR:
 		if (readtoken() != TWORD || quoteflag || ! goodname(wordtext))
 			raise_error_syntax("Bad for loop variable");
-		n1 = stalloc(sizeof(struct nfor));
+		n1 = stzalloc(sizeof(struct nfor));
 		n1->type = NFOR;
 		n1->nfor.var = wordtext;
 		checkkwd = CHKKWD | CHKALIAS;
@@ -9937,7 +9938,7 @@
 		t = TDONE;
 		break;
 	case TCASE:
-		n1 = stalloc(sizeof(struct ncase));
+		n1 = stzalloc(sizeof(struct ncase));
 		n1->type = NCASE;
 		if (readtoken() != TWORD)
 			raise_error_unexpected_syntax(TWORD);
@@ -9958,7 +9959,7 @@
 		while (t != TESAC) {
 			if (lasttoken == TLP)
 				readtoken();
-			*cpp = cp = stalloc(sizeof(struct nclist));
+			*cpp = cp = stzalloc(sizeof(struct nclist));
 			cp->type = NCLIST;
 			app = &cp->nclist.pattern;
 			for (;;) {
@@ -10344,13 +10345,13 @@
 				/*np->nfile.fd = 0; - stzalloc did it */
 			}
 			np->type = NHERE;
-			heredoc = stalloc(sizeof(struct heredoc));
+			heredoc = stzalloc(sizeof(struct heredoc));
 			heredoc->here = np;
 			c = pgetc();
 			if (c == '-') {
 				heredoc->striptabs = 1;
 			} else {
-				heredoc->striptabs = 0;
+				/*heredoc->striptabs = 0; - stzalloc did it */
 				pungetc();
 			}
 			break;
@@ -10941,7 +10942,7 @@
 	union node *n;
 
 	here = heredoclist;
-	heredoclist = 0;
+	heredoclist = NULL;
 
 	while (here) {
 		if (needprompt) {




More information about the busybox-cvs mailing list