Module Name:    src
Committed By:   dholland
Date:           Sun Aug  9 00:22:53 UTC 2020

Modified Files:
        src/bin/csh: csh.c dir.c func.c lex.c parse.c proc.c

Log Message:
Don't cast the value returned from *malloc. No change to compiler output.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/bin/csh/csh.c
cvs rdiff -u -r1.33 -r1.34 src/bin/csh/dir.c
cvs rdiff -u -r1.43 -r1.44 src/bin/csh/func.c
cvs rdiff -u -r1.34 -r1.35 src/bin/csh/lex.c
cvs rdiff -u -r1.19 -r1.20 src/bin/csh/parse.c
cvs rdiff -u -r1.39 -r1.40 src/bin/csh/proc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/csh/csh.c
diff -u src/bin/csh/csh.c:1.50 src/bin/csh/csh.c:1.51
--- src/bin/csh/csh.c:1.50	Fri Apr  3 18:11:29 2020
+++ src/bin/csh/csh.c	Sun Aug  9 00:22:53 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: csh.c,v 1.50 2020/04/03 18:11:29 joerg Exp $ */
+/* $NetBSD: csh.c,v 1.51 2020/08/09 00:22:53 dholland Exp $ */
 
 /*-
  * Copyright (c) 1980, 1991, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)csh.c	8.2 (Berkeley) 10/12/93";
 #else
-__RCSID("$NetBSD: csh.c,v 1.50 2020/04/03 18:11:29 joerg Exp $");
+__RCSID("$NetBSD: csh.c,v 1.51 2020/08/09 00:22:53 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -697,7 +697,7 @@ importpath(Char *cp)
      * i+2 where i is the number of colons in the path. There are i+1
      * directories in the path plus we need room for a zero terminator.
      */
-    pv = (Char **)xcalloc((size_t) (i + 2), sizeof(Char **));
+    pv = xcalloc((size_t) (i + 2), sizeof(Char **));
     dp = cp;
     i = 0;
     if (*dp)
@@ -1211,7 +1211,7 @@ process(int catch)
 	 * Made it!
 	 */
 	freelex(&paraml);
-	freesyn((struct command *) savet), savet = NULL;
+	freesyn(savet), savet = NULL;
     }
     resexit(osetexit);
     savet = t;

Index: src/bin/csh/dir.c
diff -u src/bin/csh/dir.c:1.33 src/bin/csh/dir.c:1.34
--- src/bin/csh/dir.c:1.33	Fri Apr  3 18:11:29 2020
+++ src/bin/csh/dir.c	Sun Aug  9 00:22:53 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.c,v 1.33 2020/04/03 18:11:29 joerg Exp $ */
+/* $NetBSD: dir.c,v 1.34 2020/08/09 00:22:53 dholland Exp $ */
 
 /*-
  * Copyright (c) 1980, 1991, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)dir.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: dir.c,v 1.33 2020/04/03 18:11:29 joerg Exp $");
+__RCSID("$NetBSD: dir.c,v 1.34 2020/08/09 00:22:53 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -128,7 +128,7 @@ dinit(Char *hp)
 	}
     }
 
-    dp = (struct directory *)xcalloc(1, sizeof(struct directory));
+    dp = xcalloc(1, sizeof(*dp));
     dp->di_name = cp;
     dp->di_count = 0;
     dhead.di_next = dhead.di_prev = dp;
@@ -363,7 +363,7 @@ dochngd(Char **v, struct command *t)
     }
     else
 	cp = dfollow(*v);
-    dp = (struct directory *)xcalloc(1, sizeof(struct directory));
+    dp = xcalloc(1, sizeof(*dp));
     dp->di_name = cp;
     dp->di_count = 0;
     dp->di_next = dcwd->di_next;
@@ -510,7 +510,7 @@ dopushd(Char **v, struct command *t)
 	Char *ccp;
 
 	ccp = dfollow(*v);
-	dp = (struct directory *)xcalloc(1, sizeof(struct directory));
+	dp = xcalloc(1, sizeof(*dp));
 	dp->di_name = ccp;
 	dp->di_count = 0;
 	dp->di_prev = dcwd;

Index: src/bin/csh/func.c
diff -u src/bin/csh/func.c:1.43 src/bin/csh/func.c:1.44
--- src/bin/csh/func.c:1.43	Sun Jan  6 01:22:50 2019
+++ src/bin/csh/func.c	Sun Aug  9 00:22:53 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: func.c,v 1.43 2019/01/06 01:22:50 christos Exp $ */
+/* $NetBSD: func.c,v 1.44 2020/08/09 00:22:53 dholland Exp $ */
 
 /*-
  * Copyright (c) 1980, 1991, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)func.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: func.c,v 1.43 2019/01/06 01:22:50 christos Exp $");
+__RCSID("$NetBSD: func.c,v 1.44 2020/08/09 00:22:53 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -414,7 +414,7 @@ doforeach(Char **v, struct command *t)
     v = globall(v);
     if (v == 0)
 	stderror(ERR_NAME | ERR_NOMATCH);
-    nwp = (struct whyle *) xcalloc(1, sizeof *nwp);
+    nwp = xcalloc(1, sizeof *nwp);
     nwp->w_fe = nwp->w_fe0 = v;
     gargv = 0;
     btell(&nwp->w_start);
@@ -452,7 +452,7 @@ dowhile(Char **v, struct command *t)
 	stderror(ERR_NAME | ERR_EXPRESSION);
     if (!again) {
 	struct whyle *nwp =
-	(struct whyle *)xcalloc(1, sizeof(*nwp));
+		xcalloc(1, sizeof(*nwp));
 
 	nwp->w_start = lineloc;
 	nwp->w_end.type = F_SEEK;

Index: src/bin/csh/lex.c
diff -u src/bin/csh/lex.c:1.34 src/bin/csh/lex.c:1.35
--- src/bin/csh/lex.c:1.34	Fri Feb  1 08:29:03 2019
+++ src/bin/csh/lex.c	Sun Aug  9 00:22:53 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.34 2019/02/01 08:29:03 mrg Exp $ */
+/* $NetBSD: lex.c,v 1.35 2020/08/09 00:22:53 dholland Exp $ */
 
 /*-
  * Copyright (c) 1980, 1991, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)lex.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: lex.c,v 1.34 2019/02/01 08:29:03 mrg Exp $");
+__RCSID("$NetBSD: lex.c,v 1.35 2020/08/09 00:22:53 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -877,7 +877,7 @@ dosub(int sc, struct wordent *en, int gl
 
     wdp = hp;
     while (--i >= 0) {
-	struct wordent *new = (struct wordent *)xcalloc(1, sizeof *wdp);
+	struct wordent *new = xcalloc(1, sizeof *new);
 
 	new->word = 0;
 	new->prev = wdp;
@@ -1453,13 +1453,13 @@ again:
     if (buf >= fblocks) {
 	Char **nfbuf;
 
-	nfbuf = (Char **)xcalloc((size_t) (fblocks + 2), sizeof(char **));
+	nfbuf = xcalloc((size_t) (fblocks + 2), sizeof(char **));
 	if (fbuf) {
 	    (void)blkcpy(nfbuf, fbuf);
 	    free(fbuf);
 	}
 	fbuf = nfbuf;
-	fbuf[fblocks] = (Char *)xcalloc(BUFSIZE, sizeof(Char));
+	fbuf[fblocks] = xcalloc(BUFSIZE, sizeof(Char));
 	fblocks++;
 	if (!intty)
 	    goto again;
@@ -1623,9 +1623,9 @@ settell(void)
 	return;
     if (lseek(SHIN, (off_t) 0, SEEK_CUR) < 0 || errno == ESPIPE)
 	return;
-    fbuf = (Char **)xcalloc(2, sizeof(Char **));
+    fbuf = xcalloc(2, sizeof(Char **));
     fblocks = 1;
-    fbuf[0] = (Char *)xcalloc(BUFSIZE, sizeof(Char));
+    fbuf[0] = xcalloc(BUFSIZE, sizeof(Char));
     fseekp = fbobp = feobp = lseek(SHIN, (off_t) 0, SEEK_CUR);
     cantell = 1;
 }

Index: src/bin/csh/parse.c
diff -u src/bin/csh/parse.c:1.19 src/bin/csh/parse.c:1.20
--- src/bin/csh/parse.c:1.19	Sat Jan  5 16:54:00 2019
+++ src/bin/csh/parse.c	Sun Aug  9 00:22:53 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.19 2019/01/05 16:54:00 christos Exp $ */
+/* $NetBSD: parse.c,v 1.20 2020/08/09 00:22:53 dholland Exp $ */
 
 /*-
  * Copyright (c) 1980, 1991, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)parse.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: parse.c,v 1.19 2019/01/05 16:54:00 christos Exp $");
+__RCSID("$NetBSD: parse.c,v 1.20 2020/08/09 00:22:53 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -262,7 +262,7 @@ syn0(struct wordent *p1, struct wordent 
 	    if (t1->t_dtyp == NODE_LIST ||
 		t1->t_dtyp == NODE_AND ||
 		t1->t_dtyp == NODE_OR) {
-		t = (struct command *)xcalloc(1, sizeof(*t));
+		t = xcalloc(1, sizeof(*t));
 		t->t_dtyp = NODE_PAREN;
 		t->t_dflg = F_AMPERSAND | F_NOINTERRUPT;
 		t->t_dspr = t1;
@@ -270,7 +270,7 @@ syn0(struct wordent *p1, struct wordent 
 	    }
 	    else
 		t1->t_dflg |= F_AMPERSAND | F_NOINTERRUPT;
-	    t = (struct command *)xcalloc(1, sizeof(*t));
+	    t = xcalloc(1, sizeof(*t));
 	    t->t_dtyp = NODE_LIST;
 	    t->t_dflg = 0;
 	    t->t_dcar = t1;
@@ -308,7 +308,7 @@ syn1(struct wordent *p1, struct wordent 
 	case '\n':
 	    if (l != 0)
 		break;
-	    t = (struct command *) xcalloc(1, sizeof(*t));
+	    t = xcalloc(1, sizeof(*t));
 	    t->t_dtyp = NODE_LIST;
 	    t->t_dcar = syn1a(p1, p, flags);
 	    t->t_dcdr = syntax(p->next, p2, flags);
@@ -344,7 +344,7 @@ syn1a(struct wordent *p1, struct wordent
 	    if (p->word[1] != '|')
 		continue;
 	    if (l == 0) {
-		t = (struct command *)xcalloc(1, sizeof(*t));
+		t = xcalloc(1, sizeof(*t));
 		t->t_dtyp = NODE_OR;
 		t->t_dcar = syn1b(p1, p, flags);
 		t->t_dcdr = syn1a(p->next, p2, flags);
@@ -379,7 +379,7 @@ syn1b(struct wordent *p1, struct wordent
 	    continue;
 	case '&':
 	    if (p->word[1] == '&' && l == 0) {
-		t = (struct command *)xcalloc(1, sizeof(*t));
+		t = xcalloc(1, sizeof(*t));
 		t->t_dtyp = NODE_AND;
 		t->t_dcar = syn2(p1, p, flags);
 		t->t_dcdr = syn1b(p->next, p2, flags);
@@ -416,7 +416,7 @@ syn2(struct wordent *p1, struct wordent 
 	case '|':
 	    if (l != 0)
 		continue;
-	    t = (struct command *)xcalloc(1, sizeof(*t));
+	    t = xcalloc(1, sizeof(*t));
 	    f = flags | POUT;
 	    pn = p->next;
 	    if (pn != p2 && pn->word[0] == '&') {
@@ -508,8 +508,8 @@ again:
 	}
     if (n < 0)
 	n = 0;
-    t = (struct command *)xcalloc(1, sizeof(*t));
-    av = (Char **)xcalloc((size_t)(n + 1), sizeof(Char **));
+    t = xcalloc(1, sizeof(*t));
+    av = xcalloc((size_t)(n + 1), sizeof(Char **));
     t->t_dcom = av;
     n = 0;
     if (p2->word[0] == ')')

Index: src/bin/csh/proc.c
diff -u src/bin/csh/proc.c:1.39 src/bin/csh/proc.c:1.40
--- src/bin/csh/proc.c:1.39	Fri Apr  3 18:11:29 2020
+++ src/bin/csh/proc.c	Sun Aug  9 00:22:53 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: proc.c,v 1.39 2020/04/03 18:11:29 joerg Exp $ */
+/* $NetBSD: proc.c,v 1.40 2020/08/09 00:22:53 dholland Exp $ */
 
 /*-
  * Copyright (c) 1980, 1991, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)proc.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: proc.c,v 1.39 2020/04/03 18:11:29 joerg Exp $");
+__RCSID("$NetBSD: proc.c,v 1.40 2020/08/09 00:22:53 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -455,7 +455,7 @@ palloc(int pid, struct command *t)
     struct process *pp;
     int i;
 
-    pp = (struct process *)xcalloc(1, (size_t)sizeof(struct process));
+    pp = xcalloc(1, sizeof(*pp));
     pp->p_pid = pid;
     pp->p_flags = t->t_dflg & F_AMPERSAND ? PRUNNING : PRUNNING | PFOREGND;
     if (t->t_dflg & F_TIME)

Reply via email to