diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-08-20 22:32:43 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-08-20 22:32:43 +0000 |
commit | 6e5d9523d6273368df6377a4db98a9533d11505c (patch) | |
tree | 665d65c04b5874cca0392587a8c45d740f3af051 | |
parent | 856a95e3f951c7875c113b683b773a7bccf1e685 (diff) |
Do not cast result of malloc/calloc/realloc* if stdlib.h is in scope
ok krw millert
52 files changed, 171 insertions, 177 deletions
diff --git a/usr.bin/at/at.c b/usr.bin/at/at.c index 080d2e853dc..e9c8528415d 100644 --- a/usr.bin/at/at.c +++ b/usr.bin/at/at.c @@ -1,4 +1,4 @@ -/* $OpenBSD: at.c,v 1.64 2014/10/08 03:56:52 doug Exp $ */ +/* $OpenBSD: at.c,v 1.65 2015/08/20 22:32:41 deraadt Exp $ */ /* * at.c : Put file into atrun queue @@ -514,7 +514,7 @@ list_jobs(int argc, char **argv, int count_only, int csort) */ numjobs = 0; maxjobs = stbuf.st_nlink + 4; - atjobs = (struct atjob **)calloc(maxjobs, sizeof(struct atjob *)); + atjobs = calloc(maxjobs, sizeof(struct atjob *)); if (atjobs == NULL) panic("Insufficient virtual memory"); @@ -561,7 +561,7 @@ list_jobs(int argc, char **argv, int count_only, int csort) continue; } - job = (struct atjob *)malloc(sizeof(struct atjob)); + job = malloc(sizeof(struct atjob)); if (job == NULL) panic("Insufficient virtual memory"); job->runtimer = runtimer; diff --git a/usr.bin/at/parsetime.c b/usr.bin/at/parsetime.c index 452a548283a..b01a6c81632 100644 --- a/usr.bin/at/parsetime.c +++ b/usr.bin/at/parsetime.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parsetime.c,v 1.22 2015/03/17 19:31:30 millert Exp $ */ +/* $OpenBSD: parsetime.c,v 1.23 2015/08/20 22:32:41 deraadt Exp $ */ /* * parsetime.c - parse time for at(1) @@ -180,7 +180,7 @@ init_scanner(int argc, char **argv) while (argc-- > 0) sc_len += strlen(*argv++); - if ((sc_token = (char *) malloc(sc_len)) == NULL) { + if ((sc_token = malloc(sc_len)) == NULL) { fprintf(stderr, "%s: Insufficient virtual memory\n", ProgramName); return (-1); diff --git a/usr.bin/cdio/rip.c b/usr.bin/cdio/rip.c index 890066280fb..64c8d1e6656 100644 --- a/usr.bin/cdio/rip.c +++ b/usr.bin/cdio/rip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rip.c,v 1.15 2014/09/13 16:06:37 doug Exp $ */ +/* $OpenBSD: rip.c,v 1.16 2015/08/20 22:32:41 deraadt Exp $ */ /* * Copyright (c) 2007 Alexey Vatchenko <av@bsdua.org> @@ -220,7 +220,7 @@ _add_pair(struct track_pair_head *head, int val1, int val2, int issorted) } } - tp = (struct track_pair *)malloc(sizeof(*tp)); + tp = malloc(sizeof(*tp)); if (tp == NULL) return (-1); @@ -369,7 +369,7 @@ read_track(struct track *ti) n_sec = ti->end_lba - ti->start_lba; blksize = (ti->isaudio) ? 2352 : 2048; - sec = (u_char *)malloc(blksize); + sec = malloc(blksize); if (sec == NULL) return (-1); diff --git a/usr.bin/compress/gzopen.c b/usr.bin/compress/gzopen.c index dd239534a5c..5837ee7a611 100644 --- a/usr.bin/compress/gzopen.c +++ b/usr.bin/compress/gzopen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gzopen.c,v 1.28 2015/01/16 06:40:06 deraadt Exp $ */ +/* $OpenBSD: gzopen.c,v 1.29 2015/08/20 22:32:41 deraadt Exp $ */ /* * Copyright (c) 1997 Michael Shalayeff @@ -115,7 +115,7 @@ gz_open(int fd, const char *mode, char *name, int bits, errno = EINVAL; return NULL; } - if ((s = (gz_stream *)calloc(1, sizeof(gz_stream))) == NULL) + if ((s = calloc(1, sizeof(gz_stream))) == NULL) return NULL; s->z_stream.zalloc = (alloc_func)0; diff --git a/usr.bin/compress/nullopen.c b/usr.bin/compress/nullopen.c index 95467a4599c..8890fe6f9e4 100644 --- a/usr.bin/compress/nullopen.c +++ b/usr.bin/compress/nullopen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nullopen.c,v 1.4 2011/09/22 10:41:04 deraadt Exp $ */ +/* $OpenBSD: nullopen.c,v 1.5 2015/08/20 22:32:41 deraadt Exp $ */ /* * Copyright (c) 2003 Can Erkin Acar @@ -60,7 +60,7 @@ null_open(int fd, const char *mode, char *name, int bits, return NULL; } - if ((s = (null_stream *) calloc(1, sizeof(null_stream))) == NULL) + if ((s = calloc(1, sizeof(null_stream))) == NULL) return NULL; s->fd = fd; diff --git a/usr.bin/ctags/tree.c b/usr.bin/ctags/tree.c index cb6952efa25..98ac352b2f5 100644 --- a/usr.bin/ctags/tree.c +++ b/usr.bin/ctags/tree.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tree.c,v 1.10 2009/10/27 23:59:37 deraadt Exp $ */ +/* $OpenBSD: tree.c,v 1.11 2015/08/20 22:32:41 deraadt Exp $ */ /* $NetBSD: tree.c,v 1.4 1995/03/26 20:14:11 glass Exp $ */ /* @@ -54,12 +54,12 @@ pfnote(char *name, int ln) char nbuf[1+MAXNAMLEN+1]; /*NOSTRICT*/ - if (!(np = (NODE *)malloc(sizeof(NODE)))) { + if (!(np = malloc(sizeof(NODE)))) { warnx("too many entries to sort"); put_entries(head); free_tree(head); /*NOSTRICT*/ - if (!(head = np = (NODE *)malloc(sizeof(NODE)))) + if (!(head = np = malloc(sizeof(NODE)))) err(1, NULL); } if (!xflag && !strcmp(name, "main")) { diff --git a/usr.bin/cvs/entries.c b/usr.bin/cvs/entries.c index 83eb9612ca1..64043d81410 100644 --- a/usr.bin/cvs/entries.c +++ b/usr.bin/cvs/entries.c @@ -1,4 +1,4 @@ -/* $OpenBSD: entries.c,v 1.104 2015/04/04 14:19:10 stsp Exp $ */ +/* $OpenBSD: entries.c,v 1.105 2015/08/20 22:32:41 deraadt Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -51,7 +51,7 @@ cvs_ent_open(const char *dir) current_list = NULL; } - ep = (CVSENTRIES *)xcalloc(1, sizeof(*ep)); + ep = xcalloc(1, sizeof(*ep)); ep->cef_path = xstrdup(buf); (void)xsnprintf(buf, sizeof(buf), "%s/%s", @@ -72,7 +72,7 @@ cvs_ent_open(const char *dir) if (buf[0] == 'D' && buf[1] == '\0') break; - line = (struct cvs_ent_line *)xmalloc(sizeof(*line)); + line = xmalloc(sizeof(*line)); line->buf = xstrdup(buf); TAILQ_INSERT_TAIL(&(ep->cef_ent), line, entries_list); } @@ -329,7 +329,7 @@ cvs_ent_add(CVSENTRIES *ep, const char *line) (void)fclose(fp); - l = (struct cvs_ent_line *)xmalloc(sizeof(*l)); + l = xmalloc(sizeof(*l)); l->buf = xstrdup(line); TAILQ_INSERT_TAIL(&(ep->cef_ent), l, entries_list); } diff --git a/usr.bin/cvs/file.c b/usr.bin/cvs/file.c index 519c88f7198..06879f2a932 100644 --- a/usr.bin/cvs/file.c +++ b/usr.bin/cvs/file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: file.c,v 1.265 2015/02/05 12:59:57 millert Exp $ */ +/* $OpenBSD: file.c,v 1.266 2015/08/20 22:32:41 deraadt Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> @@ -216,7 +216,7 @@ cvs_file_get(char *name, int flags, struct cvs_flisthead *fl, int type) if (l != NULL) return (l); - l = (struct cvs_filelist *)xmalloc(sizeof(*l)); + l = xmalloc(sizeof(*l)); l->file_path = xstrdup(p); l->flags = flags; l->type = type; @@ -235,7 +235,7 @@ cvs_file_get_cf(const char *d, const char *f, const char *fpath, int fd, for (p = fpath; p[0] == '.' && p[1] == '/';) p += 2; - cf = (struct cvs_file *)xcalloc(1, sizeof(*cf)); + cf = xcalloc(1, sizeof(*cf)); cf->file_name = xstrdup(f); cf->file_wd = xstrdup(d); diff --git a/usr.bin/finger/finger.c b/usr.bin/finger/finger.c index e2e2134e49d..5ec24c144bf 100644 --- a/usr.bin/finger/finger.c +++ b/usr.bin/finger/finger.c @@ -1,4 +1,4 @@ -/* $OpenBSD: finger.c,v 1.19 2015/01/16 06:40:07 deraadt Exp $ */ +/* $OpenBSD: finger.c,v 1.20 2015/08/20 22:32:41 deraadt Exp $ */ /* * Copyright (c) 1989 The Regents of the University of California. @@ -194,7 +194,7 @@ userlist(int argc, char **argv) struct passwd *pw; int dolocal, *used; - if (!(used = (int *)calloc((u_int)argc, (u_int)sizeof(int)))) + if (!(used = calloc((u_int)argc, (u_int)sizeof(int)))) err(2, "malloc"); /* pull out all network requests */ diff --git a/usr.bin/finger/sprint.c b/usr.bin/finger/sprint.c index 81e23dd2f88..ffed24b9c0a 100644 --- a/usr.bin/finger/sprint.c +++ b/usr.bin/finger/sprint.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sprint.c,v 1.15 2015/03/15 00:41:28 millert Exp $ */ +/* $OpenBSD: sprint.c,v 1.16 2015/08/20 22:32:41 deraadt Exp $ */ /* * Copyright (c) 1989 The Regents of the University of California. @@ -132,7 +132,7 @@ sort(void) PERSON *pn, **lp; PERSON **list; - if (!(list = (PERSON **)calloc((u_int)entries, sizeof(PERSON *)))) + if (!(list = calloc((u_int)entries, sizeof(PERSON *)))) err(1, "malloc"); for (lp = list, pn = phead; pn != NULL; pn = pn->next) *lp++ = pn; diff --git a/usr.bin/finger/util.c b/usr.bin/finger/util.c index 6e845c1ed71..0a1ba56a721 100644 --- a/usr.bin/finger/util.c +++ b/usr.bin/finger/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.30 2015/01/16 06:40:07 deraadt Exp $ */ +/* $OpenBSD: util.c,v 1.31 2015/08/20 22:32:41 deraadt Exp $ */ /* * Copyright (c) 1989 The Regents of the University of California. @@ -302,7 +302,7 @@ palloc(void) { PERSON *p; - if ((p = (PERSON *)malloc((u_int) sizeof(PERSON))) == NULL) + if ((p = malloc((u_int) sizeof(PERSON))) == NULL) err(1, "malloc"); return (p); } @@ -312,7 +312,7 @@ walloc(PERSON *pn) { WHERE *w; - if ((w = (WHERE *)malloc((u_int) sizeof(WHERE))) == NULL) + if ((w = malloc((u_int) sizeof(WHERE))) == NULL) err(1, "malloc"); if (pn->whead == NULL) pn->whead = pn->wtail = w; diff --git a/usr.bin/gprof/arcs.c b/usr.bin/gprof/arcs.c index 824e99a8725..8ba102e3cae 100644 --- a/usr.bin/gprof/arcs.c +++ b/usr.bin/gprof/arcs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: arcs.c,v 1.12 2009/10/27 23:59:38 deraadt Exp $ */ +/* $OpenBSD: arcs.c,v 1.13 2015/08/20 22:32:41 deraadt Exp $ */ /* $NetBSD: arcs.c,v 1.6 1995/04/19 07:15:52 cgd Exp $ */ /* @@ -68,7 +68,7 @@ addarc(nltype *parentp, nltype *childp, long count) arcp -> arc_count += count; return; } - arcp = (arctype *)calloc( 1 , sizeof *arcp ); + arcp = calloc( 1 , sizeof *arcp ); arcp -> arc_parentp = parentp; arcp -> arc_childp = childp; arcp -> arc_count = count; @@ -189,7 +189,7 @@ doarcs() /* * Sort the symbol table in reverse topological order */ - topsortnlp = (nltype **) calloc( nname , sizeof(nltype *) ); + topsortnlp = calloc( nname , sizeof(nltype *) ); if ( topsortnlp == (nltype **) 0 ) warnx("[doarcs] ran out of memory for topo sorting"); for ( index = 0 ; index < nname ; index += 1 ) { @@ -225,7 +225,7 @@ doarcs() * sorting both the regular function names * and cycle headers. */ - timesortnlp = (nltype **) calloc( nname + ncycle , sizeof(nltype *) ); + timesortnlp = calloc( nname + ncycle , sizeof(nltype *) ); if ( timesortnlp == (nltype **) 0 ) warnx("ran out of memory for sorting"); for ( index = 0 ; index < nname ; index++ ) { @@ -364,7 +364,7 @@ cyclelink() * cyclenl is indexed by cycle number: * i.e. it is origin 1, not origin 0. */ - cyclenl = (nltype *) calloc( ncycle + 1 , sizeof( nltype ) ); + cyclenl = calloc( ncycle + 1 , sizeof( nltype ) ); if ( cyclenl == 0 ) errx(0, "No room for %ld bytes of cycle headers", (ncycle + 1) * sizeof(nltype)); @@ -467,7 +467,7 @@ cycleanalyze() if ( size <= cyclethreshold ) continue; done = FALSE; - cyclestack = (arctype **) calloc( size + 1 , sizeof( arctype *) ); + cyclestack = calloc( size + 1 , sizeof( arctype *) ); if ( cyclestack == 0 ) { warnx("No room for %ld bytes of cycle stack" , (size + 1) * sizeof(arctype *)); @@ -581,8 +581,7 @@ addcycle(arctype **stkstart, arctype **stkend) return( TRUE ); } } - clp = (cltype *) - calloc( 1 , sizeof ( cltype ) + ( size - 1 ) * sizeof( arctype * ) ); + clp = calloc( 1 , sizeof ( cltype ) + ( size - 1 ) * sizeof( arctype * ) ); if ( clp == 0 ) { warnx("No room for %ld bytes of subcycle storage" , sizeof(cltype) + (size - 1) * sizeof(arctype *)); diff --git a/usr.bin/gprof/elf.c b/usr.bin/gprof/elf.c index 5a2381325c9..321f1357321 100644 --- a/usr.bin/gprof/elf.c +++ b/usr.bin/gprof/elf.c @@ -103,7 +103,7 @@ getnfile(const char *filename, char ***defaultEs) #endif /* Allocate memory for them, plus a terminating entry. */ - if ((nl = (nltype *)calloc(nname + 1, sizeof(nltype))) == NULL) + if ((nl = calloc(nname + 1, sizeof(nltype))) == NULL) errx(1, "Insufficient memory for symbol table"); /* Read them in. */ diff --git a/usr.bin/gprof/gprof.c b/usr.bin/gprof/gprof.c index 50dd2807710..2f38f9c3739 100644 --- a/usr.bin/gprof/gprof.c +++ b/usr.bin/gprof/gprof.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gprof.c,v 1.21 2014/12/22 18:21:10 tedu Exp $ */ +/* $OpenBSD: gprof.c,v 1.22 2015/08/20 22:32:41 deraadt Exp $ */ /* $NetBSD: gprof.c,v 1.8 1995/04/19 07:15:59 cgd Exp $ */ /* @@ -369,7 +369,7 @@ readsamples(FILE *pfile) int i; if (samples == 0) { - samples = (UNIT *) calloc(sampbytes, sizeof (UNIT)); + samples = calloc(sampbytes, sizeof (UNIT)); if (samples == 0) errx(1, "No room for %ld sample pc's", sampbytes / sizeof (UNIT)); } diff --git a/usr.bin/gprof/printgprof.c b/usr.bin/gprof/printgprof.c index 8a0f820639c..e53a8f0e00c 100644 --- a/usr.bin/gprof/printgprof.c +++ b/usr.bin/gprof/printgprof.c @@ -1,4 +1,4 @@ -/* $OpenBSD: printgprof.c,v 1.12 2009/10/27 23:59:38 deraadt Exp $ */ +/* $OpenBSD: printgprof.c,v 1.13 2015/08/20 22:32:41 deraadt Exp $ */ /* $NetBSD: printgprof.c,v 1.5 1995/04/19 07:16:21 cgd Exp $ */ /* @@ -50,7 +50,7 @@ printprof() /* * Sort the symbol table in by time */ - sortednlp = (nltype **) calloc( nname , sizeof(nltype *) ); + sortednlp = calloc( nname , sizeof(nltype *) ); if ( sortednlp == (nltype **) 0 ) warnx("[printprof] ran out of memory for time sorting"); for ( index = 0 ; index < nname ; index += 1 ) { @@ -659,7 +659,7 @@ printindex() * Now, sort regular function name alphbetically * to create an index. */ - namesortnlp = (nltype **) calloc( nname + ncycle , sizeof(nltype *) ); + namesortnlp = calloc( nname + ncycle , sizeof(nltype *) ); if ( namesortnlp == (nltype **) 0 ) warnx("ran out of memory for sorting"); for ( index = 0 , nnames = 0 ; index < nname ; index++ ) { diff --git a/usr.bin/gprof/printlist.c b/usr.bin/gprof/printlist.c index 534200809c3..663b362b4d4 100644 --- a/usr.bin/gprof/printlist.c +++ b/usr.bin/gprof/printlist.c @@ -1,4 +1,4 @@ -/* $OpenBSD: printlist.c,v 1.7 2009/10/27 23:59:38 deraadt Exp $ */ +/* $OpenBSD: printlist.c,v 1.8 2015/08/20 22:32:41 deraadt Exp $ */ /* $NetBSD: printlist.c,v 1.5 1995/04/19 07:16:23 cgd Exp $ */ /* @@ -58,7 +58,7 @@ addlist(struct stringlist *listp, char *funcname) { struct stringlist *slp; - slp = (struct stringlist *) malloc( sizeof(struct stringlist)); + slp = malloc(sizeof(struct stringlist)); if (slp == (struct stringlist *) 0) errx(0, "ran out room for printlist"); slp -> next = listp -> next; diff --git a/usr.bin/indent/indent.c b/usr.bin/indent/indent.c index ad33d215568..d7e10329c9d 100644 --- a/usr.bin/indent/indent.c +++ b/usr.bin/indent/indent.c @@ -1,4 +1,4 @@ -/* $OpenBSD: indent.c,v 1.26 2015/01/16 06:40:08 deraadt Exp $ */ +/* $OpenBSD: indent.c,v 1.27 2015/08/20 22:32:41 deraadt Exp $ */ /* * Copyright (c) 1980, 1993 @@ -89,10 +89,10 @@ main(int argc, char **argv) ps.last_nl = true; /* this is true if the last thing scanned was * a newline */ ps.last_token = semicolon; - combuf = (char *) malloc(bufsize); - labbuf = (char *) malloc(bufsize); - codebuf = (char *) malloc(bufsize); - tokenbuf = (char *) malloc(bufsize); + combuf = malloc(bufsize); + labbuf = malloc(bufsize); + codebuf = malloc(bufsize); + tokenbuf = malloc(bufsize); if (combuf == NULL || labbuf == NULL || codebuf == NULL || tokenbuf == NULL) err(1, NULL); @@ -109,7 +109,7 @@ main(int argc, char **argv) s_com = e_com = combuf + 1; s_token = e_token = tokenbuf + 1; - in_buffer = (char *) malloc(10); + in_buffer = malloc(10); if (in_buffer == NULL) err(1, NULL); in_buffer_limit = in_buffer + 8; diff --git a/usr.bin/indent/indent_globs.h b/usr.bin/indent/indent_globs.h index 110e392c59c..ea56bf4eb8e 100644 --- a/usr.bin/indent/indent_globs.h +++ b/usr.bin/indent/indent_globs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: indent_globs.h,v 1.12 2015/01/19 15:30:52 krw Exp $ */ +/* $OpenBSD: indent_globs.h,v 1.13 2015/08/20 22:32:41 deraadt Exp $ */ /* * Copyright (c) 1985 Sun Microsystems, Inc. * Copyright (c) 1980, 1993 @@ -55,7 +55,7 @@ FILE *output; /* the output file */ if (e_code >= l_code) { \ int nsize = l_code-s_code+400; \ \ - codebuf = (char *) realloc(codebuf, nsize); \ + codebuf = realloc(codebuf, nsize); \ if (codebuf == NULL) \ err(1, NULL); \ e_code = codebuf + (e_code-s_code) + 1; \ @@ -66,7 +66,7 @@ FILE *output; /* the output file */ if (e_com >= l_com) { \ int nsize = l_com-s_com+400; \ \ - combuf = (char *) realloc(combuf, nsize); \ + combuf = realloc(combuf, nsize); \ if (combuf == NULL) \ err(1, NULL); \ e_com = combuf + (e_com-s_com) + 1; \ @@ -77,7 +77,7 @@ FILE *output; /* the output file */ if (e_lab >= l_lab) { \ int nsize = l_lab-s_lab+400; \ \ - labbuf = (char *) realloc(labbuf, nsize); \ + labbuf = realloc(labbuf, nsize); \ if (labbuf == NULL) \ err(1, NULL); \ e_lab = labbuf + (e_lab-s_lab) + 1; \ @@ -88,7 +88,7 @@ FILE *output; /* the output file */ if (e_token >= l_token) { \ int nsize = l_token-s_token+400; \ \ - tokenbuf = (char *) realloc(tokenbuf, nsize); \ + tokenbuf = realloc(tokenbuf, nsize); \ if (tokenbuf == NULL) \ err(1, NULL); \ e_token = tokenbuf + (e_token-s_token) + 1; \ diff --git a/usr.bin/indent/lexi.c b/usr.bin/indent/lexi.c index e1d5ad30a8d..91754a7d98a 100644 --- a/usr.bin/indent/lexi.c +++ b/usr.bin/indent/lexi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lexi.c,v 1.18 2015/01/22 05:35:27 jsg Exp $ */ +/* $OpenBSD: lexi.c,v 1.19 2015/08/20 22:32:41 deraadt Exp $ */ /* * Copyright (c) 1980, 1993 @@ -582,7 +582,7 @@ addkey(char *key, int val) */ nspecials = sizeof (specialsinit) / sizeof (specialsinit[0]); maxspecials = nspecials + (nspecials >> 2); - specials = (struct templ *)calloc(maxspecials, sizeof specials[0]); + specials = calloc(maxspecials, sizeof specials[0]); if (specials == NULL) err(1, NULL); memcpy(specials, specialsinit, sizeof specialsinit); diff --git a/usr.bin/last/last.c b/usr.bin/last/last.c index ba3c8aec66c..259b8d3c861 100644 --- a/usr.bin/last/last.c +++ b/usr.bin/last/last.c @@ -1,4 +1,4 @@ -/* $OpenBSD: last.c,v 1.48 2015/03/15 00:41:28 millert Exp $ */ +/* $OpenBSD: last.c,v 1.49 2015/08/20 22:32:41 deraadt Exp $ */ /* $NetBSD: last.c,v 1.6 1994/12/24 16:49:02 cgd Exp $ */ /* @@ -463,7 +463,7 @@ addarg(int type, char *arg) { struct arg *cur; - if (!(cur = (struct arg *)malloc((u_int)sizeof(struct arg)))) + if (!(cur = malloc((u_int)sizeof(struct arg)))) err(1, "malloc failure"); cur->next = arglist; cur->type = type; @@ -479,7 +479,7 @@ addtty(char *ttyname) { struct ttytab *cur; - if (!(cur = (struct ttytab *)malloc((u_int)sizeof(struct ttytab)))) + if (!(cur = malloc((u_int)sizeof(struct ttytab)))) err(1, "malloc failure"); cur->next = ttylist; cur->logout = currentout; diff --git a/usr.bin/make/varmodifiers.c b/usr.bin/make/varmodifiers.c index 2c9229a5842..27bd13d8f13 100644 --- a/usr.bin/make/varmodifiers.c +++ b/usr.bin/make/varmodifiers.c @@ -1,4 +1,4 @@ -/* $OpenBSD: varmodifiers.c,v 1.41 2015/01/23 22:35:58 espie Exp $ */ +/* $OpenBSD: varmodifiers.c,v 1.42 2015/08/20 22:32:41 deraadt Exp $ */ /* $NetBSD: var.c,v 1.18 1997/03/18 19:24:46 christos Exp $ */ /* @@ -658,7 +658,7 @@ get_sysvpattern(const char **p, SymTable *ctxt UNUSED, bool err, int endc) Buf_AddChar(&buf, *cp2); } - pattern = (VarPattern *)emalloc(sizeof(VarPattern)); + pattern = emalloc(sizeof(VarPattern)); pattern->lbuffer = pattern->lhs = Str_dupi(*p, cp); pattern->leftLen = cp - *p; pattern->rhs = Buf_Retrieve(&buf); @@ -1280,7 +1280,7 @@ common_get_patternarg(const char **p, SymTable *ctxt, bool err, int endc, char delim; const char *s; - pattern = (VarPattern *)emalloc(sizeof(VarPattern)); + pattern = emalloc(sizeof(VarPattern)); pattern->flags = 0; s = *p; @@ -1354,7 +1354,7 @@ get_value(const char **p, SymTable *ctxt, bool err, int endc) VarPattern *pattern; const char *s; - pattern = (VarPattern *)emalloc(sizeof(VarPattern)); + pattern = emalloc(sizeof(VarPattern)); s = *p + 1; pattern->rhs = NULL; pattern->lbuffer = VarGetPattern(ctxt, err, &s, ':', endc, @@ -1373,7 +1373,7 @@ get_cmd(const char **p, SymTable *ctxt, bool err, int endc UNUSED) VarPattern *pattern; const char *s; - pattern = (VarPattern *)emalloc(sizeof(VarPattern)); + pattern = emalloc(sizeof(VarPattern)); s = *p + 1; pattern->rhs = NULL; pattern->lbuffer = VarGetPattern(ctxt, err, &s, '!', '!', diff --git a/usr.bin/mklocale/yacc.y b/usr.bin/mklocale/yacc.y index 430256ffe38..46816aad825 100644 --- a/usr.bin/mklocale/yacc.y +++ b/usr.bin/mklocale/yacc.y @@ -1,4 +1,4 @@ -/* $OpenBSD: yacc.y,v 1.6 2014/10/14 15:35:40 deraadt Exp $ */ +/* $OpenBSD: yacc.y,v 1.7 2015/08/20 22:32:41 deraadt Exp $ */ /* $NetBSD: yacc.y,v 1.24 2004/01/05 23:23:36 jmmv Exp $ */ %{ @@ -170,7 +170,7 @@ entry : ENCODING STRING list : RUNE { - $$ = (rune_list *)xmalloc(sizeof(rune_list)); + $$ = xmalloc(sizeof(rune_list)); $$->min = ($1 & charsetmask) | charsetbits; $$->max = ($1 & charsetmask) | charsetbits; $$->map = 0; @@ -178,7 +178,7 @@ list : RUNE } | RUNE THRU RUNE { - $$ = (rune_list *)xmalloc(sizeof(rune_list)); + $$ = xmalloc(sizeof(rune_list)); $$->min = ($1 & charsetmask) | charsetbits; $$->max = ($3 & charsetmask) | charsetbits; $$->map = 0; @@ -186,7 +186,7 @@ list : RUNE } | list RUNE { - $$ = (rune_list *)xmalloc(sizeof(rune_list)); + $$ = xmalloc(sizeof(rune_list)); $$->min = ($2 & charsetmask) | charsetbits; $$->max = ($2 & charsetmask) | charsetbits; $$->map = 0; @@ -194,7 +194,7 @@ list : RUNE } | list RUNE THRU RUNE { - $$ = (rune_list *)xmalloc(sizeof(rune_list)); + $$ = xmalloc(sizeof(rune_list)); $$->min = ($2 & charsetmask) | charsetbits; $$->max = ($4 & charsetmask) | charsetbits; $$->map = 0; @@ -204,7 +204,7 @@ list : RUNE map : LBRK RUNE RUNE RBRK { - $$ = (rune_list *)xmalloc(sizeof(rune_list)); + $$ = xmalloc(sizeof(rune_list)); $$->min = ($2 & charsetmask) | charsetbits; $$->max = ($2 & charsetmask) | charsetbits; $$->map = $3; @@ -212,7 +212,7 @@ map : LBRK RUNE RUNE RBRK } | map LBRK RUNE RUNE RBRK { - $$ = (rune_list *)xmalloc(sizeof(rune_list)); + $$ = xmalloc(sizeof(rune_list)); $$->min = ($3 & charsetmask) | charsetbits; $$->max = ($3 & charsetmask) | charsetbits; $$->map = $4; @@ -220,7 +220,7 @@ map : LBRK RUNE RUNE RBRK } | LBRK RUNE THRU RUNE ':' RUNE RBRK { - $$ = (rune_list *)xmalloc(sizeof(rune_list)); + $$ = xmalloc(sizeof(rune_list)); $$->min = ($2 & charsetmask) | charsetbits; $$->max = ($4 & charsetmask) | charsetbits; $$->map = $6; @@ -228,7 +228,7 @@ map : LBRK RUNE RUNE RBRK } | map LBRK RUNE THRU RUNE ':' RUNE RBRK { - $$ = (rune_list *)xmalloc(sizeof(rune_list)); + $$ = xmalloc(sizeof(rune_list)); $$->min = ($3 & charsetmask) | charsetbits; $$->max = ($5 & charsetmask) | charsetbits; $$->map = $7; @@ -311,7 +311,7 @@ xmalloc(size_t sz) u_int32_t * xlalloc(size_t sz) { - u_int32_t *r = (u_int32_t *)reallocarray(NULL, sz, sizeof(u_int32_t)); + u_int32_t *r = reallocarray(NULL, sz, sizeof(u_int32_t)); if (!r) { perror("xlalloc"); abort(); @@ -322,7 +322,7 @@ xlalloc(size_t sz) u_int32_t * xrelalloc(u_int32_t *old, size_t sz) { - u_int32_t *r = (u_int32_t *)reallocarray(old, sz, sizeof(u_int32_t)); + u_int32_t *r = reallocarray(old, sz, sizeof(u_int32_t)); if (!r) { perror("xrelalloc"); abort(); @@ -351,7 +351,7 @@ set_digitmap(rune_map *map, rune_list *list) rune_list *nlist = list->next; for (i = list->min; i <= list->max; ++i) { if (list->map + (i - list->min)) { - rune_list *tmp = (rune_list *)xmalloc(sizeof(rune_list)); + rune_list *tmp = xmalloc(sizeof(rune_list)); tmp->min = i; tmp->max = i; add_map(map, tmp, list->map + (i - list->min)); diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c index 2c0e46d370a..a56d5d51a03 100644 --- a/usr.bin/netstat/inet.c +++ b/usr.bin/netstat/inet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inet.c,v 1.143 2015/06/21 12:11:13 claudio Exp $ */ +/* $OpenBSD: inet.c,v 1.144 2015/08/20 22:32:41 deraadt Exp $ */ /* $NetBSD: inet.c,v 1.14 1995/10/03 21:42:37 thorpej Exp $ */ /* @@ -833,7 +833,7 @@ getrpcportnam(in_port_t port, int proto) return (NULL); } for (; head != NULL; head = head->pml_next) { - n = (struct rpcnams *)malloc(sizeof(struct rpcnams)); + n = malloc(sizeof(struct rpcnams)); if (n == NULL) continue; n->next = rpcn; diff --git a/usr.bin/newsyslog/newsyslog.c b/usr.bin/newsyslog/newsyslog.c index 1bd3fece8e3..761da365f9d 100644 --- a/usr.bin/newsyslog/newsyslog.c +++ b/usr.bin/newsyslog/newsyslog.c @@ -1,4 +1,4 @@ -/* $OpenBSD: newsyslog.c,v 1.94 2015/02/08 23:40:34 deraadt Exp $ */ +/* $OpenBSD: newsyslog.c,v 1.95 2015/08/20 22:32:41 deraadt Exp $ */ /* * Copyright (c) 1999, 2002, 2003 Todd C. Miller <Todd.Miller@courtesan.com> @@ -225,7 +225,7 @@ main(int argc, char **argv) p = x; } - pidlist = (struct pidinfo *)calloc(listlen + 1, sizeof(struct pidinfo)); + pidlist = calloc(listlen + 1, sizeof(struct pidinfo)); if (pidlist == NULL) err(1, "calloc"); @@ -1019,7 +1019,7 @@ domonitor(struct conf_entry *ent) /* Now see if current size is larger. */ if (sb.st_size > osize) { - rb = (char *) malloc(sb.st_size - osize); + rb = malloc(sb.st_size - osize); if (rb == NULL) err(1, "malloc"); diff --git a/usr.bin/passwd/yp_passwd.c b/usr.bin/passwd/yp_passwd.c index de9a6603edf..03e9d50b5bf 100644 --- a/usr.bin/passwd/yp_passwd.c +++ b/usr.bin/passwd/yp_passwd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: yp_passwd.c,v 1.35 2015/01/16 06:40:10 deraadt Exp $ */ +/* $OpenBSD: yp_passwd.c,v 1.36 2015/08/20 22:32:41 deraadt Exp $ */ /* * Copyright (c) 1988 The Regents of the University of California. @@ -330,7 +330,7 @@ ypgetpwnam(char *nam, int secure) val[vallen] = '\0'; if (__yplin) free(__yplin); - __yplin = (char *)malloc(vallen + 1); + __yplin = malloc(vallen + 1); if (__yplin == NULL) pw_error(NULL, 1, 1); strlcpy(__yplin, val, vallen + 1); diff --git a/usr.bin/pr/pr.c b/usr.bin/pr/pr.c index 0a953558301..be0d5592c3d 100644 --- a/usr.bin/pr/pr.c +++ b/usr.bin/pr/pr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pr.c,v 1.35 2015/02/08 23:40:34 deraadt Exp $ */ +/* $OpenBSD: pr.c,v 1.36 2015/08/20 22:32:41 deraadt Exp $ */ /*- * Copyright (c) 1991 Keith Muller. @@ -391,21 +391,21 @@ vertcol(int argc, char *argv[]) * col pointers when no headers */ mvc = lines * clcnt; - if ((vc=(struct vcol *)calloc((unsigned)mvc, sizeof(struct vcol))) == NULL) + if ((vc = calloc((unsigned)mvc, sizeof(struct vcol))) == NULL) goto oomem; /* * pointer into page where last data per line is located */ - if ((lstdat = (char **)calloc((unsigned)lines, sizeof(char *))) == NULL) + if ((lstdat = calloc((unsigned)lines, sizeof(char *))) == NULL) goto oomem; /* * fast index lookups to locate start of lines */ - if ((indy = (int *)calloc((unsigned)lines, sizeof(int))) == NULL) + if ((indy = calloc((unsigned)lines, sizeof(int))) == NULL) goto oomem; - if ((lindy = (int *)calloc((unsigned)lines, sizeof(int))) == NULL) + if ((lindy = calloc((unsigned)lines, sizeof(int))) == NULL) goto oomem; if (nmwd) @@ -915,13 +915,13 @@ mulfile(int argc, char *argv[]) /* * array of FILE *, one for each operand */ - if ((fbuf = (FILE **)calloc((unsigned)clcnt, sizeof(FILE *))) == NULL) + if ((fbuf = calloc((unsigned)clcnt, sizeof(FILE *))) == NULL) goto oomem; /* * array of int *, one for each operand */ - if ((rc = (int *)calloc((unsigned)clcnt, sizeof(int))) == NULL) + if ((rc = calloc((unsigned)clcnt, sizeof(int))) == NULL) goto oomem; /* diff --git a/usr.bin/quota/quota.c b/usr.bin/quota/quota.c index 7d2bfdf3c48..0e9dc68c2d3 100644 --- a/usr.bin/quota/quota.c +++ b/usr.bin/quota/quota.c @@ -1,4 +1,4 @@ -/* $OpenBSD: quota.c,v 1.35 2015/02/08 23:40:34 deraadt Exp $ */ +/* $OpenBSD: quota.c,v 1.36 2015/08/20 22:32:41 deraadt Exp $ */ /* * Copyright (c) 1980, 1990, 1993 @@ -444,8 +444,7 @@ getprivs(long id, int quotatype) setfsent(); for (i = 0; i < nfst; i++) { if (qup == NULL) { - if ((qup = - (struct quotause *)malloc(sizeof *qup)) == NULL) + if ((qup = malloc(sizeof *qup)) == NULL) errx(2, "out of memory"); } if (strncmp(fst[i].f_fstypename, "nfs", MFSNAMELEN) == 0) { diff --git a/usr.bin/rpcgen/rpc_cout.c b/usr.bin/rpcgen/rpc_cout.c index ae13b1165c9..1a04f04fa67 100644 --- a/usr.bin/rpcgen/rpc_cout.c +++ b/usr.bin/rpcgen/rpc_cout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rpc_cout.c,v 1.24 2013/11/28 18:24:54 deraadt Exp $ */ +/* $OpenBSD: rpc_cout.c,v 1.25 2015/08/20 22:32:41 deraadt Exp $ */ /* $NetBSD: rpc_cout.c,v 1.6 1996/10/01 04:13:53 cgd Exp $ */ /* @@ -355,7 +355,7 @@ emit_union(def) int len = strlen(def->def_name) + strlen(format) + strlen(cs->name) + 1; - object = alloc(len); + object = malloc(len); if (object == NULL) { fprintf(stderr, "Fatal error: no memory\n"); crash(); @@ -380,7 +380,7 @@ emit_union(def) strlen(dflt->name) + 1; fprintf(fout, "\tdefault:\n"); - object = alloc(len); + object = malloc(len); if (object == NULL) { fprintf(stderr, "Fatal error: no memory\n"); crash(); @@ -515,7 +515,7 @@ emit_struct(def) len = strlen(sizestr) + strlen(ptemp) + 1; - sizestr = (char *)realloc(sizestr, len); + sizestr = realloc(sizestr, len); if (sizestr == NULL) { fprintf(stderr, "Fatal error: no memory\n"); @@ -731,7 +731,7 @@ upcase(str) { char *ptr, *hptr; - ptr = (char *) malloc(strlen(str)+1); + ptr = malloc(strlen(str)+1); if (ptr == (char *) NULL) { fprintf(stderr, "malloc failed\n"); exit(1); diff --git a/usr.bin/rpcgen/rpc_main.c b/usr.bin/rpcgen/rpc_main.c index 70027bac95d..dec139fc6a8 100644 --- a/usr.bin/rpcgen/rpc_main.c +++ b/usr.bin/rpcgen/rpc_main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rpc_main.c,v 1.29 2015/01/16 06:40:11 deraadt Exp $ */ +/* $OpenBSD: rpc_main.c,v 1.30 2015/08/20 22:32:41 deraadt Exp $ */ /* $NetBSD: rpc_main.c,v 1.9 1996/02/19 11:12:43 pk Exp $ */ /* @@ -214,7 +214,7 @@ extendfile(char *path, char *ext) file++; len = strlen(file) + strlen(ext) + 1; - res = alloc(len); + res = malloc(len); if (res == NULL) { fprintf(stderr, "could not allocate memory\n"); exit(1); diff --git a/usr.bin/rpcgen/rpc_parse.c b/usr.bin/rpcgen/rpc_parse.c index 5ef82eb08b1..1b7e68fa897 100644 --- a/usr.bin/rpcgen/rpc_parse.c +++ b/usr.bin/rpcgen/rpc_parse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rpc_parse.c,v 1.18 2010/09/01 14:43:34 millert Exp $ */ +/* $OpenBSD: rpc_parse.c,v 1.19 2015/08/20 22:32:41 deraadt Exp $ */ /* $NetBSD: rpc_parse.c,v 1.5 1995/08/29 23:05:55 cgd Exp $ */ /* @@ -66,7 +66,7 @@ get_definition(void) definition *defp; token tok; - defp = ALLOC(definition); + defp = malloc(sizeof(definition)); get_token(&tok); switch (tok.kind) { case TOK_STRUCT: @@ -122,7 +122,7 @@ def_struct(defp) tailp = &defp->def.st.decls; do { get_declaration(&dec, DEF_STRUCT); - decls = ALLOC(decl_list); + decls = malloc(sizeof(decl_list)); decls->decl = dec; *tailp = decls; tailp = &decls->next; @@ -156,13 +156,13 @@ def_program(defp) scan(TOK_VERSION, &tok); do { scan(TOK_IDENT, &tok); - vlist = ALLOC(version_list); + vlist = malloc(sizeof(version_list)); vlist->vers_name = tok.str; scan(TOK_LBRACE, &tok); ptailp = &vlist->procs; do { /* get result type */ - plist = ALLOC(proc_list); + plist = malloc(sizeof(proc_list)); get_type(&plist->res_prefix, &plist->res_type, DEF_PROGRAM); if (streq(plist->res_type, "opaque")) { @@ -181,7 +181,7 @@ def_program(defp) get_prog_declaration(&dec, DEF_PROGRAM, num_args); if (streq(dec.type, "void")) isvoid = TRUE; - decls = ALLOC(decl_list); + decls = malloc(sizeof(decl_list)); plist->args.decls = decls; decls->decl = dec; tailp = &decls->next; @@ -190,7 +190,7 @@ def_program(defp) num_args++; get_prog_declaration(&dec, DEF_STRUCT, num_args); - decls = ALLOC(decl_list); + decls = malloc(sizeof(decl_list)); decls->decl = dec; *tailp = decls; if (streq(dec.type, "void")) @@ -254,7 +254,7 @@ def_enum(defp) tailp = &defp->def.en.vals; do { scan(TOK_IDENT, &tok); - elist = ALLOC(enumval_list); + elist = malloc(sizeof(enumval_list)); elist->name = tok.str; elist->assignment = NULL; scan3(TOK_COMMA, TOK_RBRACE, TOK_EQUAL, &tok); @@ -306,7 +306,7 @@ def_union(defp) scan(TOK_CASE, &tok); while (tok.kind == TOK_CASE) { scan2(TOK_IDENT, TOK_CHARCONST, &tok); - cases = ALLOC(case_list); + cases = malloc(sizeof(case_list)); cases->case_name = tok.str; scan(TOK_COLON, &tok); /* now peek at next token */ @@ -317,14 +317,14 @@ def_union(defp) cases->contflag=1; /* continued case statement */ *tailp = cases; tailp = &cases->next; - cases = ALLOC(case_list); + cases = malloc(sizeof(case_list)); cases->case_name = tok.str; scan(TOK_COLON, &tok); } while (peekscan(TOK_CASE,&tok)); } else if (flag) { *tailp = cases; tailp = &cases->next; - cases = ALLOC(case_list); + cases = malloc(sizeof(case_list)); } get_declaration(&dec, DEF_UNION); cases->case_decl = dec; @@ -340,7 +340,7 @@ def_union(defp) if (tok.kind == TOK_DEFAULT) { scan(TOK_COLON, &tok); get_declaration(&dec, DEF_UNION); - defp->def.un.default_decl = ALLOC(declaration); + defp->def.un.default_decl = malloc(sizeof(declaration)); *defp->def.un.default_decl = dec; scan(TOK_SEMICOLON, &tok); scan(TOK_RBRACE, &tok); diff --git a/usr.bin/rpcgen/rpc_scan.c b/usr.bin/rpcgen/rpc_scan.c index d2e3f742417..2ce4851655f 100644 --- a/usr.bin/rpcgen/rpc_scan.c +++ b/usr.bin/rpcgen/rpc_scan.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rpc_scan.c,v 1.17 2013/11/28 18:24:54 deraadt Exp $ */ +/* $OpenBSD: rpc_scan.c,v 1.18 2015/08/20 22:32:41 deraadt Exp $ */ /* $NetBSD: rpc_scan.c,v 1.4 1995/06/11 21:50:02 pk Exp $ */ /* @@ -326,7 +326,7 @@ findstrconst(str, val) } p++; size = p - *str; - *val = alloc(size + 1); + *val = malloc(size + 1); if (val == NULL) error("alloc failed"); (void) strncpy(*val, *str, size); @@ -354,7 +354,7 @@ findchrconst(str, val) if (size != 3) { error("empty char string"); } - *val = alloc(size + 1); + *val = malloc(size + 1); if (val == NULL) error("alloc failed"); (void) strncpy(*val, *str, size); @@ -382,7 +382,7 @@ findconst(str, val) } while (isdigit((unsigned char)*p)); } size = p - *str; - *val = alloc(size + 1); + *val = malloc(size + 1); if (val == NULL) error("alloc failed"); (void) strncpy(*val, *str, size); @@ -441,7 +441,7 @@ findkind(mark, tokp) for (len = 0; isalnum((unsigned char)str[len]) || str[len] == '_'; len++) ; - tokp->str = alloc(len + 1); + tokp->str = malloc(len + 1); if (tokp->str == NULL) error("alloc failed"); (void) strncpy(tokp->str, str, len); @@ -495,7 +495,7 @@ docppline(line, lineno, fname) error("preprocessor error"); } line++; - p = file = alloc(strlen(line) + 1); + p = file = malloc(strlen(line) + 1); if (p == NULL) error("alloc failed"); while (*line && *line != '"') { diff --git a/usr.bin/rpcgen/rpc_util.c b/usr.bin/rpcgen/rpc_util.c index 4e10292a03a..c0807957d1d 100644 --- a/usr.bin/rpcgen/rpc_util.c +++ b/usr.bin/rpcgen/rpc_util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rpc_util.c,v 1.16 2012/12/05 23:20:26 deraadt Exp $ */ +/* $OpenBSD: rpc_util.c,v 1.17 2015/08/20 22:32:41 deraadt Exp $ */ /* $NetBSD: rpc_util.c,v 1.6 1995/08/29 23:05:57 cgd Exp $ */ /* @@ -117,7 +117,7 @@ storeval(lstp, val) for (l = lstp; *l != NULL; l = (list **) & (*l)->next) ; - lst = ALLOC(list); + lst = malloc(sizeof(list)); if (lst == NULL) { fprintf(stderr, "failed in alloc\n"); exit(1); @@ -444,7 +444,7 @@ make_argname(pname, vname) char *name; int len = strlen(pname) + strlen(vname) + strlen(ARGEXT) + 3; - name = (char *)malloc(len); + name = malloc(len); if (!name) { fprintf(stderr, "failed in malloc\n"); exit(1); @@ -463,7 +463,7 @@ add_type(len, type) { bas_type *ptr; - if ((ptr = (bas_type *)malloc(sizeof(bas_type))) == (bas_type *)NULL) { + if ((ptr = malloc(sizeof(bas_type))) == (bas_type *)NULL) { fprintf(stderr, "failed in malloc\n"); exit(1); } diff --git a/usr.bin/rpcgen/rpc_util.h b/usr.bin/rpcgen/rpc_util.h index d8187f4710c..2adad1ab37c 100644 --- a/usr.bin/rpcgen/rpc_util.h +++ b/usr.bin/rpcgen/rpc_util.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rpc_util.h,v 1.15 2010/09/01 14:43:34 millert Exp $ */ +/* $OpenBSD: rpc_util.h,v 1.16 2015/08/20 22:32:41 deraadt Exp $ */ /* $NetBSD: rpc_util.h,v 1.3 1995/06/11 21:50:10 pk Exp $ */ /* @@ -38,9 +38,6 @@ * rpc_util.h, Useful definitions for the RPC protocol compiler */ -#define alloc(size) (void *)malloc((unsigned)(size)) -#define ALLOC(object) (object *) malloc(sizeof(object)) - struct list { definition *val; struct list *next; diff --git a/usr.bin/rs/rs.c b/usr.bin/rs/rs.c index f29f580f0d8..5521f55bb19 100644 --- a/usr.bin/rs/rs.c +++ b/usr.bin/rs/rs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rs.c,v 1.24 2014/10/08 04:07:24 doug Exp $ */ +/* $OpenBSD: rs.c,v 1.25 2015/08/20 22:32:41 deraadt Exp $ */ /*- * Copyright (c) 1993 @@ -268,7 +268,7 @@ prepfile(void) *ep = *(ep - nelem); nelem = lp - elem; } - if (!(colwidths = (short *) calloc(ocols, sizeof(short)))) + if (!(colwidths = calloc(ocols, sizeof(short)))) errx(1, "malloc: No gutter space"); if (flags & SQUEEZE) { if (flags & TRANSPOSE) @@ -321,7 +321,7 @@ get_line(void) /* get line; maintain curline, curlen; manage storage */ printf(" %d line %d\n", curlen, irows); } if (!putlength && endblock - curline < BUFSIZ) { /* need storage */ - if (!(curline = (char *) malloc(BSIZE))) + if (!(curline = malloc(BSIZE))) errx(1, "File too large"); endblock = curline + BSIZE; } diff --git a/usr.bin/rup/rup.c b/usr.bin/rup/rup.c index 6e61fc06a28..50d8035f1d5 100644 --- a/usr.bin/rup/rup.c +++ b/usr.bin/rup/rup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rup.c,v 1.29 2015/01/16 06:40:11 deraadt Exp $ */ +/* $OpenBSD: rup.c,v 1.30 2015/08/20 22:32:41 deraadt Exp $ */ /*- * Copyright (c) 1993, John Brezak @@ -76,7 +76,7 @@ remember_host(struct in_addr addr) { struct host_list *hp; - if (!(hp = (struct host_list *)malloc(sizeof(struct host_list)))) { + if (!(hp = malloc(sizeof(struct host_list)))) { err(1, NULL); /* NOTREACHED */ } diff --git a/usr.bin/rusers/rusers.c b/usr.bin/rusers/rusers.c index 96077d82c5a..6fe6dfbf31a 100644 --- a/usr.bin/rusers/rusers.c +++ b/usr.bin/rusers/rusers.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rusers.c,v 1.34 2015/01/16 06:40:11 deraadt Exp $ */ +/* $OpenBSD: rusers.c,v 1.35 2015/08/20 22:32:41 deraadt Exp $ */ /* * Copyright (c) 2001, 2003 Todd C. Miller <Todd.Miller@courtesan.com> @@ -540,7 +540,7 @@ allhosts(void) xdr_destroy(&xdr); maxfd = MAXIMUM(sock[0], sock[1]) + 1; - fds = (fd_set *)calloc(howmany(maxfd, NFDBITS), sizeof(fd_mask)); + fds = calloc(howmany(maxfd, NFDBITS), sizeof(fd_mask)); if (fds == NULL) err(1, NULL); @@ -690,7 +690,7 @@ expandhosts(void) for (i = 0, count = 0; i < nentries; i++) count += hostinfo[i].count; - new_hostinfo = (struct host_info *)calloc(sizeof(*entry), count); + new_hostinfo = calloc(sizeof(*entry), count); if (new_hostinfo == NULL) err(1, NULL); for (i = 0, entry = new_hostinfo; i < nentries; i++) { diff --git a/usr.bin/showmount/showmount.c b/usr.bin/showmount/showmount.c index 0ed5200ad4f..694dee7400b 100644 --- a/usr.bin/showmount/showmount.c +++ b/usr.bin/showmount/showmount.c @@ -1,4 +1,4 @@ -/* $OpenBSD: showmount.c,v 1.17 2009/10/27 23:59:43 deraadt Exp $ */ +/* $OpenBSD: showmount.c,v 1.18 2015/08/20 22:32:42 deraadt Exp $ */ /* $NetBSD: showmount.c,v 1.7 1996/05/01 18:14:10 cgd Exp $ */ /* @@ -235,7 +235,7 @@ xdr_mntdump(XDR *xdrsp, struct mountlist **mlp) if (!xdr_bool(xdrsp, &bool)) return (0); while (bool) { - mp = (struct mountlist *)malloc(sizeof(struct mountlist)); + mp = malloc(sizeof(struct mountlist)); if (mp == NULL) return (0); mp->ml_left = mp->ml_right = (struct mountlist *)0; @@ -313,7 +313,7 @@ xdr_exports(XDR *xdrsp, struct exportslist **exp) if (!xdr_bool(xdrsp, &bool)) return (0); while (bool) { - ep = (struct exportslist *)malloc(sizeof(struct exportslist)); + ep = malloc(sizeof(struct exportslist)); if (ep == NULL) return (0); ep->ex_groups = (struct grouplist *)0; @@ -323,8 +323,7 @@ xdr_exports(XDR *xdrsp, struct exportslist **exp) if (!xdr_bool(xdrsp, &grpbool)) return (0); while (grpbool) { - gp = (struct grouplist *)malloc( - sizeof(struct grouplist)); + gp = malloc(sizeof(struct grouplist)); if (gp == NULL) return (0); strp = gp->gr_name; diff --git a/usr.bin/skeyinit/skeyinit.c b/usr.bin/skeyinit/skeyinit.c index abbba66c07e..92d7f0f6db7 100644 --- a/usr.bin/skeyinit/skeyinit.c +++ b/usr.bin/skeyinit/skeyinit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: skeyinit.c,v 1.57 2015/04/18 18:28:38 deraadt Exp $ */ +/* $OpenBSD: skeyinit.c,v 1.58 2015/08/20 22:32:42 deraadt Exp $ */ /* OpenBSD S/Key (skeyinit.c) * @@ -305,7 +305,7 @@ main(int argc, char **argv) alarm(0); /* XXX - why use malloc here? */ - if ((skey.val = (char *)malloc(16 + 1)) == NULL) + if ((skey.val = malloc(16 + 1)) == NULL) err(1, "Can't allocate memory"); btoa8(skey.val, key); diff --git a/usr.bin/ssh/dns.c b/usr.bin/ssh/dns.c index acbcc2c675c..301d65c5a88 100644 --- a/usr.bin/ssh/dns.c +++ b/usr.bin/ssh/dns.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dns.c,v 1.34 2015/01/28 22:36:00 djm Exp $ */ +/* $OpenBSD: dns.c,v 1.35 2015/08/20 22:32:42 deraadt Exp $ */ /* * Copyright (c) 2003 Wesley Griffin. All rights reserved. @@ -151,7 +151,7 @@ dns_read_rdata(u_int8_t *algorithm, u_int8_t *digest_type, *digest_len = rdata_len - 2; if (*digest_len > 0) { - *digest = (u_char *) xmalloc(*digest_len); + *digest = xmalloc(*digest_len); memcpy(*digest, rdata + 2, *digest_len); } else { *digest = (u_char *)xstrdup(""); diff --git a/usr.bin/ssh/packet.c b/usr.bin/ssh/packet.c index f5f1d4f3e1e..841a15a6834 100644 --- a/usr.bin/ssh/packet.c +++ b/usr.bin/ssh/packet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: packet.c,v 1.213 2015/07/29 04:43:06 djm Exp $ */ +/* $OpenBSD: packet.c,v 1.214 2015/08/20 22:32:42 deraadt Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -1261,7 +1261,7 @@ ssh_packet_read_seqnr(struct ssh *ssh, u_char *typep, u_int32_t *seqnr_p) DBG(debug("packet_read()")); - setp = (fd_set *)calloc(howmany(state->connection_in + 1, + setp = calloc(howmany(state->connection_in + 1, NFDBITS), sizeof(fd_mask)); if (setp == NULL) return SSH_ERR_ALLOC_FAIL; @@ -2023,7 +2023,7 @@ ssh_packet_write_wait(struct ssh *ssh) struct timeval start, timeout, *timeoutp = NULL; struct session_state *state = ssh->state; - setp = (fd_set *)calloc(howmany(state->connection_out + 1, + setp = calloc(howmany(state->connection_out + 1, NFDBITS), sizeof(fd_mask)); if (setp == NULL) return SSH_ERR_ALLOC_FAIL; diff --git a/usr.bin/ssh/sftp-server.c b/usr.bin/ssh/sftp-server.c index 075e7b2ae22..e0ad3e33f44 100644 --- a/usr.bin/ssh/sftp-server.c +++ b/usr.bin/ssh/sftp-server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sftp-server.c,v 1.106 2015/04/24 01:36:01 deraadt Exp $ */ +/* $OpenBSD: sftp-server.c,v 1.107 2015/08/20 22:32:42 deraadt Exp $ */ /* * Copyright (c) 2000-2004 Markus Friedl. All rights reserved. * @@ -1585,8 +1585,8 @@ sftp_server_main(int argc, char **argv, struct passwd *user_pw) fatal("%s: sshbuf_new failed", __func__); set_size = howmany(max + 1, NFDBITS) * sizeof(fd_mask); - rset = (fd_set *)xmalloc(set_size); - wset = (fd_set *)xmalloc(set_size); + rset = xmalloc(set_size); + wset = xmalloc(set_size); if (homedir != NULL) { if (chdir(homedir) != 0) { diff --git a/usr.bin/ssh/sftp.c b/usr.bin/ssh/sftp.c index d13d48d41bf..50e2f5843ce 100644 --- a/usr.bin/ssh/sftp.c +++ b/usr.bin/ssh/sftp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sftp.c,v 1.170 2015/01/20 23:14:00 deraadt Exp $ */ +/* $OpenBSD: sftp.c,v 1.171 2015/08/20 22:32:42 deraadt Exp $ */ /* * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> * @@ -1935,7 +1935,7 @@ complete(EditLine *el, int ch) /* Figure out which argument the cursor points to */ cursor = lf->cursor - lf->buffer; - line = (char *)xmalloc(cursor + 1); + line = xmalloc(cursor + 1); memcpy(line, lf->buffer, cursor); line[cursor] = '\0'; argv = makeargv(line, &carg, 1, "e, &terminated); @@ -1943,7 +1943,7 @@ complete(EditLine *el, int ch) /* Get all the arguments on the line */ len = lf->lastchar - lf->buffer; - line = (char *)xmalloc(len + 1); + line = xmalloc(len + 1); memcpy(line, lf->buffer, len); line[len] = '\0'; argv = makeargv(line, &argc, 1, NULL, NULL); diff --git a/usr.bin/ssh/ssh-pkcs11-helper.c b/usr.bin/ssh/ssh-pkcs11-helper.c index e80bca58384..5e239882e20 100644 --- a/usr.bin/ssh/ssh-pkcs11-helper.c +++ b/usr.bin/ssh/ssh-pkcs11-helper.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh-pkcs11-helper.c,v 1.10 2015/01/20 23:14:00 deraadt Exp $ */ +/* $OpenBSD: ssh-pkcs11-helper.c,v 1.11 2015/08/20 22:32:42 deraadt Exp $ */ /* * Copyright (c) 2010 Markus Friedl. All rights reserved. * @@ -290,8 +290,8 @@ main(int argc, char **argv) buffer_init(&oqueue); set_size = howmany(max + 1, NFDBITS) * sizeof(fd_mask); - rset = (fd_set *)xmalloc(set_size); - wset = (fd_set *)xmalloc(set_size); + rset = xmalloc(set_size); + wset = xmalloc(set_size); for (;;) { memset(rset, 0, set_size); diff --git a/usr.bin/ssh/sshconnect.c b/usr.bin/ssh/sshconnect.c index 9a8dba23107..23dbca1c7f9 100644 --- a/usr.bin/ssh/sshconnect.c +++ b/usr.bin/ssh/sshconnect.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sshconnect.c,v 1.262 2015/05/28 05:41:29 dtucker Exp $ */ +/* $OpenBSD: sshconnect.c,v 1.263 2015/08/20 22:32:42 deraadt Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -346,7 +346,7 @@ timeout_connect(int sockfd, const struct sockaddr *serv_addr, goto done; } - fdset = (fd_set *)xcalloc(howmany(sockfd + 1, NFDBITS), + fdset = xcalloc(howmany(sockfd + 1, NFDBITS), sizeof(fd_mask)); FD_SET(sockfd, fdset); ms_to_timeval(&tv, *timeoutp); diff --git a/usr.bin/ssh/sshd.c b/usr.bin/ssh/sshd.c index 532521438d6..d4ebbbd001d 100644 --- a/usr.bin/ssh/sshd.c +++ b/usr.bin/ssh/sshd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sshd.c,v 1.457 2015/07/30 00:01:34 djm Exp $ */ +/* $OpenBSD: sshd.c,v 1.458 2015/08/20 22:32:42 deraadt Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -1201,7 +1201,7 @@ server_accept_loop(int *sock_in, int *sock_out, int *newsock, int *config_s) sighup_restart(); if (fdset != NULL) free(fdset); - fdset = (fd_set *)xcalloc(howmany(maxfd + 1, NFDBITS), + fdset = xcalloc(howmany(maxfd + 1, NFDBITS), sizeof(fd_mask)); for (i = 0; i < num_listen_socks; i++) diff --git a/usr.bin/systat/pftop.c b/usr.bin/systat/pftop.c index dcaf142e863..33479c5e7b1 100644 --- a/usr.bin/systat/pftop.c +++ b/usr.bin/systat/pftop.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pftop.c,v 1.31 2015/02/09 02:00:38 jsg Exp $ */ +/* $OpenBSD: pftop.c,v 1.32 2015/08/20 22:32:42 deraadt Exp $ */ /* * Copyright (c) 2001, 2007 Can Erkin Acar * Copyright (c) 2001 Daniel Hartmeier @@ -1014,7 +1014,7 @@ alloc_anchor_name(const char *path) a = anchor_free; if (a == NULL) { - a = (struct anchor_name *)malloc(sizeof(struct anchor_name)); + a = malloc(sizeof(struct anchor_name)); if (a == NULL) return (NULL); } else diff --git a/usr.bin/systat/swap.c b/usr.bin/systat/swap.c index b0cf4d1958a..b2840b86a6b 100644 --- a/usr.bin/systat/swap.c +++ b/usr.bin/systat/swap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: swap.c,v 1.26 2015/01/16 00:03:38 deraadt Exp $ */ +/* $OpenBSD: swap.c,v 1.27 2015/08/20 22:32:42 deraadt Exp $ */ /* $NetBSD: swap.c,v 1.9 1998/12/26 07:05:08 marc Exp $ */ /*- @@ -115,7 +115,7 @@ read_sw(void) if (swap_devices) (void)free(swap_devices); - swap_devices = (struct swapent *)calloc(nswap, sizeof(*swap_devices)); + swap_devices = calloc(nswap, sizeof(*swap_devices)); if (swap_devices == NULL) return 0; diff --git a/usr.bin/systat/vmstat.c b/usr.bin/systat/vmstat.c index 6a644946f28..4f53c0b9322 100644 --- a/usr.bin/systat/vmstat.c +++ b/usr.bin/systat/vmstat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmstat.c,v 1.79 2015/01/16 00:03:38 deraadt Exp $ */ +/* $OpenBSD: vmstat.c,v 1.80 2015/08/20 22:32:42 deraadt Exp $ */ /* $NetBSD: vmstat.c,v 1.5 1996/05/10 23:16:40 thorpej Exp $ */ /*- @@ -632,7 +632,7 @@ static void allocinfo(struct Info *si) { memset(si, 0, sizeof(*si)); - si->intrcnt = (u_quad_t *) calloc(nintr, sizeof(u_quad_t)); + si->intrcnt = calloc(nintr, sizeof(u_quad_t)); if (si->intrcnt == NULL) errx(2, "out of memory"); } diff --git a/usr.bin/top/machine.c b/usr.bin/top/machine.c index 5f027d7eb29..9c6aaea20af 100644 --- a/usr.bin/top/machine.c +++ b/usr.bin/top/machine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machine.c,v 1.84 2015/05/06 07:53:29 mpi Exp $ */ +/* $OpenBSD: machine.c,v 1.85 2015/08/20 22:32:42 deraadt Exp $ */ /*- * Copyright (c) 1994 Thorsten Lockert <tholo@sigmasoft.com> @@ -378,8 +378,8 @@ get_process_info(struct system_info *si, struct process_select *sel, quit(23); } if (nproc > onproc) - pref = (struct kinfo_proc **)realloc(pref, - sizeof(struct kinfo_proc *) * (onproc = nproc)); + pref = reallocarray(pref, (onproc = nproc), + sizeof(struct kinfo_proc *)); if (pref == NULL) { warnx("Out of memory."); quit(23); diff --git a/usr.bin/unifdef/unifdef.c b/usr.bin/unifdef/unifdef.c index fa751572814..bd414b8361f 100644 --- a/usr.bin/unifdef/unifdef.c +++ b/usr.bin/unifdef/unifdef.c @@ -1518,7 +1518,7 @@ astrcat(const char *s1, const char *s2) if (len < 0) err(2, "snprintf"); size = (size_t)len + 1; - s = (char *)malloc(size); + s = malloc(size); if (s == NULL) err(2, "malloc"); snprintf(s, size, "%s%s", s1, s2); diff --git a/usr.bin/vacation/vacation.c b/usr.bin/vacation/vacation.c index 8d5ca580176..4786546faee 100644 --- a/usr.bin/vacation/vacation.c +++ b/usr.bin/vacation/vacation.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vacation.c,v 1.36 2015/03/15 00:41:28 millert Exp $ */ +/* $OpenBSD: vacation.c,v 1.37 2015/08/20 22:32:42 deraadt Exp $ */ /* $NetBSD: vacation.c,v 1.7 1995/04/29 05:58:27 cgd Exp $ */ /* @@ -98,7 +98,7 @@ main(int argc, char *argv[]) while ((ch = getopt(argc, argv, "a:Iir:")) != -1) switch ((char)ch) { case 'a': /* alias */ - if (!(cur = (ALIAS *)malloc((u_int)sizeof(ALIAS)))) + if (!(cur = malloc(sizeof(ALIAS)))) break; cur->name = optarg; cur->next = names; @@ -162,7 +162,7 @@ main(int argc, char *argv[]) exit(0); } - if (!(cur = malloc((u_int)sizeof(ALIAS)))) + if (!(cur = malloc(sizeof(ALIAS)))) exit(1); cur->name = pw->pw_name; cur->next = names; diff --git a/usr.bin/wall/wall.c b/usr.bin/wall/wall.c index b44d1cffa5c..e2e4bb8b0dd 100644 --- a/usr.bin/wall/wall.c +++ b/usr.bin/wall/wall.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wall.c,v 1.26 2015/01/16 06:40:14 deraadt Exp $ */ +/* $OpenBSD: wall.c,v 1.27 2015/08/20 22:32:42 deraadt Exp $ */ /* $NetBSD: wall.c,v 1.6 1994/11/17 07:17:58 jtc Exp $ */ /* @@ -235,12 +235,12 @@ addgroup(struct group *grp, char *name) for (i = 0; grp->gr_mem[i]; i++) ; - g = (struct wallgroup *)malloc(sizeof *g); + g = malloc(sizeof *g); if (g == NULL) err(1, NULL); g->gid = grp->gr_gid; g->name = name; - g->mem = (char **)calloc(i + 1, sizeof(char *)); + g->mem = calloc(i + 1, sizeof(char *)); if (g->mem == NULL) err(1, NULL); for (i = 0; grp->gr_mem[i] != NULL; i++) { |