diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2015-02-08 05:47:29 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2015-02-08 05:47:29 +0000 |
commit | c1f682d62afbb63fc31157ff01aca31327bfaf62 (patch) | |
tree | c6900a36fc1aae7de07049e0668f8f8b8997743a | |
parent | 5a114f833e86689b554c00f7d5a9059a2357704e (diff) |
delete lots of unnecessary ptr_t casts, and drop a little NULL in as well
-rw-r--r-- | bin/csh/alloc.c | 8 | ||||
-rw-r--r-- | bin/csh/file.c | 8 | ||||
-rw-r--r-- | bin/csh/func.c | 32 | ||||
-rw-r--r-- | bin/csh/glob.c | 28 | ||||
-rw-r--r-- | bin/csh/lex.c | 19 | ||||
-rw-r--r-- | bin/csh/parse.c | 26 | ||||
-rw-r--r-- | bin/csh/sem.c | 32 | ||||
-rw-r--r-- | bin/csh/set.c | 16 |
8 files changed, 84 insertions, 85 deletions
diff --git a/bin/csh/alloc.c b/bin/csh/alloc.c index 28e9c99c765..16b3aadc60d 100644 --- a/bin/csh/alloc.c +++ b/bin/csh/alloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: alloc.c,v 1.14 2015/02/08 05:25:16 tedu Exp $ */ +/* $OpenBSD: alloc.c,v 1.15 2015/02/08 05:47:28 tedu Exp $ */ /* $NetBSD: alloc.c,v 1.6 1995/03/21 09:02:23 cgd Exp $ */ /*- @@ -43,7 +43,7 @@ Malloc(size_t n) { ptr_t ptr; - if ((ptr = malloc(n)) == (ptr_t) 0) { + if ((ptr = malloc(n)) == NULL) { child++; stderror(ERR_NOMEM); } @@ -55,7 +55,7 @@ Reallocarray(ptr_t p, size_t c, size_t n) { ptr_t ptr; - if ((ptr = reallocarray(p, c, n)) == (ptr_t) 0) { + if ((ptr = reallocarray(p, c, n)) == NULL) { child++; stderror(ERR_NOMEM); } @@ -67,7 +67,7 @@ Calloc(size_t s, size_t n) { ptr_t ptr; - if ((ptr = calloc(s, n)) == (ptr_t) 0) { + if ((ptr = calloc(s, n)) == NULL) { child++; stderror(ERR_NOMEM); } diff --git a/bin/csh/file.c b/bin/csh/file.c index 40730e7c08d..5d1fd48993b 100644 --- a/bin/csh/file.c +++ b/bin/csh/file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: file.c,v 1.18 2015/01/16 06:39:31 deraadt Exp $ */ +/* $OpenBSD: file.c,v 1.19 2015/02/08 05:47:28 tedu Exp $ */ /* $NetBSD: file.c,v 1.11 1996/11/08 19:34:37 christos Exp $ */ /*- @@ -395,8 +395,8 @@ free_items(Char **items, int numitems) int i; for (i = 0; i < numitems; i++) - xfree((ptr_t) items[i]); - xfree((ptr_t) items); + xfree(items[i]); + xfree(items); } #define FREE_ITEMS(items) { \ @@ -492,7 +492,7 @@ again: /* search for matches */ return (numitems); } else { /* LIST */ - qsort((ptr_t) items, numitems, sizeof(*items), + qsort(items, numitems, sizeof(*items), (int (*)(const void *, const void *)) sortscmp); print_by_column(looking_for_lognames ? NULL : tilded_dir, items, numitems); diff --git a/bin/csh/func.c b/bin/csh/func.c index ca02f726af7..36cd8371a41 100644 --- a/bin/csh/func.c +++ b/bin/csh/func.c @@ -1,4 +1,4 @@ -/* $OpenBSD: func.c,v 1.26 2014/10/16 19:43:31 deraadt Exp $ */ +/* $OpenBSD: func.c,v 1.27 2015/02/08 05:47:28 tedu Exp $ */ /* $NetBSD: func.c,v 1.11 1996/02/09 02:28:29 christos Exp $ */ /*- @@ -127,7 +127,7 @@ doonintr(Char **v, struct command *t) stderror(ERR_NAME | ERR_TERMINAL); cp = gointr; gointr = 0; - xfree((ptr_t) cp); + xfree(cp); if (vv == 0) { if (setintr) { sigemptyset(&sigset); @@ -300,7 +300,7 @@ dogoto(Char **v, struct command *t) Char *lp; gotolab(lp = globone(v[1], G_ERROR)); - xfree((ptr_t) lp); + xfree(lp); } void @@ -341,7 +341,7 @@ doswitch(Char **v, struct command *t) if (*v) stderror(ERR_SYNTAX); search(T_SWITCH, 0, lp = globone(cp, G_ERROR)); - xfree((ptr_t) lp); + xfree(lp); } void @@ -661,7 +661,7 @@ search(int type, int level, Char *goal) cp = strip(Dfix1(aword)); if (Gmatch(goal, cp)) level = -1; - xfree((ptr_t) cp); + xfree(cp); break; case T_DEFAULT: @@ -826,8 +826,8 @@ wfree(void) if (wp->w_fe0) blkfree(wp->w_fe0); if (wp->w_fename) - xfree((ptr_t) wp->w_fename); - xfree((ptr_t) wp); + xfree(wp->w_fename); + xfree(wp); } } @@ -931,7 +931,7 @@ dosetenv(Char **v, struct command *t) AsciiOnly = 0; #endif /* NLS */ } - xfree((ptr_t) lp); + xfree(lp); } void @@ -943,7 +943,7 @@ dounsetenv(Char **v, struct command *t) static Char *name = NULL; if (name) - xfree((ptr_t) name); + xfree(name); /* * Find the longest environment variable */ @@ -984,7 +984,7 @@ dounsetenv(Char **v, struct command *t) Unsetenv(name); break; } - xfree((ptr_t) name); + xfree(name); name = NULL; } @@ -1002,21 +1002,21 @@ Setenv(Char *name, Char *val) if (*cp != 0 || *dp != '=') continue; cp = Strspl(STRequal, val); - xfree((ptr_t) * ep); + xfree(* ep); *ep = strip(Strspl(name, cp)); - xfree((ptr_t) cp); + xfree(cp); blkfree((Char **) environ); environ = short2blk(STR_environ); return; } cp = Strspl(name, STRequal); blk[0] = strip(Strspl(cp, val)); - xfree((ptr_t) cp); + xfree(cp); blk[1] = 0; STR_environ = blkspl(STR_environ, blk); blkfree((Char **) environ); environ = short2blk(STR_environ); - xfree((ptr_t) oep); + xfree(oep); } static void @@ -1036,8 +1036,8 @@ Unsetenv(Char *name) STR_environ = blkspl(STR_environ, ep + 1); environ = short2blk(STR_environ); *ep = cp; - xfree((ptr_t) cp); - xfree((ptr_t) oep); + xfree(cp); + xfree(oep); return; } } diff --git a/bin/csh/glob.c b/bin/csh/glob.c index d5d4a54c292..a26a75fe80c 100644 --- a/bin/csh/glob.c +++ b/bin/csh/glob.c @@ -1,4 +1,4 @@ -/* $OpenBSD: glob.c,v 1.15 2015/01/16 06:39:31 deraadt Exp $ */ +/* $OpenBSD: glob.c,v 1.16 2015/02/08 05:47:28 tedu Exp $ */ /* $NetBSD: glob.c,v 1.10 1995/03/21 09:03:01 cgd Exp $ */ /*- @@ -110,7 +110,7 @@ globtilde(Char **nv, Char *s) *b++ = *s++; *b = EOS; --u; - xfree((ptr_t) u); + xfree(u); return (Strsave(gstart)); } @@ -228,13 +228,13 @@ expbrace(Char ***nvp, Char ***elp, int size) int len; if ((len = globbrace(s, b, &bl)) < 0) { - xfree((ptr_t) nv); + xfree(nv); stderror(ERR_MISSING, -len); } - xfree((ptr_t) s); + xfree(s); if (len == 1) { *vl-- = *bl; - xfree((ptr_t) bl); + xfree(bl); continue; } len = blklen(bl); @@ -258,7 +258,7 @@ expbrace(Char ***nvp, Char ***elp, int size) vp++; for (bp = bl + 1; *bp; *vp++ = *bp++) continue; - xfree((ptr_t) bl); + xfree(bl); } } @@ -294,7 +294,7 @@ globexpand(Char **v) vl = &nv[size - GLOBSPACE]; } } - xfree((ptr_t) pargv); + xfree(pargv); pargv = NULL; } else { @@ -345,9 +345,9 @@ handleone(Char *str, Char **vl, int action) str = Strsave(*vlp++); do { cp = Strspl(str, STRspace); - xfree((ptr_t) str); + xfree(str); str = Strspl(cp, *vlp); - xfree((ptr_t) cp); + xfree(cp); } while (*++vlp) ; @@ -430,14 +430,14 @@ globone(Char *str, int action) vo = globexpand(v); if (noglob || (gflg & G_GLOB) == 0) { if (vo[0] == NULL) { - xfree((ptr_t) vo); + xfree(vo); return (Strsave(STRNULL)); } if (vo[1] != NULL) return (handleone(str, vo, action)); else { str = strip(vo[0]); - xfree((ptr_t) vo); + xfree(vo); return (str); } } @@ -455,14 +455,14 @@ globone(Char *str, int action) stderror(ERR_NAME | ERR_NOMATCH); } if (vl[0] == NULL) { - xfree((ptr_t) vl); + xfree(vl); return (Strsave(STRNULL)); } if (vl[1] != NULL) return (handleone(str, vl, action)); else { str = strip(*vl); - xfree((ptr_t) vl); + xfree(vl); return (str); } } @@ -695,7 +695,7 @@ backeval(Char *cp, bool literal) execute(t, -1, NULL, NULL); exitstat(); } - xfree((ptr_t) cp); + xfree(cp); (void) close(pvec[1]); c = 0; ip = NULL; diff --git a/bin/csh/lex.c b/bin/csh/lex.c index 2ea507e3ad7..34b5e26b59e 100644 --- a/bin/csh/lex.c +++ b/bin/csh/lex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lex.c,v 1.14 2009/10/27 23:59:21 deraadt Exp $ */ +/* $OpenBSD: lex.c,v 1.15 2015/02/08 05:47:28 tedu Exp $ */ /* $NetBSD: lex.c,v 1.9 1995/09/27 00:38:46 jtc Exp $ */ /*- @@ -211,8 +211,8 @@ freelex(struct wordent *vp) while (vp->next != vp) { fp = vp->next; vp->next = fp->next; - xfree((ptr_t) fp->word); - xfree((ptr_t) fp); + xfree(fp->word); + xfree(fp); } vp->prev = vp; } @@ -864,11 +864,11 @@ dosub(int sc, struct wordent *en, bool global) otword = tword; tword = subword(otword, sc, &didone); if (Strcmp(tword, otword) == 0) { - xfree((ptr_t) otword); + xfree(otword); break; } else - xfree((ptr_t) otword); + xfree(otword); } } } @@ -1428,16 +1428,15 @@ bgetc(void) again: buf = (int) fseekp / BUFSIZ; if (buf >= fblocks) { - Char **nfbuf = - (Char **) xcalloc((size_t) (fblocks + 2), + Char **nfbuf = xcalloc((size_t) (fblocks + 2), sizeof(Char **)); if (fbuf) { (void) blkcpy(nfbuf, fbuf); - xfree((ptr_t) fbuf); + xfree(fbuf); } fbuf = nfbuf; - fbuf[fblocks] = (Char *) xcalloc(BUFSIZ, sizeof(Char)); + fbuf[fblocks] = xcalloc(BUFSIZ, sizeof(Char)); fblocks++; if (!intty) goto again; @@ -1512,7 +1511,7 @@ bfree(void) sb = (int) (fseekp - 1) / BUFSIZ; if (sb > 0) { for (i = 0; i < sb; i++) - xfree((ptr_t) fbuf[i]); + xfree(fbuf[i]); (void) blkcpy(fbuf, &fbuf[sb]); fseekp -= BUFSIZ * sb; feobp -= BUFSIZ * sb; diff --git a/bin/csh/parse.c b/bin/csh/parse.c index 7b833c50871..754482e1f35 100644 --- a/bin/csh/parse.c +++ b/bin/csh/parse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.c,v 1.9 2009/10/27 23:59:21 deraadt Exp $ */ +/* $OpenBSD: parse.c,v 1.10 2015/02/08 05:47:28 tedu Exp $ */ /* $NetBSD: parse.c,v 1.6 1995/03/21 09:03:10 cgd Exp $ */ /*- @@ -170,7 +170,7 @@ asyn3(struct wordent *p1, struct wordent *p2) Char *cp = alout.next->word; alout.next->word = Strspl(STRQNULL, cp); - xfree((ptr_t) cp); + xfree(cp); } p1 = freenod(p1, redid ? p2 : p1->next); if (alout.next != &alout) { @@ -178,8 +178,8 @@ asyn3(struct wordent *p1, struct wordent *p2) alout.prev->prev->next = p1->next; alout.next->prev = p1; p1->next = alout.next; - xfree((ptr_t) alout.prev->word); - xfree((ptr_t) (alout.prev)); + xfree(alout.prev->word); + xfree((alout.prev)); } reset(); /* throw! */ } @@ -190,9 +190,9 @@ freenod(struct wordent *p1, struct wordent *p2) struct wordent *retp = p1->prev; while (p1 != p2) { - xfree((ptr_t) p1->word); + xfree(p1->word); p1 = p1->next; - xfree((ptr_t) (p1->prev)); + xfree((p1->prev)); } retp->next = p2; p2->prev = retp; @@ -645,15 +645,15 @@ freesyn(struct command *t) case NODE_COMMAND: for (v = t->t_dcom; *v; v++) - xfree((ptr_t) * v); - xfree((ptr_t) (t->t_dcom)); - xfree((ptr_t) t->t_dlef); - xfree((ptr_t) t->t_drit); + xfree(* v); + xfree((t->t_dcom)); + xfree(t->t_dlef); + xfree(t->t_drit); break; case NODE_PAREN: freesyn(t->t_dspr); - xfree((ptr_t) t->t_dlef); - xfree((ptr_t) t->t_drit); + xfree(t->t_dlef); + xfree(t->t_drit); break; case NODE_AND: @@ -663,5 +663,5 @@ freesyn(struct command *t) freesyn(t->t_dcar), freesyn(t->t_dcdr); break; } - xfree((ptr_t) t); + xfree(t); } diff --git a/bin/csh/sem.c b/bin/csh/sem.c index 930b8a214aa..17ea1bdb555 100644 --- a/bin/csh/sem.c +++ b/bin/csh/sem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sem.c,v 1.18 2015/01/16 06:39:31 deraadt Exp $ */ +/* $OpenBSD: sem.c,v 1.19 2015/02/08 05:47:28 tedu Exp $ */ /* $NetBSD: sem.c,v 1.9 1995/09/27 00:38:50 jtc Exp $ */ /*- @@ -250,7 +250,7 @@ execute(struct command *t, int wanttty, int *pipein, int *pipeout) otpgrp = tpgrp; ocsigset = csigset; onosigchld = nosigchld; - Vsav = Vdp = 0; + Vsav = Vdp = NULL; Vexpath = 0; Vt = 0; pid = vfork(); @@ -273,14 +273,14 @@ execute(struct command *t, int wanttty, int *pipein, int *pipeout) csigset = ocsigset; nosigchld = onosigchld; - xfree((ptr_t) Vsav); - Vsav = 0; - xfree((ptr_t) Vdp); - Vdp = 0; - xfree((ptr_t) Vexpath); - Vexpath = 0; + xfree(Vsav); + Vsav = NULL; + xfree(Vdp); + Vdp = NULL; + xfree(Vexpath); + Vexpath = NULL; blkfree((Char **) Vt); - Vt = 0; + Vt = NULL; /* this is from pfork() */ palloc(pid, t); sigprocmask(SIG_SETMASK, &osigset, NULL); @@ -483,23 +483,23 @@ splicepipe(struct command *t, Char *cp) /* word after < or > */ pv = globall(blk); if (pv == NULL) { setname(vis_str(blk[0])); - xfree((ptr_t) blk[0]); + xfree(blk[0]); stderror(ERR_NAME | ERR_NOMATCH); } gargv = NULL; if (pv[1] != NULL) { /* we need to fix the command vector */ Char **av = blkspl(t->t_dcom, &pv[1]); - xfree((ptr_t) t->t_dcom); + xfree(t->t_dcom); t->t_dcom = av; } - xfree((ptr_t) blk[0]); + xfree(blk[0]); blk[0] = pv[0]; - xfree((ptr_t) pv); + xfree(pv); } } else { blk[0] = globone(blk[1] = Dfix1(cp), G_ERROR); - xfree((ptr_t) blk[1]); + xfree(blk[1]); } return(blk[0]); } @@ -529,7 +529,7 @@ doio(struct command *t, int *pipein, int *pipeout) (void) dcopy(SHERR, 2); cp = splicepipe(t, t->t_dlef); strlcpy(tmp, short2str(cp), sizeof tmp); - xfree((ptr_t) cp); + xfree(cp); if ((fd = open(tmp, O_RDONLY)) < 0) stderror(ERR_SYSTEM, tmp, strerror(errno)); (void) dmove(fd, 0); @@ -555,7 +555,7 @@ doio(struct command *t, int *pipein, int *pipeout) cp = splicepipe(t, t->t_drit); strlcpy(tmp, short2str(cp), sizeof tmp); - xfree((ptr_t) cp); + xfree(cp); /* * so > /dev/std{out,err} work */ diff --git a/bin/csh/set.c b/bin/csh/set.c index 0edd885c653..0870f39ff4b 100644 --- a/bin/csh/set.c +++ b/bin/csh/set.c @@ -1,4 +1,4 @@ -/* $OpenBSD: set.c,v 1.13 2014/10/16 19:43:31 deraadt Exp $ */ +/* $OpenBSD: set.c,v 1.14 2015/02/08 05:47:28 tedu Exp $ */ /* $NetBSD: set.c,v 1.8 1995/03/21 18:35:52 mycroft Exp $ */ /*- @@ -160,7 +160,7 @@ doset(Char **v, struct command *t) Setenv(STRHOME, cp); /* fix directory stack for new tilde home */ dtilde(); - xfree((ptr_t) cp); + xfree(cp); } #ifdef FILEC else if (eq(vp, STRfilec)) @@ -187,7 +187,7 @@ asx(Char *vp, int subscr, Char *p) { struct varent *v = getvx(vp, subscr); - xfree((ptr_t) v->vec[subscr - 1]); + xfree(v->vec[subscr - 1]); v->vec[subscr - 1] = globone(p, G_APPEND); } @@ -282,9 +282,9 @@ dolet(Char **v, struct command *t) exportpath(adrof(STRpath)->vec); dohash(NULL, NULL); } - xfree((ptr_t) vp); + xfree(vp); if (c != '=') - xfree((ptr_t) p); + xfree(p); } while ((p = *v++) != NULL); } @@ -296,7 +296,7 @@ xset(Char *cp, Char ***vp) if (*cp) { dp = Strsave(cp); --(*vp); - xfree((ptr_t) ** vp); + xfree(** vp); **vp = dp; } return (putn(expr(vp))); @@ -543,7 +543,7 @@ unsetv1(struct varent *p) * Free associated memory first to avoid complications. */ blkfree(p->vec); - xfree((ptr_t) p->v_name); + xfree(p->v_name); /* * If p is missing one child, then we can move the other into where p is. * Otherwise, we find the predecessor of p, which is guaranteed to have no @@ -571,7 +571,7 @@ unsetv1(struct varent *p) /* * Free the deleted node, and rebalance. */ - xfree((ptr_t) p); + xfree(p); balance(pp, f, 1); } |