diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-08-20 22:02:22 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-08-20 22:02:22 +0000 |
commit | 999d668af49ba65ca209316fb879a8459e9f850e (patch) | |
tree | c9473babdf7ff29e941f183a4a1929fba6c63699 | |
parent | 9e6263b04dc3a7a8ef2f02175efe20fe4ab2097a (diff) |
<stdlib.h> is included, so do not need to cast result from
malloc, calloc, realloc*
ok krw millert
39 files changed, 130 insertions, 153 deletions
diff --git a/sbin/atactl/atactl.c b/sbin/atactl/atactl.c index 8d6263a81e3..625e16f3087 100644 --- a/sbin/atactl/atactl.c +++ b/sbin/atactl/atactl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: atactl.c,v 1.45 2015/01/16 06:39:56 deraadt Exp $ */ +/* $OpenBSD: atactl.c,v 1.46 2015/08/20 22:02:20 deraadt Exp $ */ /* $NetBSD: atactl.c,v 1.4 1999/02/24 18:49:14 jwise Exp $ */ /*- @@ -1461,7 +1461,7 @@ device_smart_readlog(int argc, char *argv[]) * the latest one. */ nsect = nerr / 5 + (nerr % 5 != 0 ? 1 : 0); - if ((newbuf = (u_int8_t *)calloc(nsect, DEV_BSIZE)) == NULL) + if ((newbuf = calloc(nsect, DEV_BSIZE)) == NULL) err(1, "calloc()"); memset(&req, 0, sizeof(req)); req.flags = ATACMD_READ; diff --git a/sbin/disklabel/disklabel.c b/sbin/disklabel/disklabel.c index 77b9f1be578..832e6d467bf 100644 --- a/sbin/disklabel/disklabel.c +++ b/sbin/disklabel/disklabel.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disklabel.c,v 1.203 2015/08/15 17:16:10 krw Exp $ */ +/* $OpenBSD: disklabel.c,v 1.204 2015/08/20 22:02:20 deraadt Exp $ */ /* * Copyright (c) 1987, 1993 @@ -573,7 +573,7 @@ makebootarea(char *boot, struct disklabel *dp) if (bootsize > 0) { /* XXX assume d_secsize is a power of two */ bootsize = (bootsize + dp->d_secsize-1) & ~(dp->d_secsize-1); - bootbuf = (char *)malloc((size_t)bootsize); + bootbuf = malloc((size_t)bootsize); if (bootbuf == NULL) err(4, "%s", xxboot); if (read(b, bootbuf, bootsize) < 0) { diff --git a/sbin/dump/itime.c b/sbin/dump/itime.c index af38cbc2414..18eaf5859aa 100644 --- a/sbin/dump/itime.c +++ b/sbin/dump/itime.c @@ -1,4 +1,4 @@ -/* $OpenBSD: itime.c,v 1.21 2015/05/23 05:17:20 guenther Exp $ */ +/* $OpenBSD: itime.c,v 1.22 2015/08/20 22:02:20 deraadt Exp $ */ /* $NetBSD: itime.c,v 1.4 1997/04/15 01:09:50 lukem Exp $ */ /*- @@ -96,7 +96,7 @@ readdumptimes(FILE *df) struct dumptime *dtwalk; for (;;) { - dtwalk = (struct dumptime *)calloc(1, sizeof(struct dumptime)); + dtwalk = calloc(1, sizeof(struct dumptime)); if (getrecord(df, &(dtwalk->dt_value)) < 0) { free(dtwalk); break; @@ -111,8 +111,7 @@ readdumptimes(FILE *df) * arrayify the list, leaving enough room for the additional * record that we may have to add to the ddate structure */ - ddatev = (struct dumpdates **) - calloc((unsigned) (nddates + 1), sizeof(struct dumpdates *)); + ddatev = calloc((unsigned) (nddates + 1), sizeof(struct dumpdates *)); dtwalk = dthead; for (i = nddates - 1; i >= 0; i--, dtwalk = dtwalk->dt_next) ddatev[i] = &dtwalk->dt_value; @@ -190,8 +189,7 @@ putdumptime(void) * construct the new upper bound; * Enough room has been allocated. */ - dtwalk = ddatev[nddates] = - (struct dumpdates *)calloc(1, sizeof(struct dumpdates)); + dtwalk = ddatev[nddates] = calloc(1, sizeof(struct dumpdates)); nddates += 1; found: (void) strlcpy(dtwalk->dd_name, fname, sizeof(dtwalk->dd_name)); diff --git a/sbin/dump/main.c b/sbin/dump/main.c index 93bcfc3c4ad..59fbbc21281 100644 --- a/sbin/dump/main.c +++ b/sbin/dump/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.56 2015/05/23 05:17:20 guenther Exp $ */ +/* $OpenBSD: main.c,v 1.57 2015/08/20 22:02:20 deraadt Exp $ */ /* $NetBSD: main.c,v 1.14 1997/06/05 11:13:24 lukem Exp $ */ /*- @@ -450,9 +450,9 @@ main(int argc, char *argv[]) #endif maxino = sblock->fs_ipg * sblock->fs_ncg; mapsize = roundup(howmany(maxino, NBBY), TP_BSIZE); - usedinomap = (char *)calloc((unsigned) mapsize, sizeof(char)); - dumpdirmap = (char *)calloc((unsigned) mapsize, sizeof(char)); - dumpinomap = (char *)calloc((unsigned) mapsize, sizeof(char)); + usedinomap = calloc((unsigned) mapsize, sizeof(char)); + dumpdirmap = calloc((unsigned) mapsize, sizeof(char)); + dumpinomap = calloc((unsigned) mapsize, sizeof(char)); tapesize = 3 * (howmany(mapsize * sizeof(char), TP_BSIZE) + 1); nonodump = spcl.c_level < honorlevel; diff --git a/sbin/dump/optr.c b/sbin/dump/optr.c index 10aa0232325..37a802b460b 100644 --- a/sbin/dump/optr.c +++ b/sbin/dump/optr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: optr.c,v 1.37 2015/05/23 05:17:20 guenther Exp $ */ +/* $OpenBSD: optr.c,v 1.38 2015/08/20 22:02:20 deraadt Exp $ */ /* $NetBSD: optr.c,v 1.11 1997/05/27 08:34:36 mrg Exp $ */ /*- @@ -274,7 +274,7 @@ allocfsent(struct fstab *fs) { struct fstab *new; - new = (struct fstab *)malloc(sizeof(*fs)); + new = malloc(sizeof(*fs)); if (new == NULL || (new->fs_file = strdup(fs->fs_file)) == NULL || (new->fs_type = strdup(fs->fs_type)) == NULL || @@ -312,7 +312,7 @@ getfstab(void) strcmp(fs->fs_type, FSTAB_RQ)) continue; fs = allocfsent(fs); - if ((pf = (struct pfstab *)malloc(sizeof(*pf))) == NULL) + if ((pf = malloc(sizeof(*pf))) == NULL) quit("%s\n", strerror(errno)); pf->pf_fstab = fs; pf->pf_next = table; diff --git a/sbin/dump/tape.c b/sbin/dump/tape.c index 79280df84e7..dc0eaf1d3bb 100644 --- a/sbin/dump/tape.c +++ b/sbin/dump/tape.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tape.c,v 1.42 2015/01/20 18:22:20 deraadt Exp $ */ +/* $OpenBSD: tape.c,v 1.43 2015/08/20 22:02:20 deraadt Exp $ */ /* $NetBSD: tape.c,v 1.11 1997/06/05 11:13:26 lukem Exp $ */ /*- @@ -138,8 +138,7 @@ alloctape(void) * Align tape buffer on page boundary to speed up tape write(). */ for (i = 0; i <= SLAVES; i++) { - buf = (char *) - malloc((unsigned)(reqsiz + writesize + pgoff + TP_BSIZE)); + buf = malloc((unsigned)(reqsiz + writesize + pgoff + TP_BSIZE)); if (buf == NULL) return(0); slaves[i].tblock = (char (*)[TP_BSIZE]) diff --git a/sbin/fsck_ext2fs/pass1.c b/sbin/fsck_ext2fs/pass1.c index 608d45e3f37..020da5f0f1f 100644 --- a/sbin/fsck_ext2fs/pass1.c +++ b/sbin/fsck_ext2fs/pass1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass1.c,v 1.15 2015/01/16 06:39:57 deraadt Exp $ */ +/* $OpenBSD: pass1.c,v 1.16 2015/08/20 22:02:20 deraadt Exp $ */ /* $NetBSD: pass1.c,v 1.9 2000/01/31 11:40:12 bouyer Exp $ */ /* @@ -239,7 +239,7 @@ checkinode(ino_t inumber, struct inodesc *idesc) n_files++; lncntp[inumber] = letoh16(dp->e2di_nlink); if (dp->e2di_nlink == 0) { - zlnp = (struct zlncnt *)malloc(sizeof *zlnp); + zlnp = malloc(sizeof *zlnp); if (zlnp == NULL) { pfatal("LINK COUNT TABLE OVERFLOW"); if (reply("CONTINUE") == 0) @@ -326,7 +326,7 @@ pass1check(struct inodesc *idesc) errexit("%s\n", ""); return (STOP); } - new = (struct dups *)malloc(sizeof(struct dups)); + new = malloc(sizeof(struct dups)); if (new == NULL) { pfatal("DUP TABLE OVERFLOW."); if (reply("CONTINUE") == 0) diff --git a/sbin/fsck_ext2fs/setup.c b/sbin/fsck_ext2fs/setup.c index 7f2404f5f28..32d7e62ef63 100644 --- a/sbin/fsck_ext2fs/setup.c +++ b/sbin/fsck_ext2fs/setup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: setup.c,v 1.25 2015/01/16 06:39:57 deraadt Exp $ */ +/* $OpenBSD: setup.c,v 1.26 2015/08/20 22:02:20 deraadt Exp $ */ /* $NetBSD: setup.c,v 1.1 1997/06/11 11:22:01 bouyer Exp $ */ /* @@ -218,7 +218,7 @@ setup(char *dev) (unsigned)(maxino + 1)); goto badsblabel; } - lncntp = (int16_t *)calloc((unsigned)(maxino + 1), sizeof(int16_t)); + lncntp = calloc((unsigned)(maxino + 1), sizeof(int16_t)); if (lncntp == NULL) { printf("cannot alloc %u bytes for lncntp\n", (unsigned)((maxino + 1) * sizeof(int16_t))); @@ -229,10 +229,8 @@ setup(char *dev) } inplast = 0; listmax = numdirs + 10; - inpsort = (struct inoinfo **)calloc((unsigned)listmax, - sizeof(struct inoinfo *)); - inphead = (struct inoinfo **)calloc((unsigned)numdirs, - sizeof(struct inoinfo *)); + inpsort = calloc((unsigned)listmax, sizeof(struct inoinfo *)); + inphead = calloc((unsigned)numdirs, sizeof(struct inoinfo *)); if (inpsort == NULL || inphead == NULL) { printf("cannot alloc %u bytes for inphead\n", (unsigned)(numdirs * sizeof(struct inoinfo *))); diff --git a/sbin/fsck_ext2fs/utilities.c b/sbin/fsck_ext2fs/utilities.c index 3eb2daa4753..89b6c4d4f6a 100644 --- a/sbin/fsck_ext2fs/utilities.c +++ b/sbin/fsck_ext2fs/utilities.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utilities.c,v 1.24 2015/01/16 06:39:57 deraadt Exp $ */ +/* $OpenBSD: utilities.c,v 1.25 2015/08/20 22:02:20 deraadt Exp $ */ /* $NetBSD: utilities.c,v 1.6 2001/02/04 21:19:34 christos Exp $ */ /* @@ -127,7 +127,7 @@ bufinit(void) if (bufcnt < MINBUFS) bufcnt = MINBUFS; for (i = 0; i < bufcnt; i++) { - bp = (struct bufarea *)malloc(sizeof(struct bufarea)); + bp = malloc(sizeof(struct bufarea)); bufp = malloc((unsigned int)sblock.e2fs_bsize); if (bp == NULL || bufp == NULL) { free(bp); diff --git a/sbin/fsck_msdos/dir.c b/sbin/fsck_msdos/dir.c index 39c6ff35ce1..75cd23bf16d 100644 --- a/sbin/fsck_msdos/dir.c +++ b/sbin/fsck_msdos/dir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dir.c,v 1.28 2015/01/16 06:39:58 deraadt Exp $ */ +/* $OpenBSD: dir.c,v 1.29 2015/08/20 22:02:21 deraadt Exp $ */ /* $NetBSD: dir.c,v 1.11 1997/10/17 11:19:35 ws Exp $ */ /* @@ -103,7 +103,7 @@ newDosDirEntry(void) struct dosDirEntry *de; if (!(de = freede)) { - if (!(de = (struct dosDirEntry *)malloc(sizeof *de))) + if (!(de = malloc(sizeof *de))) return (0); } else freede = de->next; @@ -128,7 +128,7 @@ newDirTodo(void) struct dirTodoNode *dt; if (!(dt = freedt)) { - if (!(dt = (struct dirTodoNode *)malloc(sizeof *dt))) + if (!(dt = malloc(sizeof *dt))) return (0); } else freedt = dt->next; diff --git a/sbin/growfs/growfs.c b/sbin/growfs/growfs.c index d64891a2599..e809e33dcdf 100644 --- a/sbin/growfs/growfs.c +++ b/sbin/growfs/growfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: growfs.c,v 1.39 2015/04/18 18:28:37 deraadt Exp $ */ +/* $OpenBSD: growfs.c,v 1.40 2015/08/20 22:02:21 deraadt Exp $ */ /* * Copyright (c) 2000 Christoph Herrmann, Thomas-Henning von Kamptz * Copyright (c) 1980, 1989, 1993 The Regents of the University of California. @@ -1240,7 +1240,7 @@ updcsloc(time_t utime, int fsi, int fso, unsigned int Nflag) /* * Allocate the space for the array of blocks to be relocated. */ - bp = (struct gfs_bpp *)calloc(((dupper-odupper) / sblock.fs_frag + 2), + bp = calloc(((dupper-odupper) / sblock.fs_frag + 2), sizeof(struct gfs_bpp)); if (bp == NULL) errx(1, "calloc failed"); @@ -2211,7 +2211,7 @@ get_disklabel(int fd) DBG_ENTER; - lab = (struct disklabel *)malloc(sizeof(struct disklabel)); + lab = malloc(sizeof(struct disklabel)); if (!lab) errx(1, "malloc failed"); if (ioctl(fd, DIOCGDINFO, (char *)lab) != 0) diff --git a/sbin/init/init.c b/sbin/init/init.c index 210ee739375..9d35d99a94d 100644 --- a/sbin/init/init.c +++ b/sbin/init/init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init.c,v 1.53 2015/07/14 19:14:05 millert Exp $ */ +/* $OpenBSD: init.c,v 1.54 2015/08/20 22:02:21 deraadt Exp $ */ /* $NetBSD: init.c,v 1.22 1996/05/15 23:29:33 jtc Exp $ */ /*- @@ -834,8 +834,7 @@ char ** construct_argv(char *command) { int argc = 0; - char **argv = (char **) calloc((strlen(command) + 1) / 2 + 1, - sizeof (char *)); + char **argv = calloc((strlen(command) + 1) / 2 + 1, sizeof (char *)); static const char separators[] = " \t"; if (argv == NULL) diff --git a/sbin/isakmpd/conf.c b/sbin/isakmpd/conf.c index 4a80b426113..ea236da22c9 100644 --- a/sbin/isakmpd/conf.c +++ b/sbin/isakmpd/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.103 2013/11/22 04:12:47 deraadt Exp $ */ +/* $OpenBSD: conf.c,v 1.104 2015/08/20 22:02:21 deraadt Exp $ */ /* $EOM: conf.c,v 1.48 2000/12/04 02:04:29 angelos Exp $ */ /* @@ -978,7 +978,7 @@ conf_report(void) char *current_section = (char *)0; struct dumper *dumper, *dnode; - dumper = dnode = (struct dumper *)calloc(1, sizeof *dumper); + dumper = dnode = calloc(1, sizeof *dumper); if (!dumper) goto mem_fail; @@ -995,17 +995,15 @@ conf_report(void) if (asprintf(&dnode->s, "[%s]", current_section) == -1) goto mem_fail; - dnode->next = (struct dumper *) - calloc(1, - sizeof(struct dumper)); + dnode->next = calloc(1, + sizeof(struct dumper)); dnode = dnode->next; if (!dnode) goto mem_fail; dnode->s = ""; - dnode->next = (struct dumper *) - calloc(1, - sizeof(struct dumper)); + dnode->next = calloc(1, + sizeof(struct dumper)); dnode = dnode->next; if (!dnode) goto mem_fail; @@ -1014,8 +1012,7 @@ conf_report(void) } dnode->s = cb->tag; dnode->v = cb->value; - dnode->next = (struct dumper *) - calloc(1, sizeof(struct dumper)); + dnode->next = calloc(1, sizeof(struct dumper)); dnode = dnode->next; if (!dnode) goto mem_fail; diff --git a/sbin/isakmpd/dnssec.c b/sbin/isakmpd/dnssec.c index ab7fc32f696..5704bc8e08b 100644 --- a/sbin/isakmpd/dnssec.c +++ b/sbin/isakmpd/dnssec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dnssec.c,v 1.24 2015/01/16 06:39:58 deraadt Exp $ */ +/* $OpenBSD: dnssec.c,v 1.25 2015/08/20 22:02:21 deraadt Exp $ */ /* * Copyright (c) 2001 Håkan Olsson. All rights reserved. @@ -215,7 +215,7 @@ dns_get_key(int type, struct message *msg, int *keylen) continue; } /* This key seems to fit our requirements... */ - key_rr.data = (char *)malloc(key_rr.datalen); + key_rr.data = malloc(key_rr.datalen); if (!key_rr.data) { log_error("dns_get_key: malloc (%d) failed", key_rr.datalen); diff --git a/sbin/isakmpd/ike_phase_1.c b/sbin/isakmpd/ike_phase_1.c index 76f4bd72321..594f608da18 100644 --- a/sbin/isakmpd/ike_phase_1.c +++ b/sbin/isakmpd/ike_phase_1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ike_phase_1.c,v 1.74 2015/02/15 01:56:42 tedu Exp $ */ +/* $OpenBSD: ike_phase_1.c,v 1.75 2015/08/20 22:02:21 deraadt Exp $ */ /* $EOM: ike_phase_1.c,v 1.31 2000/12/11 23:47:56 niklas Exp $ */ /* @@ -284,11 +284,11 @@ ike_phase_1_initiator_send_SA(struct message *msg) proto->xf_cnt = conf->cnt; TAILQ_INIT(&proto->xfs); for (i = 0; i < proto->xf_cnt; i++) { - pa = (struct proto_attr *)calloc(1, sizeof *pa); + pa = calloc(1, sizeof *pa); if (!pa) goto bail_out; pa->len = transform_len[i]; - pa->attrs = (u_int8_t *)malloc(pa->len); + pa->attrs = malloc(pa->len); if (!pa->attrs) { free(pa); goto bail_out; diff --git a/sbin/isakmpd/ike_quick_mode.c b/sbin/isakmpd/ike_quick_mode.c index 0db67a47356..2e2dac23ae7 100644 --- a/sbin/isakmpd/ike_quick_mode.c +++ b/sbin/isakmpd/ike_quick_mode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ike_quick_mode.c,v 1.108 2014/10/09 02:38:56 deraadt Exp $ */ +/* $OpenBSD: ike_quick_mode.c,v 1.109 2015/08/20 22:02:21 deraadt Exp $ */ /* $EOM: ike_quick_mode.c,v 1.139 2001/01/26 10:43:17 niklas Exp $ */ /* @@ -756,8 +756,7 @@ initiator_send_HASH_SA_NONCE(struct message *msg) proto->xf_cnt = transform_cnt[prop_no]; TAILQ_INIT(&proto->xfs); for (xf_no = 0; xf_no < proto->xf_cnt; xf_no++) { - pa = (struct proto_attr *)calloc(1, - sizeof *pa); + pa = calloc(1, sizeof *pa); if (!pa) { if (proto->data) free(proto->data); @@ -765,7 +764,7 @@ initiator_send_HASH_SA_NONCE(struct message *msg) goto bail_out; } pa->len = transform_len[prop_no][xf_no]; - pa->attrs = (u_int8_t *)malloc(pa->len); + pa->attrs = malloc(pa->len); if (!pa->attrs) { if (proto->data) free(proto->data); diff --git a/sbin/isakmpd/ipsec.c b/sbin/isakmpd/ipsec.c index 4a415a70819..4585a3ad57d 100644 --- a/sbin/isakmpd/ipsec.c +++ b/sbin/isakmpd/ipsec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ipsec.c,v 1.143 2015/01/16 06:39:58 deraadt Exp $ */ +/* $OpenBSD: ipsec.c,v 1.144 2015/08/20 22:02:21 deraadt Exp $ */ /* $EOM: ipsec.c,v 1.143 2000/12/11 23:57:42 niklas Exp $ */ /* @@ -623,15 +623,13 @@ ipsec_set_network(u_int8_t *src_id, u_int8_t *dst_id, struct sa *sa) /* Set source address/mask. */ switch (src_af) { case AF_INET: - isa->src_net = (struct sockaddr *)calloc(1, - sizeof(struct sockaddr_in)); + isa->src_net = calloc(1, sizeof(struct sockaddr_in)); if (!isa->src_net) goto memfail; isa->src_net->sa_family = AF_INET; isa->src_net->sa_len = sizeof(struct sockaddr_in); - isa->src_mask = (struct sockaddr *)calloc(1, - sizeof(struct sockaddr_in)); + isa->src_mask = calloc(1, sizeof(struct sockaddr_in)); if (!isa->src_mask) goto memfail; isa->src_mask->sa_family = AF_INET; @@ -639,15 +637,13 @@ ipsec_set_network(u_int8_t *src_id, u_int8_t *dst_id, struct sa *sa) break; case AF_INET6: - isa->src_net = (struct sockaddr *)calloc(1, - sizeof(struct sockaddr_in6)); + isa->src_net = calloc(1, sizeof(struct sockaddr_in6)); if (!isa->src_net) goto memfail; isa->src_net->sa_family = AF_INET6; isa->src_net->sa_len = sizeof(struct sockaddr_in6); - isa->src_mask = (struct sockaddr *)calloc(1, - sizeof(struct sockaddr_in6)); + isa->src_mask = calloc(1, sizeof(struct sockaddr_in6)); if (!isa->src_mask) goto memfail; isa->src_mask->sa_family = AF_INET6; @@ -677,15 +673,13 @@ ipsec_set_network(u_int8_t *src_id, u_int8_t *dst_id, struct sa *sa) /* Set destination address. */ switch (dst_af) { case AF_INET: - isa->dst_net = (struct sockaddr *)calloc(1, - sizeof(struct sockaddr_in)); + isa->dst_net = calloc(1, sizeof(struct sockaddr_in)); if (!isa->dst_net) goto memfail; isa->dst_net->sa_family = AF_INET; isa->dst_net->sa_len = sizeof(struct sockaddr_in); - isa->dst_mask = (struct sockaddr *)calloc(1, - sizeof(struct sockaddr_in)); + isa->dst_mask = calloc(1, sizeof(struct sockaddr_in)); if (!isa->dst_mask) goto memfail; isa->dst_mask->sa_family = AF_INET; @@ -693,15 +687,13 @@ ipsec_set_network(u_int8_t *src_id, u_int8_t *dst_id, struct sa *sa) break; case AF_INET6: - isa->dst_net = (struct sockaddr *)calloc(1, - sizeof(struct sockaddr_in6)); + isa->dst_net = calloc(1, sizeof(struct sockaddr_in6)); if (!isa->dst_net) goto memfail; isa->dst_net->sa_family = AF_INET6; isa->dst_net->sa_len = sizeof(struct sockaddr_in6); - isa->dst_mask = (struct sockaddr *)calloc(1, - sizeof(struct sockaddr_in6)); + isa->dst_mask = calloc(1, sizeof(struct sockaddr_in6)); if (!isa->dst_mask) goto memfail; isa->dst_mask->sa_family = AF_INET6; @@ -1734,7 +1726,7 @@ ipsec_handle_leftover_payload(struct message *msg, u_int8_t type, spisz, proto); return -1; } - spis = (u_int8_t *) calloc(nspis, spisz); + spis = calloc(nspis, spisz); if (!spis) { log_error("ipsec_handle_leftover_payload: malloc " "(%d) failed", nspis * spisz); diff --git a/sbin/isakmpd/isakmpd.c b/sbin/isakmpd/isakmpd.c index a6669340362..5d30e63e7e3 100644 --- a/sbin/isakmpd/isakmpd.c +++ b/sbin/isakmpd/isakmpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: isakmpd.c,v 1.102 2015/02/07 02:09:13 deraadt Exp $ */ +/* $OpenBSD: isakmpd.c,v 1.103 2015/08/20 22:02:21 deraadt Exp $ */ /* $EOM: isakmpd.c,v 1.54 2000/10/05 09:28:22 niklas Exp $ */ /* @@ -418,11 +418,11 @@ main(int argc, char *argv[]) /* Allocate the file descriptor sets just big enough. */ n = getdtablesize(); mask_size = howmany(n, NFDBITS) * sizeof(fd_mask); - rfds = (fd_set *) malloc(mask_size); + rfds = malloc(mask_size); if (!rfds) log_fatal("main: malloc (%lu) failed", (unsigned long)mask_size); - wfds = (fd_set *) malloc(mask_size); + wfds = malloc(mask_size); if (!wfds) log_fatal("main: malloc (%lu) failed", (unsigned long)mask_size); diff --git a/sbin/isakmpd/message.c b/sbin/isakmpd/message.c index c1619142bfa..30d8e718211 100644 --- a/sbin/isakmpd/message.c +++ b/sbin/isakmpd/message.c @@ -1,4 +1,4 @@ -/* $OpenBSD: message.c,v 1.127 2014/10/09 02:38:56 deraadt Exp $ */ +/* $OpenBSD: message.c,v 1.128 2015/08/20 22:02:21 deraadt Exp $ */ /* $EOM: message.c,v 1.156 2000/10/10 12:36:39 provos Exp $ */ /* @@ -119,7 +119,7 @@ message_alloc(struct transport *t, u_int8_t *buf, size_t sz) * We use calloc(3) because it zeroes the structure which we rely on in * message_free when determining what sub-allocations to free. */ - msg = (struct message *)calloc(1, sizeof *msg); + msg = calloc(1, sizeof *msg); if (!msg) return 0; msg->iov = calloc(1, sizeof *msg->iov); @@ -140,8 +140,7 @@ message_alloc(struct transport *t, u_int8_t *buf, size_t sz) ISAKMP_HDR_NEXT_PAYLOAD_OFF; msg->transport = t; transport_reference(t); - msg->payload = (struct payload_head *)calloc(ISAKMP_PAYLOAD_MAX, - sizeof *msg->payload); + msg->payload = calloc(ISAKMP_PAYLOAD_MAX, sizeof *msg->payload); if (!msg->payload) { message_free(msg); return 0; diff --git a/sbin/isakmpd/monitor.c b/sbin/isakmpd/monitor.c index 4d4737f1e4e..5a8fb910262 100644 --- a/sbin/isakmpd/monitor.c +++ b/sbin/isakmpd/monitor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: monitor.c,v 1.73 2015/01/16 06:39:59 deraadt Exp $ */ +/* $OpenBSD: monitor.c,v 1.74 2015/08/20 22:02:21 deraadt Exp $ */ /* * Copyright (c) 2003 Håkan Olsson. All rights reserved. @@ -555,7 +555,7 @@ m_priv_setsockopt(void) must_read(&optname, sizeof optname); must_read(&optlen, sizeof optlen); - optval = (char *)malloc(optlen); + optval = malloc(optlen); if (!optval) { log_print("m_priv_setsockopt: malloc failed"); close(sock); @@ -598,7 +598,7 @@ m_priv_bind(void) } must_read(&namelen, sizeof namelen); - name = (struct sockaddr *)malloc(namelen); + name = malloc(namelen); if (!name) { log_print("m_priv_bind: malloc failed"); close(sock); diff --git a/sbin/isakmpd/nat_traversal.c b/sbin/isakmpd/nat_traversal.c index 0f99a21c085..d85c2a68790 100644 --- a/sbin/isakmpd/nat_traversal.c +++ b/sbin/isakmpd/nat_traversal.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nat_traversal.c,v 1.22 2014/11/19 13:35:37 krw Exp $ */ +/* $OpenBSD: nat_traversal.c,v 1.23 2015/08/20 22:02:21 deraadt Exp $ */ /* * Copyright (c) 2004 Håkan Olsson. All rights reserved. @@ -106,7 +106,7 @@ nat_t_setup_hashes(void) /* Populate isakmp_nat_t_cap with hashes. */ for (i = 0; i < n; i++) { isakmp_nat_t_cap[i].hashsize = hash->hashsize; - isakmp_nat_t_cap[i].hash = (char *)malloc(hash->hashsize); + isakmp_nat_t_cap[i].hash = malloc(hash->hashsize); if (!isakmp_nat_t_cap[i].hash) { log_error("nat_t_setup_hashes: malloc (%lu) failed", (unsigned long)hash->hashsize); @@ -227,7 +227,7 @@ nat_t_generate_nat_d_hash(struct message *msg, struct sockaddr *sa, *hashlen = hash->hashsize; - res = (u_int8_t *)malloc((unsigned long)*hashlen); + res = malloc((unsigned long)*hashlen); if (!res) { log_print("nat_t_generate_nat_d_hash: malloc (%lu) failed", (unsigned long)*hashlen); diff --git a/sbin/isakmpd/pf_key_v2.c b/sbin/isakmpd/pf_key_v2.c index 0a03b0c3e84..af3314d7fe8 100644 --- a/sbin/isakmpd/pf_key_v2.c +++ b/sbin/isakmpd/pf_key_v2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pf_key_v2.c,v 1.194 2015/04/17 10:04:37 mikeb Exp $ */ +/* $OpenBSD: pf_key_v2.c,v 1.195 2015/08/20 22:02:21 deraadt Exp $ */ /* $EOM: pf_key_v2.c,v 1.79 2000/12/12 00:33:19 niklas Exp $ */ /* @@ -326,7 +326,7 @@ pf_key_v2_write(struct pf_key_v2_msg *pmsg) struct sadb_msg *msg = TAILQ_FIRST(pmsg)->seg; struct pf_key_v2_node *np = TAILQ_FIRST(pmsg); - iov = (struct iovec *) calloc(cnt, sizeof *iov); + iov = calloc(cnt, sizeof *iov); if (!iov) { log_error("pf_key_v2_write: malloc (%lu) failed", cnt * (unsigned long) sizeof *iov); @@ -686,7 +686,7 @@ pf_key_v2_get_kernel_sa(u_int8_t *spi, size_t spi_sz, u_int8_t proto, goto cleanup; /* SPI */ - ssa = (struct sadb_sa *)calloc(1, sizeof *ssa); + ssa = calloc(1, sizeof *ssa); if (!ssa) { log_print("pf_key_v2_get_kernel_sa: calloc(1, %lu) failed", (unsigned long)sizeof *ssa); @@ -1378,7 +1378,7 @@ nodid: /* Add a pf tag to matching packets of this SA. */ if (sa->tag != NULL) { len = sizeof(*stag) + PF_KEY_V2_ROUND(strlen(sa->tag) + 1); - if ((stag = (struct sadb_x_tag *)calloc(1, len)) == NULL) + if ((stag = calloc(1, len)) == NULL) goto cleanup; stag->sadb_x_tag_exttype = SADB_X_EXT_TAG; stag->sadb_x_tag_len = len / PF_KEY_V2_CHUNK; diff --git a/sbin/isakmpd/sa.c b/sbin/isakmpd/sa.c index c5533b0bb6a..d88cda8ab6d 100644 --- a/sbin/isakmpd/sa.c +++ b/sbin/isakmpd/sa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sa.c,v 1.121 2014/10/09 02:38:56 deraadt Exp $ */ +/* $OpenBSD: sa.c,v 1.122 2015/08/20 22:02:21 deraadt Exp $ */ /* $EOM: sa.c,v 1.112 2000/12/12 00:22:52 niklas Exp $ */ /* @@ -1038,7 +1038,7 @@ sa_validate_proto_xf(struct proto *match, struct payload *xf, int phase) "protocol mismatch", match, match->no)); return 1; } - avs = (struct attr_validation_state *)calloc(1, sizeof *avs); + avs = calloc(1, sizeof *avs); if (!avs) { log_error("sa_validate_proto_xf: calloc (1, %lu)", (unsigned long)sizeof *avs); diff --git a/sbin/isakmpd/timer.c b/sbin/isakmpd/timer.c index 4533ff1a20f..614ac6fa44b 100644 --- a/sbin/isakmpd/timer.c +++ b/sbin/isakmpd/timer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: timer.c,v 1.16 2013/04/02 03:06:18 guenther Exp $ */ +/* $OpenBSD: timer.c,v 1.17 2015/08/20 22:02:21 deraadt Exp $ */ /* $EOM: timer.c,v 1.13 2000/02/20 19:58:42 niklas Exp $ */ /* @@ -82,7 +82,7 @@ struct event * timer_add_event(char *name, void (*func)(void *), void *arg, struct timeval *expiration) { - struct event *ev = (struct event *) malloc(sizeof *ev); + struct event *ev = malloc(sizeof *ev); struct event *n; struct timeval now; diff --git a/sbin/isakmpd/udp_encap.c b/sbin/isakmpd/udp_encap.c index 8b67e2df3bf..ae20f98fada 100644 --- a/sbin/isakmpd/udp_encap.c +++ b/sbin/isakmpd/udp_encap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udp_encap.c,v 1.22 2014/01/22 03:09:31 deraadt Exp $ */ +/* $OpenBSD: udp_encap.c,v 1.23 2015/08/20 22:02:21 deraadt Exp $ */ /* * Copyright (c) 1998, 1999, 2001 Niklas Hallqvist. All rights reserved. @@ -111,7 +111,7 @@ udp_encap_make(struct sockaddr *laddr) t = calloc(1, sizeof *t); if (!t) { - log_print("udp_encap_make: malloc (%lu) failed", + log_print("udp_encap_make: malloc(%lu) failed", (unsigned long)sizeof *t); free(laddr); return 0; @@ -421,11 +421,10 @@ udp_encap_send_message(struct message *msg, struct transport *t) if (msg) { /* Construct new iov array, prefixing NULL-ESP Marker. */ - new_iov = (struct iovec *)calloc (msg->iovlen + 1, - sizeof *new_iov); + new_iov = calloc(msg->iovlen + 1, sizeof *new_iov); if (!new_iov) { log_error ("udp_encap_send_message: " - "calloc (%lu, %lu) failed", + "calloc(%lu, %lu) failed", (unsigned long)msg->iovlen + 1, (unsigned long)sizeof *new_iov); return -1; diff --git a/sbin/isakmpd/util.c b/sbin/isakmpd/util.c index 96e96cd061e..036a2e5586e 100644 --- a/sbin/isakmpd/util.c +++ b/sbin/isakmpd/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.68 2014/01/23 01:04:28 deraadt Exp $ */ +/* $OpenBSD: util.c,v 1.69 2015/08/20 22:02:21 deraadt Exp $ */ /* $EOM: util.c,v 1.23 2000/11/23 12:22:08 niklas Exp $ */ /* @@ -153,7 +153,7 @@ raw2hex(u_int8_t *buf, size_t sz) char *s; size_t i; - if ((s = (char *)malloc(sz * 2 + 1)) == NULL) { + if ((s = malloc(sz * 2 + 1)) == NULL) { log_error("raw2hex: malloc (%lu) failed", (unsigned long)sz * 2 + 1); return NULL; } diff --git a/sbin/isakmpd/virtual.c b/sbin/isakmpd/virtual.c index 734ca801fb0..4a7e672fa75 100644 --- a/sbin/isakmpd/virtual.c +++ b/sbin/isakmpd/virtual.c @@ -1,4 +1,4 @@ -/* $OpenBSD: virtual.c,v 1.31 2011/02/03 08:49:46 phessler Exp $ */ +/* $OpenBSD: virtual.c,v 1.32 2015/08/20 22:02:21 deraadt Exp $ */ /* * Copyright (c) 2004 Håkan Olsson. All rights reserved. @@ -228,7 +228,7 @@ virtual_bind(const struct sockaddr *addr) char *stport; in_port_t port; - v = (struct virtual_transport *)calloc(1, sizeof *v); + v = calloc(1, sizeof *v); if (!v) { log_error("virtual_bind: calloc(1, %lu) failed", (unsigned long)sizeof *v); @@ -590,7 +590,7 @@ virtual_create(char *name) } } - v = (struct virtual_transport *)calloc(1, sizeof *v); + v = calloc(1, sizeof *v); if (!v) { log_error("virtual_create: calloc(1, %lu) failed", (unsigned long)sizeof *v); diff --git a/sbin/mountd/mountd.c b/sbin/mountd/mountd.c index 5c324a769a9..06e2b94bd0a 100644 --- a/sbin/mountd/mountd.c +++ b/sbin/mountd/mountd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mountd.c,v 1.79 2015/01/16 06:39:59 deraadt Exp $ */ +/* $OpenBSD: mountd.c,v 1.80 2015/08/20 22:02:21 deraadt Exp $ */ /* $NetBSD: mountd.c,v 1.31 1996/02/18 11:57:53 fvdl Exp $ */ /* @@ -821,7 +821,7 @@ get_exportlist(void) ep = get_exp(); ep->ex_fs = fsb.f_fsid; len = strlen(fsb.f_mntonname) + 1; - ep->ex_fsdir = (char *)malloc(len); + ep->ex_fsdir = malloc(len); if (ep->ex_fsdir) strlcpy(ep->ex_fsdir, fsb.f_mntonname, len); @@ -924,7 +924,7 @@ get_exportlist(void) if (debug) fprintf(stderr, "Adding a default entry\n"); /* add a default group and make the grp list NULL */ - hpe = (struct hostent *)malloc(sizeof(struct hostent)); + hpe = malloc(sizeof(struct hostent)); if (hpe == NULL) out_of_mem(); hpe->h_name = strdup("Default"); @@ -1117,7 +1117,7 @@ add_expdir(struct dirlist **dpp, char *cp, int len) struct dirlist *dp; /* do not need +1 because of dp_dirp[1] */ - dp = (struct dirlist *)malloc(sizeof (struct dirlist) + len); + dp = malloc(sizeof (struct dirlist) + len); if (dp == NULL) out_of_mem(); dp->dp_left = *dpp; @@ -1453,13 +1453,12 @@ get_host(char *cp, struct grouplist *grp, struct grouplist *tgrp) } grp->gr_type = GT_HOST; - nhp = grp->gr_ptr.gt_hostent = (struct hostent *) - malloc(sizeof(struct hostent)); + nhp = grp->gr_ptr.gt_hostent = malloc(sizeof(struct hostent)); if (nhp == NULL) out_of_mem(); memcpy(nhp, hp, sizeof(struct hostent)); i = strlen(hp->h_name)+1; - nhp->h_name = (char *)malloc(i); + nhp->h_name = malloc(i); if (nhp->h_name == NULL) out_of_mem(); memcpy(nhp->h_name, hp->h_name, i); @@ -1467,14 +1466,12 @@ get_host(char *cp, struct grouplist *grp, struct grouplist *tgrp) i = 1; while (*addrp++) i++; - naddrp = nhp->h_addr_list = (char **) - malloc(i*sizeof(char *)); + naddrp = nhp->h_addr_list = malloc(i*sizeof(char *)); if (naddrp == NULL) out_of_mem(); addrp = hp->h_addr_list; while (*addrp) { - *naddrp = (char *) - malloc(hp->h_length); + *naddrp = malloc(hp->h_length); if (*naddrp == NULL) out_of_mem(); memcpy(*naddrp, *addrp, hp->h_length); @@ -1524,7 +1521,7 @@ get_ht(void) { struct hostlist *hp; - hp = (struct hostlist *)malloc(sizeof (struct hostlist)); + hp = malloc(sizeof (struct hostlist)); if (hp == NULL) out_of_mem(); hp->ht_next = NULL; @@ -1722,7 +1719,7 @@ get_net(char *cp, struct netmsk *net, int maskflg) else name = inet_ntoa(inetaddr); len = strlen(name) + 1; - net->nt_name = (char *)malloc(len); + net->nt_name = malloc(len); if (net->nt_name == NULL) out_of_mem(); strlcpy(net->nt_name, name, len); @@ -1892,7 +1889,7 @@ get_mountlist(void) dirp = strsep(&cp, " \t\n"); if (host == NULL || dirp == NULL) continue; - mlp = (struct mountlist *)malloc(sizeof (*mlp)); + mlp = malloc(sizeof (*mlp)); if (mlp == NULL) out_of_mem(); strlcpy(mlp->ml_host, host, sizeof(mlp->ml_host)); @@ -1955,7 +1952,7 @@ add_mlist(char *hostp, char *dirp) mlpp = &mlp->ml_next; mlp = mlp->ml_next; } - mlp = (struct mountlist *)malloc(sizeof (*mlp)); + mlp = malloc(sizeof (*mlp)); if (mlp == NULL) out_of_mem(); strlcpy(mlp->ml_host, hostp, sizeof(mlp->ml_host)); diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c index d239bfc6c3a..6452f8ab1cc 100644 --- a/sbin/newfs/mkfs.c +++ b/sbin/newfs/mkfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mkfs.c,v 1.91 2015/04/18 18:28:37 deraadt Exp $ */ +/* $OpenBSD: mkfs.c,v 1.92 2015/08/20 22:02:21 deraadt Exp $ */ /* $NetBSD: mkfs.c,v 1.25 1995/06/18 21:35:38 cgd Exp $ */ /* @@ -443,7 +443,7 @@ mkfs(struct partition *pp, char *fsys, int fi, int fo, mode_t mfsmode, sblock.fs_cssize = fragroundup(&sblock, sblock.fs_ncg * sizeof(struct csum)); - fscs = (struct csum *)calloc(1, sblock.fs_cssize); + fscs = calloc(1, sblock.fs_cssize); if (fscs == NULL) errx(31, "calloc failed"); diff --git a/sbin/pdisk/dump.c b/sbin/pdisk/dump.c index cfcd217eaf4..935d01a03cd 100644 --- a/sbin/pdisk/dump.c +++ b/sbin/pdisk/dump.c @@ -276,7 +276,7 @@ dump_partition_entry(partition_map *entry, int type_length, int name_length, int printf("%2ld: %*.32s", entry->disk_address, type_length, p->dpme_type); } - buf = (char *) malloc(name_length+1); + buf = malloc(name_length+1); if (entry->HFS_name == NULL || fflag == 0) { strncpy(buf, p->dpme_name, name_length); buf[name_length] = 0; @@ -681,7 +681,7 @@ display_patches(partition_map *entry) m = entry->the_map->m; offset = ((long long) entry->data->dpme_pblock_start) * entry->the_map->logical_block; if (patch_block == NULL) { - patch_block = (unsigned char *) malloc(PBLOCK_SIZE); + patch_block = malloc(PBLOCK_SIZE); if (patch_block == NULL) { error(errno, "can't allocate memory for patch block buffer"); return; @@ -695,7 +695,7 @@ display_patches(partition_map *entry) if (p->numPatchBlocks != 1) { i = p->numPatchBlocks; free(patch_block); - patch_block = (unsigned char *) malloc(PBLOCK_SIZE*i); + patch_block = malloc(PBLOCK_SIZE*i); if (patch_block == NULL) { error(errno, "can't allocate memory for patch blocks buffer"); return; diff --git a/sbin/pdisk/file_media.c b/sbin/pdisk/file_media.c index 321d7aabe1c..ebfcc1eb9a3 100644 --- a/sbin/pdisk/file_media.c +++ b/sbin/pdisk/file_media.c @@ -427,7 +427,7 @@ step_file_iterator(MEDIA_ITERATOR m) } #endif /* generate result */ - result = (char *) malloc(20); + result = malloc(20); if (result != NULL) { /* * for DR3 we should actually iterate through: diff --git a/sbin/pdisk/hfs_misc.c b/sbin/pdisk/hfs_misc.c index 894b829dfb9..eac587deb43 100644 --- a/sbin/pdisk/hfs_misc.c +++ b/sbin/pdisk/hfs_misc.c @@ -171,7 +171,7 @@ get_HFS_name(partition_map *entry, int *kind) *kind = kHFS_not; - mdb = (struct mdb_record *) malloc(PBLOCK_SIZE); + mdb = malloc(PBLOCK_SIZE); if (mdb == NULL) { error(errno, "can't allocate memory for MDB"); return NULL; @@ -196,7 +196,7 @@ get_HFS_name(partition_map *entry, int *kind) // printf("%lu HFS\n", entry->disk_address); *kind = kHFS_std; len = mdb->drVN[0]; - name = (char *) malloc(len+1); + name = malloc(len+1); strncpy(name, &mdb->drVN[1], len); name[len] = 0; } else { @@ -204,7 +204,7 @@ get_HFS_name(partition_map *entry, int *kind) // printf("%lu embedded HFS Plus\n", entry->disk_address); *kind = kHFS_embed; len = mdb->drVN[0]; - name = (char *) malloc(len+1); + name = malloc(len+1); strncpy(name, &mdb->drVN[1], len); name[len] = 0; } diff --git a/sbin/pdisk/io.c b/sbin/pdisk/io.c index 287d4cd41f0..2c22ac89685 100644 --- a/sbin/pdisk/io.c +++ b/sbin/pdisk/io.c @@ -316,7 +316,7 @@ get_string(int eos) char *limit; int length; - ret_value = (char *) malloc(STRING_CHUNK); + ret_value = malloc(STRING_CHUNK); if (ret_value == NULL) { error(errno, "can't allocate memory for string buffer"); return NULL; @@ -328,7 +328,7 @@ get_string(int eos) for (s = ret_value; ; c = my_getch()) { if (s >= limit) { // expand string - limit = (char *) malloc(length+STRING_CHUNK); + limit = malloc(length+STRING_CHUNK); if (limit == NULL) { error(errno, "can't allocate memory for string buffer"); ret_value[length-1] = 0; diff --git a/sbin/pdisk/media.c b/sbin/pdisk/media.c index e363590d52b..1e9701174fe 100644 --- a/sbin/pdisk/media.c +++ b/sbin/pdisk/media.c @@ -73,7 +73,7 @@ allocate_media_kind(void) MEDIA new_media(long size) { - return (MEDIA) malloc(size); + return malloc(size); } @@ -169,5 +169,5 @@ os_reload_media(MEDIA m) MEDIA_ITERATOR new_media_iterator(long size) { - return (MEDIA_ITERATOR) malloc(size); + return malloc(size); } diff --git a/sbin/pdisk/partition_map.c b/sbin/pdisk/partition_map.c index 654fec52912..5715f5f794a 100644 --- a/sbin/pdisk/partition_map.c +++ b/sbin/pdisk/partition_map.c @@ -133,7 +133,7 @@ open_partition_map(char *name, int *valid_file, int ask_logical_size) } *valid_file = 1; - map = (partition_map_header *) malloc(sizeof(partition_map_header)); + map = malloc(sizeof(partition_map_header)); if (map == NULL) { error(errno, "can't allocate memory for open partition map"); close_media(m); @@ -149,7 +149,7 @@ open_partition_map(char *name, int *valid_file, int ask_logical_size) map->physical_block = media_granularity(m); /* preflight */ m = open_deblock_media(PBLOCK_SIZE, m); map->m = m; - map->misc = (Block0 *) malloc(PBLOCK_SIZE); + map->misc = malloc(PBLOCK_SIZE); if (map->misc == NULL) { error(errno, "can't allocate memory for block zero buffer"); close_media(map->m); @@ -237,7 +237,7 @@ read_partition_map(partition_map_header *map) //printf("called read_partition_map\n"); //printf("logical = %d, physical = %d\n", map->logical_block, map->physical_block); - data = (DPME *) malloc(PBLOCK_SIZE); + data = malloc(PBLOCK_SIZE); if (data == NULL) { error(errno, "can't allocate memory for disk buffers"); return -1; @@ -286,7 +286,7 @@ read_partition_map(partition_map_header *map) ix++; } - data = (DPME *) malloc(PBLOCK_SIZE); + data = malloc(PBLOCK_SIZE); if (data == NULL) { error(errno, "can't allocate memory for disk buffers"); return -1; @@ -323,7 +323,7 @@ write_partition_map(partition_map_header *map) result = write_block(map, 0, (char *)map->misc); convert_block0(map->misc, 1); } else { - block = (char *) calloc(1, PBLOCK_SIZE); + block = calloc(1, PBLOCK_SIZE); if (block != NULL) { result = write_block(map, 0, block); free(block); @@ -355,7 +355,7 @@ add_data_to_map(struct dpme *data, long ix, partition_map_header *map) partition_map *entry; //printf("add data %d to map\n", ix); - entry = (partition_map *) malloc(sizeof(partition_map)); + entry = malloc(sizeof(partition_map)); if (entry == NULL) { error(errno, "can't allocate memory for map entries"); return 0; @@ -426,7 +426,7 @@ create_partition_map(char *name, partition_map_header *oldmap) return NULL; } - map = (partition_map_header *) malloc(sizeof(partition_map_header)); + map = malloc(sizeof(partition_map_header)); if (map == NULL) { error(errno, "can't allocate memory for open partition map"); close_media(m); @@ -523,7 +523,7 @@ create_partition_map(char *name, partition_map_header *oldmap) } map->media_size = number; - map->misc = (Block0 *) calloc(1, PBLOCK_SIZE); + map->misc = calloc(1, PBLOCK_SIZE); if (map->misc == NULL) { error(errno, "can't allocate memory for block zero buffer"); } else { @@ -531,7 +531,7 @@ create_partition_map(char *name, partition_map_header *oldmap) coerce_block0(map); sync_device_size(map); - data = (DPME *) calloc(1, PBLOCK_SIZE); + data = calloc(1, PBLOCK_SIZE); if (data == NULL) { error(errno, "can't allocate memory for disk buffers"); } else { @@ -725,7 +725,7 @@ create_data(const char *name, const char *dptype, u32 base, u32 length) { DPME *data; - data = (DPME *) calloc(1, PBLOCK_SIZE); + data = calloc(1, PBLOCK_SIZE); if (data == NULL) { error(errno, "can't allocate memory for disk buffers"); } else { @@ -884,7 +884,7 @@ compute_device_size(partition_map_header *map, partition_map_header *oldmap) // else case - data = (char *) malloc(PBLOCK_SIZE); + data = malloc(PBLOCK_SIZE); if (data == NULL) { error(errno, "can't allocate memory for try buffer"); x = 0; diff --git a/sbin/pdisk/pdisk.c b/sbin/pdisk/pdisk.c index 9d46f7cd1b1..cf5bbe7adf7 100644 --- a/sbin/pdisk/pdisk.c +++ b/sbin/pdisk/pdisk.c @@ -947,7 +947,7 @@ do_display_block(partition_map_header *map, char *alt_name) free(display_block); display_g = 0; } - display_block = (unsigned char *) malloc(g); + display_block = malloc(g); if (display_block == NULL) { error(errno, "can't allocate memory for display block buffer"); goto xit; diff --git a/sbin/pdisk/validate.c b/sbin/pdisk/validate.c index 00140e585f6..2c6ca8d4467 100644 --- a/sbin/pdisk/validate.c +++ b/sbin/pdisk/validate.c @@ -152,7 +152,7 @@ new_range_list_item(enum range_state state, int valid, u32 low, u32 high) { range_list *item; - item = (range_list *) malloc(sizeof(struct range_list)); + item = malloc(sizeof(struct range_list)); item->next = 0; item->prev = 0; item->state = state; diff --git a/sbin/scsi/libscsi.c b/sbin/scsi/libscsi.c index 26aa7d0f930..1e394a6d07b 100644 --- a/sbin/scsi/libscsi.c +++ b/sbin/scsi/libscsi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: libscsi.c,v 1.9 2013/11/22 04:12:48 deraadt Exp $ */ +/* $OpenBSD: libscsi.c,v 1.10 2015/08/20 22:02:21 deraadt Exp $ */ /* Copyright (c) 1994 HD Associates * (contact: dufault@hda.com) @@ -80,7 +80,7 @@ scsireq_reset(scsireq_t *scsireq) scsireq_t * scsireq_new(void) { - scsireq_t *p = (scsireq_t *)malloc(sizeof(scsireq_t)); + scsireq_t *p = malloc(sizeof(scsireq_t)); if (p) scsireq_reset(p); diff --git a/sbin/swapctl/swaplist.c b/sbin/swapctl/swaplist.c index cd0b008e12f..a20c36b4044 100644 --- a/sbin/swapctl/swaplist.c +++ b/sbin/swapctl/swaplist.c @@ -1,4 +1,4 @@ -/* $OpenBSD: swaplist.c,v 1.10 2015/01/16 06:40:01 deraadt Exp $ */ +/* $OpenBSD: swaplist.c,v 1.11 2015/08/20 22:02:21 deraadt Exp $ */ /* $NetBSD: swaplist.c,v 1.8 1998/10/08 10:00:31 mrg Exp $ */ /* @@ -58,7 +58,7 @@ list_swap(int pri, int kflag, int pflag, int dolong) if (nswap < 1) errx(1, "no swap devices configured"); - fsep = sep = (struct swapent *)calloc(nswap, sizeof(*sep)); + fsep = sep = calloc(nswap, sizeof(*sep)); if (sep == NULL) err(1, "calloc"); rnswap = swapctl(SWAP_STATS, (void *)sep, nswap); |