diff options
Diffstat (limited to 'usr.sbin')
37 files changed, 123 insertions, 135 deletions
diff --git a/usr.sbin/bgpd/mrt.c b/usr.sbin/bgpd/mrt.c index f48d7f4e01d..2357caee5bc 100644 --- a/usr.sbin/bgpd/mrt.c +++ b/usr.sbin/bgpd/mrt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mrt.c,v 1.77 2014/04/19 15:43:17 claudio Exp $ */ +/* $OpenBSD: mrt.c,v 1.78 2015/08/20 22:39:29 deraadt Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> @@ -990,8 +990,7 @@ mrt_mergeconfig(struct mrt_head *xconf, struct mrt_head *nconf) LIST_FOREACH(m, nconf, entry) { if ((xm = mrt_get(xconf, m)) == NULL) { /* NEW */ - if ((xm = (struct mrt *)calloc(1, - sizeof(struct mrt_config))) == NULL) + if ((xm = calloc(1, sizeof(struct mrt_config))) == NULL) fatal("mrt_mergeconfig"); memcpy(xm, m, sizeof(struct mrt_config)); xm->state = MRT_STATE_OPEN; diff --git a/usr.sbin/crunchgen/crunchide.c b/usr.sbin/crunchgen/crunchide.c index 1720dd08fde..40f8f86d8a1 100644 --- a/usr.sbin/crunchgen/crunchide.c +++ b/usr.sbin/crunchgen/crunchide.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crunchide.c,v 1.9 2015/01/18 05:30:58 guenther Exp $ */ +/* $OpenBSD: crunchide.c,v 1.10 2015/08/20 22:39:29 deraadt Exp $ */ /* * Copyright (c) 1994 University of Maryland @@ -138,7 +138,7 @@ add_to_keep_list(char *symbol) if (curp && cmp == 0) return; /* already in table */ - newp = (struct keep *) calloc(1, sizeof(struct keep)); + newp = calloc(1, sizeof(struct keep)); if (newp) newp->sym = strdup(symbol); if (newp == NULL || newp->sym == NULL) { diff --git a/usr.sbin/crunchgen/elf_hide.c b/usr.sbin/crunchgen/elf_hide.c index 662d4e29070..1d1c164c530 100644 --- a/usr.sbin/crunchgen/elf_hide.c +++ b/usr.sbin/crunchgen/elf_hide.c @@ -1,4 +1,4 @@ -/* $OpenBSD: elf_hide.c,v 1.9 2015/01/18 05:30:58 guenther Exp $ */ +/* $OpenBSD: elf_hide.c,v 1.10 2015/08/20 22:39:29 deraadt Exp $ */ /* * Copyright (c) 1997 Dale Rahn. @@ -349,8 +349,8 @@ reorder_syms(Elf_Ehdr * ehdr, Elf_Shdr * symsect, nsyms = symtabsize / sizeof(Elf_Sym); - tmpsymtab = (Elf_Sym *) calloc(1, symtabsize); - symmap = (Symmap *) calloc(nsyms, sizeof(Symmap)); + tmpsymtab = calloc(1, symtabsize); + symmap = calloc(nsyms, sizeof(Symmap)); if (!tmpsymtab || !symmap) errc(5, ENOMEM, "calloc"); diff --git a/usr.sbin/dhcpd/confpars.c b/usr.sbin/dhcpd/confpars.c index 8b79d263a80..2423e91dba1 100644 --- a/usr.sbin/dhcpd/confpars.c +++ b/usr.sbin/dhcpd/confpars.c @@ -1,4 +1,4 @@ -/* $OpenBSD: confpars.c,v 1.24 2015/05/18 17:51:21 krw Exp $ */ +/* $OpenBSD: confpars.c,v 1.25 2015/08/20 22:39:29 deraadt Exp $ */ /* * Copyright (c) 1995, 1996, 1997 The Internet Software Consortium. @@ -1277,8 +1277,7 @@ parse_lease_declaration(FILE *cfile) if (token == TOK_STRING) { token = next_token(&val, cfile); lease.uid_len = strlen(val); - lease.uid = (unsigned char *) - malloc(lease.uid_len); + lease.uid = malloc(lease.uid_len); if (!lease.uid) { warning("no space for uid"); return NULL; diff --git a/usr.sbin/dhcpd/dhcp.c b/usr.sbin/dhcpd/dhcp.c index 9edcd55dda2..f90aa4a3983 100644 --- a/usr.sbin/dhcpd/dhcp.c +++ b/usr.sbin/dhcpd/dhcp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcp.c,v 1.42 2015/04/15 12:40:57 krw Exp $ */ +/* $OpenBSD: dhcp.c,v 1.43 2015/08/20 22:39:29 deraadt Exp $ */ /* * Copyright (c) 1995, 1996, 1997, 1998, 1999 @@ -874,7 +874,7 @@ ack_lease(struct packet *packet, struct lease *lease, unsigned int offer, lt.uid_len = packet->options[i].len; } else { lt.uid_max = lt.uid_len = packet->options[i].len; - lt.uid = (unsigned char *)malloc(lt.uid_max); + lt.uid = malloc(lt.uid_max); if (!lt.uid) error("can't allocate memory for large uid."); memcpy(lt.uid, packet->options[i].data, lt.uid_len); diff --git a/usr.sbin/dhcpd/dispatch.c b/usr.sbin/dhcpd/dispatch.c index ceb3856887b..a54f05220af 100644 --- a/usr.sbin/dhcpd/dispatch.c +++ b/usr.sbin/dhcpd/dispatch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dispatch.c,v 1.34 2014/10/08 04:26:07 deraadt Exp $ */ +/* $OpenBSD: dispatch.c,v 1.35 2015/08/20 22:39:29 deraadt Exp $ */ /* * Copyright (c) 1995, 1996, 1997, 1998, 1999 @@ -156,7 +156,7 @@ discover_interfaces(int *rdomain) which we found it. */ if (!tmp->ifp) { int len = (IFNAMSIZ + ifa->ifa_addr->sa_len); - tif = (struct ifreq *)malloc(len); + tif = malloc(len); if (!tif) error("no space to remember ifp."); strlcpy(tif->ifr_name, ifa->ifa_name, IFNAMSIZ); @@ -530,7 +530,7 @@ add_timeout(time_t when, void (*where)(void *), void *what) q->func = where; q->what = what; } else { - q = (struct dhcpd_timeout *)malloc(sizeof (struct dhcpd_timeout)); + q = malloc(sizeof (struct dhcpd_timeout)); if (!q) error("Can't allocate timeout structure!"); q->func = where; @@ -595,7 +595,7 @@ add_protocol(char *name, int fd, void (*handler)(struct protocol *), { struct protocol *p; - p = (struct protocol *)malloc(sizeof *p); + p = malloc(sizeof *p); if (!p) error("can't allocate protocol struct for %s", name); p->fd = fd; diff --git a/usr.sbin/edquota/edquota.c b/usr.sbin/edquota/edquota.c index fd14f3b9bd0..42a9d35fc06 100644 --- a/usr.sbin/edquota/edquota.c +++ b/usr.sbin/edquota/edquota.c @@ -255,7 +255,7 @@ getprivs(u_int id, int quotatype) continue; qfpathnamelen = strlen(qfpathname); qupsize = sizeof(*qup) + qfpathnamelen; - if ((qup = (struct quotause *)malloc(qupsize)) == NULL) + if ((qup = malloc(qupsize)) == NULL) errx(2, "out of memory"); if (quotactl(fs->fs_file, qcmd, id, (char *)&qup->dqblk) != 0) { if (errno == EOPNOTSUPP && !warned) { diff --git a/usr.sbin/eeprom/eehandlers.c b/usr.sbin/eeprom/eehandlers.c index 75aac5657be..4066aad80ae 100644 --- a/usr.sbin/eeprom/eehandlers.c +++ b/usr.sbin/eeprom/eehandlers.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eehandlers.c,v 1.20 2015/01/15 20:48:51 miod Exp $ */ +/* $OpenBSD: eehandlers.c,v 1.21 2015/08/20 22:39:29 deraadt Exp $ */ /* $NetBSD: eehandlers.c,v 1.2 1996/02/28 01:13:22 thorpej Exp $ */ /*- @@ -458,7 +458,7 @@ doio(struct keytabent *ktent, u_char *buf, ssize_t len, int wr) int fd, rval = 0; u_char *buf2; - buf2 = (u_char *)calloc(1, len); + buf2 = calloc(1, len); if (buf2 == NULL) { snprintf(err_str, sizeof err_str, "memory allocation failed"); return (1); diff --git a/usr.sbin/eeprom/ophandlers.c b/usr.sbin/eeprom/ophandlers.c index b66c5138b3e..751fb68a294 100644 --- a/usr.sbin/eeprom/ophandlers.c +++ b/usr.sbin/eeprom/ophandlers.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ophandlers.c,v 1.13 2014/11/18 20:54:28 krw Exp $ */ +/* $OpenBSD: ophandlers.c,v 1.14 2015/08/20 22:39:29 deraadt Exp $ */ /* $NetBSD: ophandlers.c,v 1.2 1996/02/28 01:13:30 thorpej Exp $ */ /*- @@ -265,7 +265,7 @@ op_print(char *op_buf) size_t size; size = 1 + 4 * strlen(op_buf); - vistr = (char *)malloc(size); + vistr = malloc(size); if (vistr == NULL) printf("(out of memory)\n"); else { diff --git a/usr.sbin/hostapd/parse.y b/usr.sbin/hostapd/parse.y index 1ffd4c2de09..c6a8beb4588 100644 --- a/usr.sbin/hostapd/parse.y +++ b/usr.sbin/hostapd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.49 2015/01/16 06:40:17 deraadt Exp $ */ +/* $OpenBSD: parse.y,v 1.50 2015/08/20 22:39:29 deraadt Exp $ */ /* * Copyright (c) 2004, 2005, 2006 Reyk Floeter <reyk@openbsd.org> @@ -367,8 +367,8 @@ event : HOSTAP HANDLE /* IEEE 802.11 raw frame to send as an action */ frame_ieee80211 = &frame.f_action_data.a_frame; } action limit rate { - if ((frame_ptr = (struct hostapd_frame *)calloc(1, - sizeof(struct hostapd_frame))) == NULL) { + if ((frame_ptr = calloc(1, sizeof(struct hostapd_frame))) + == NULL) { yyerror("calloc"); YYERROR; } @@ -647,7 +647,7 @@ authalg : OPEN REQUEST frmreason : frmreason_l { if ($1 != 0) { - if ((frame_ieee80211->i_data = (u_int16_t *) + if ((frame_ieee80211->i_data = malloc(sizeof(u_int16_t))) == NULL) { yyerror("failed to allocate " "reason code %u", $1); @@ -1611,7 +1611,7 @@ symset(const char *nam, const char *val, int persist) free(sym); } } - if ((sym = (struct sym *)calloc(1, sizeof(*sym))) == NULL) + if ((sym = calloc(1, sizeof(*sym))) == NULL) return (-1); sym->nam = strdup(nam); @@ -1645,7 +1645,7 @@ hostapd_parse_symset(char *s) return (-1); len = strlen(s) - strlen(val) + 1; - if ((sym = (char *)malloc(len)) == NULL) + if ((sym = malloc(len)) == NULL) hostapd_fatal("cmdline_symset: malloc"); (void)strlcpy(sym, s, len); diff --git a/usr.sbin/httpd/parse.y b/usr.sbin/httpd/parse.y index 0b7958557e2..8622d84b055 100644 --- a/usr.sbin/httpd/parse.y +++ b/usr.sbin/httpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.75 2015/08/20 13:00:23 reyk Exp $ */ +/* $OpenBSD: parse.y,v 1.76 2015/08/20 22:39:29 deraadt Exp $ */ /* * Copyright (c) 2007 - 2015 Reyk Floeter <reyk@openbsd.org> @@ -2116,9 +2116,8 @@ is_if_in_group(const char *ifname, const char *groupname) } len = ifgr.ifgr_len; - ifgr.ifgr_groups = - (struct ifg_req *)calloc(len / sizeof(struct ifg_req), - sizeof(struct ifg_req)); + ifgr.ifgr_groups = calloc(len / sizeof(struct ifg_req), + sizeof(struct ifg_req)); if (ifgr.ifgr_groups == NULL) err(1, "getifgroups"); if (ioctl(s, SIOCGIFGROUP, (caddr_t)&ifgr) == -1) diff --git a/usr.sbin/kgmon/kgmon.c b/usr.sbin/kgmon/kgmon.c index 87cbf116217..4e7f570dede 100644 --- a/usr.sbin/kgmon/kgmon.c +++ b/usr.sbin/kgmon/kgmon.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kgmon.c,v 1.21 2015/01/16 06:40:17 deraadt Exp $ */ +/* $OpenBSD: kgmon.c,v 1.22 2015/08/20 22:39:29 deraadt Exp $ */ /* * Copyright (c) 1983, 1992, 1993 @@ -341,7 +341,7 @@ dumpstate(struct kvmvars *kvp, int cpuid) */ mib[0] = CTL_KERN; mib[1] = KERN_PROF; - if ((tickbuf = (u_short *)malloc(kvp->gpm.kcountsize)) == NULL) + if ((tickbuf = malloc(kvp->gpm.kcountsize)) == NULL) errx(5, "cannot allocate kcount space"); if (kflag) { i = kvm_read(kvp->kd, (u_long)kvp->gpm.kcount, (void *)tickbuf, @@ -364,7 +364,7 @@ dumpstate(struct kvmvars *kvp, int cpuid) /* * Write out the arc info. */ - if ((froms = (u_short *)malloc(kvp->gpm.fromssize)) == NULL) + if ((froms = malloc(kvp->gpm.fromssize)) == NULL) errx(8, "cannot allocate froms space"); if (kflag) { i = kvm_read(kvp->kd, (u_long)kvp->gpm.froms, (void *)froms, @@ -380,7 +380,7 @@ dumpstate(struct kvmvars *kvp, int cpuid) errx(9, "read froms: read %lu, got %zu: %s", kvp->gpm.fromssize, i, kflag ? kvm_geterr(kvp->kd) : strerror(errno)); - if ((tos = (struct tostruct *)malloc(kvp->gpm.tossize)) == NULL) + if ((tos = malloc(kvp->gpm.tossize)) == NULL) errx(10, "cannot allocate tos space"); if (kflag) { i = kvm_read(kvp->kd, (u_long)kvp->gpm.tos, (void *)tos, @@ -462,7 +462,7 @@ reset(struct kvmvars *kvp, int cpuid) biggest = kvp->gpm.fromssize; if (kvp->gpm.tossize > biggest) biggest = kvp->gpm.tossize; - if ((zbuf = (char *)malloc(biggest)) == NULL) + if ((zbuf = malloc(biggest)) == NULL) errx(12, "cannot allocate zbuf space"); bzero(zbuf, biggest); if (kflag) { diff --git a/usr.sbin/kvm_mkdb/nlist.c b/usr.sbin/kvm_mkdb/nlist.c index e2f534f7458..ed325d95368 100644 --- a/usr.sbin/kvm_mkdb/nlist.c +++ b/usr.sbin/kvm_mkdb/nlist.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nlist.c,v 1.47 2015/01/18 04:48:24 deraadt Exp $ */ +/* $OpenBSD: nlist.c,v 1.48 2015/08/20 22:39:29 deraadt Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -87,7 +87,7 @@ __elf_knlist(int fd, DB *db, int ksyms) !IS_ELF(eh)) return (1); - sh = (Elf_Shdr *)calloc(sizeof(Elf_Shdr), eh.e_shnum); + sh = calloc(sizeof(Elf_Shdr), eh.e_shnum); if (sh == NULL) errx(1, "cannot allocate %zu bytes for symbol header", sizeof(Elf_Shdr) * eh.e_shnum); diff --git a/usr.sbin/map-mbone/mapper.c b/usr.sbin/map-mbone/mapper.c index dc71c059a14..be305fd6a5a 100644 --- a/usr.sbin/map-mbone/mapper.c +++ b/usr.sbin/map-mbone/mapper.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mapper.c,v 1.22 2015/01/16 06:40:18 deraadt Exp $ */ +/* $OpenBSD: mapper.c,v 1.23 2015/08/20 22:39:29 deraadt Exp $ */ /* $NetBSD: mapper.c,v 1.3 1995/12/10 11:12:04 mycroft Exp $ */ /* Mapper for connections between MRouteD multicast routers. @@ -108,7 +108,7 @@ Node *find_node(u_int32_t addr, Node **ptr) Node *n = *ptr; if (!n) { - *ptr = n = (Node *) malloc(sizeof(Node)); + *ptr = n = malloc(sizeof(Node)); n->addr = addr; n->version = 0; n->tries = 0; @@ -132,7 +132,7 @@ Interface *find_interface(u_int32_t addr, Node *node) if (ifc->addr == addr) return ifc; - ifc = (Interface *) malloc(sizeof(Interface)); + ifc = malloc(sizeof(Interface)); ifc->addr = addr; ifc->next = node->u.interfaces; node->u.interfaces = ifc; @@ -406,7 +406,7 @@ void accept_neighbors(u_int32_t src, u_int32_t dst, u_char *p, int datalen, goto next_neighbor; } - nb = (Neighbor *) malloc(sizeof(Neighbor)); + nb = malloc(sizeof(Neighbor)); nb->next = ifc->neighbors; ifc->neighbors = nb; nb->addr = neighbor; @@ -550,7 +550,7 @@ void accept_neighbors2(u_int32_t src, u_int32_t dst, u_char *p, int datalen, goto next_neighbor; } - nb = (Neighbor *) malloc(sizeof(Neighbor)); + nb = malloc(sizeof(Neighbor)); nb->next = ifc->neighbors; ifc->neighbors = nb; nb->addr = neighbor; diff --git a/usr.sbin/netgroup_mkdb/netgroup_mkdb.c b/usr.sbin/netgroup_mkdb/netgroup_mkdb.c index 88ae7edde5a..9e3c2d27479 100644 --- a/usr.sbin/netgroup_mkdb/netgroup_mkdb.c +++ b/usr.sbin/netgroup_mkdb/netgroup_mkdb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: netgroup_mkdb.c,v 1.17 2015/01/16 15:40:16 deraadt Exp $ */ +/* $OpenBSD: netgroup_mkdb.c,v 1.18 2015/08/20 22:39:29 deraadt Exp $ */ /* * Copyright (c) 1994 Christos Zoulas @@ -51,8 +51,6 @@ #define DEBUG_NG -#define NEW(a) (a *) emalloc(sizeof(a)) - struct nentry { int n_type; size_t n_size; /* Buffer size required for printing */ @@ -249,7 +247,7 @@ ng_load(const char *fname) break; case _NG_NAME: - e = NEW(struct nentry); + e = emalloc(sizeof(struct nentry)); e->n_type = _NG_NAME; e->n_name = name; e->n_next = NULL; @@ -268,7 +266,7 @@ ng_load(const char *fname) _ng_print(fmt, sizeof(fmt), ng); errx(1, "no netgroup key for %s", fmt); } else { - e = NEW(struct nentry); + e = emalloc(sizeof(struct nentry)); e->n_type = _NG_GROUP; e->n_group = ng; e->n_next = NULL; diff --git a/usr.sbin/quot/quot.c b/usr.sbin/quot/quot.c index d6058ee6a84..18c9c0ff06a 100644 --- a/usr.sbin/quot/quot.c +++ b/usr.sbin/quot/quot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: quot.c,v 1.26 2015/01/20 18:22:21 deraadt Exp $ */ +/* $OpenBSD: quot.c,v 1.27 2015/08/20 22:39:29 deraadt Exp $ */ /* * Copyright (C) 1991, 1994 Wolfgang Solfrank. @@ -220,8 +220,7 @@ inituser(void) if (!nusers) { nusers = 8; - if (!(users = - (struct user *)calloc(nusers, sizeof(struct user)))) { + if (!(users = calloc(nusers, sizeof(struct user)))) { err(1, "allocate users"); } } else { @@ -241,7 +240,7 @@ usrrehash(void) svusr = users; nusers <<= 1; - if (!(users = (struct user *)calloc(nusers, sizeof(struct user)))) + if (!(users = calloc(nusers, sizeof(struct user)))) err(1, "allocate users"); for (usr = svusr, i = nusers >> 1; --i >= 0; usr++) { for (usrn = users + (usr->uid&(nusers - 1)); @@ -354,7 +353,7 @@ dofsizes(int fd, struct fs *super, char *name) maxino = super->fs_ncg * super->fs_ipg - 1; #ifdef COMPAT - if (!(fsizes = (struct fsizes *)malloc(sizeof(struct fsizes)))) + if (!(fsizes = malloc(sizeof(struct fsizes)))) err(1, "alloc fsize structure"); #endif /* COMPAT */ for (inode = 0; inode < maxino; inode++) { @@ -435,7 +434,7 @@ douser(int fd, struct fs *super, char *name) else if (errno) err(1, "%s", name); } - if (!(usrs = (struct user *)calloc(nusers, sizeof(struct user)))) + if (!(usrs = calloc(nusers, sizeof(struct user)))) err(1, "allocate users"); memcpy(usrs, users, nusers * sizeof(struct user)); sortusers(usrs); diff --git a/usr.sbin/rarpd/rarpd.c b/usr.sbin/rarpd/rarpd.c index ac1f966e4ca..df981e85498 100644 --- a/usr.sbin/rarpd/rarpd.c +++ b/usr.sbin/rarpd/rarpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rarpd.c,v 1.60 2015/07/16 17:51:22 miod Exp $ */ +/* $OpenBSD: rarpd.c,v 1.61 2015/08/20 22:39:29 deraadt Exp $ */ /* $NetBSD: rarpd.c,v 1.25 1998/04/23 02:48:33 mrg Exp $ */ /* @@ -205,7 +205,7 @@ init_one(char *ifname) if (fd < 0) return; - p = (struct if_info *)malloc(sizeof(*p)); + p = malloc(sizeof(*p)); if (p == 0) { error(FATAL, "malloc: %s", strerror(errno)); /* NOTREACHED */ @@ -400,7 +400,7 @@ rarp_loop(void) error(FATAL, "BIOCGBLEN: %s", strerror(errno)); /* NOTREACHED */ } - buf = (u_char *) malloc((size_t) bufsize); + buf = malloc((size_t) bufsize); if (buf == 0) { error(FATAL, "malloc: %s", strerror(errno)); /* NOTREACHED */ diff --git a/usr.sbin/rbootd/bpf.c b/usr.sbin/rbootd/bpf.c index 523a9553219..b5baf0429dd 100644 --- a/usr.sbin/rbootd/bpf.c +++ b/usr.sbin/rbootd/bpf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bpf.c,v 1.22 2015/04/18 18:28:38 deraadt Exp $ */ +/* $OpenBSD: bpf.c,v 1.23 2015/08/20 22:39:29 deraadt Exp $ */ /* $NetBSD: bpf.c,v 1.5.2.1 1995/11/14 08:45:42 thorpej Exp $ */ /* @@ -160,7 +160,7 @@ BpfOpen(void) DoExit(); } if (BpfPkt == NULL) - BpfPkt = (u_int8_t *)malloc(BpfLen); + BpfPkt = malloc(BpfLen); if (BpfPkt == NULL) { syslog(LOG_ERR, "bpf: out of memory (%u bytes for bpfpkt)", diff --git a/usr.sbin/rbootd/utils.c b/usr.sbin/rbootd/utils.c index b89e6e4611d..41a8dfd3b2f 100644 --- a/usr.sbin/rbootd/utils.c +++ b/usr.sbin/rbootd/utils.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utils.c,v 1.13 2015/01/16 06:40:19 deraadt Exp $ */ +/* $OpenBSD: utils.c,v 1.14 2015/08/20 22:39:29 deraadt Exp $ */ /* $NetBSD: utils.c,v 1.5.2.1 1995/11/14 08:45:46 thorpej Exp $ */ /* @@ -268,7 +268,7 @@ NewClient(u_int8_t *addr) { CLIENT *ctmp; - if ((ctmp = (CLIENT *) malloc(sizeof(CLIENT))) == NULL) { + if ((ctmp = malloc(sizeof(CLIENT))) == NULL) { syslog(LOG_ERR, "NewClient: out of memory (%s)", GetEtherAddr(addr)); return(NULL); @@ -359,7 +359,7 @@ NewConn(RMPCONN *rconn) RMPCONN *rtmp; if (LastFree == NULL) { /* nothing cached; make a new one */ - if ((rtmp = (RMPCONN *) malloc(sizeof(RMPCONN))) == NULL) { + if ((rtmp = malloc(sizeof(RMPCONN))) == NULL) { syslog(LOG_ERR, "NewConn: out of memory (%s)", EnetStr(rconn)); return(NULL); diff --git a/usr.sbin/relayd/parse.y b/usr.sbin/relayd/parse.y index ae83e49ba4b..c6c9d7b3f74 100644 --- a/usr.sbin/relayd/parse.y +++ b/usr.sbin/relayd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.204 2015/05/02 13:15:24 claudio Exp $ */ +/* $OpenBSD: parse.y,v 1.205 2015/08/20 22:39:29 deraadt Exp $ */ /* * Copyright (c) 2007 - 2014 Reyk Floeter <reyk@openbsd.org> @@ -3266,9 +3266,8 @@ is_if_in_group(const char *ifname, const char *groupname) } len = ifgr.ifgr_len; - ifgr.ifgr_groups = - (struct ifg_req *)calloc(len / sizeof(struct ifg_req), - sizeof(struct ifg_req)); + ifgr.ifgr_groups = calloc(len / sizeof(struct ifg_req), + sizeof(struct ifg_req)); if (ifgr.ifgr_groups == NULL) err(1, "getifgroups"); if (ioctl(s, SIOCGIFGROUP, (caddr_t)&ifgr) == -1) diff --git a/usr.sbin/repquota/repquota.c b/usr.sbin/repquota/repquota.c index df68703913c..8376bea3210 100644 --- a/usr.sbin/repquota/repquota.c +++ b/usr.sbin/repquota/repquota.c @@ -320,7 +320,7 @@ addid(uid_t id, int type, char *name) len = strlen(name); else len = 10; - if ((fup = (struct fileusage *)calloc(1, sizeof(*fup) + len)) == NULL) { + if ((fup = calloc(1, sizeof(*fup) + len)) == NULL) { fprintf(stderr, "out of memory for fileusage structures\n"); exit(1); } diff --git a/usr.sbin/rip6query/rip6query.c b/usr.sbin/rip6query/rip6query.c index 72de4aa864e..d4414ba13ca 100644 --- a/usr.sbin/rip6query/rip6query.c +++ b/usr.sbin/rip6query/rip6query.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rip6query.c,v 1.15 2015/04/18 18:28:38 deraadt Exp $ */ +/* $OpenBSD: rip6query.c,v 1.16 2015/08/20 22:39:29 deraadt Exp $ */ /* $KAME: rip6query.c,v 1.17 2002/09/08 01:35:17 itojun Exp $ */ /* @@ -136,7 +136,7 @@ main(int argc, char *argv[]) if (ifidx >= 0) sin6.sin6_scope_id = ifidx; - if ((ripbuf = (struct rip6 *)malloc(BUFSIZ)) == NULL) { + if ((ripbuf = malloc(BUFSIZ)) == NULL) { err(1, "malloc"); /*NOTREACHED*/ } diff --git a/usr.sbin/route6d/route6d.c b/usr.sbin/route6d/route6d.c index d2bc8dd2415..5c34462d957 100644 --- a/usr.sbin/route6d/route6d.c +++ b/usr.sbin/route6d/route6d.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route6d.c,v 1.65 2015/02/04 20:16:23 bluhm Exp $ */ +/* $OpenBSD: route6d.c,v 1.66 2015/08/20 22:39:29 deraadt Exp $ */ /* $KAME: route6d.c,v 1.111 2006/10/25 06:38:13 jinmei Exp $ */ /* @@ -254,8 +254,6 @@ struct ifc *ifc_find(char *); struct iff *iff_find(struct ifc *, int); void setindex2ifc(int, struct ifc *); -#define MALLOC(type) ((type *)malloc(sizeof(type))) - int main(int argc, char *argv[]) { @@ -339,7 +337,7 @@ main(int argc, char *argv[]) openlog(progname, LOG_NDELAY|LOG_PID, LOG_DAEMON); logopened++; - if ((ripbuf = (struct rip6 *)malloc(RIP6_MAXMTU)) == NULL) + if ((ripbuf = malloc(RIP6_MAXMTU)) == NULL) fatal("malloc"); memset(ripbuf, 0, RIP6_MAXMTU); ripbuf->rip6_cmd = RIP6_RESPONSE; @@ -372,7 +370,7 @@ main(int argc, char *argv[]) pidfile(NULL); - if ((ripbuf = (struct rip6 *)malloc(RIP6_MAXMTU)) == NULL) { + if ((ripbuf = malloc(RIP6_MAXMTU)) == NULL) { fatal("malloc"); /*NOTREACHED*/ } @@ -1283,7 +1281,7 @@ riprecv(void) */ } else if (np->rip6_metric < HOPCNT_INFINITY6) { /* Got a new valid route */ - if ((rrt = MALLOC(struct riprt)) == NULL) { + if ((rrt = malloc(sizeof(struct riprt))) == NULL) { fatal("malloc: struct riprt"); /*NOTREACHED*/ } @@ -1413,7 +1411,7 @@ ifconfig(void) continue; if (!ifcp) { /* new interface */ - if ((ifcp = MALLOC(struct ifc)) == NULL) { + if ((ifcp = malloc(sizeof(struct ifc))) == NULL) { fatal("malloc: struct ifc"); /*NOTREACHED*/ } @@ -1486,7 +1484,7 @@ ifconfig1(const char *name, const struct sockaddr *sa, struct ifc *ifcp, int s) /* * New address is found */ - if ((ifa = MALLOC(struct ifac)) == NULL) { + if ((ifa = malloc(sizeof(struct ifac))) == NULL) { fatal("malloc: struct ifac"); /*NOTREACHED*/ } @@ -2011,7 +2009,7 @@ ifrt(struct ifc *ifcp, int again) continue; } if (ifcp->ifc_flags & IFF_UP) { - if ((rrt = MALLOC(struct riprt)) == NULL) + if ((rrt = malloc(sizeof(struct riprt))) == NULL) fatal("malloc: struct riprt"); memset(rrt, 0, sizeof(*rrt)); rrt->rrt_same = NULL; @@ -2167,7 +2165,7 @@ ifrt_p2p(struct ifc *ifcp, int again) for (i = 1; i <= P2PADVERT_MAX; i *= 2) { if ((ignore & i) != 0) continue; - if ((rrt = MALLOC(struct riprt)) == NULL) { + if ((rrt = malloc(sizeof(struct riprt))) == NULL) { fatal("malloc: struct riprt"); /*NOTREACHED*/ } @@ -2541,7 +2539,7 @@ rt_entry(struct rt_msghdr *rtm, int again) if (IN6_IS_ADDR_MULTICAST(&sin6_dst->sin6_addr)) return; - if ((rrt = MALLOC(struct riprt)) == NULL) { + if ((rrt = malloc(sizeof(struct riprt))) == NULL) { fatal("malloc: struct riprt"); /*NOTREACHED*/ } @@ -3031,7 +3029,7 @@ ifonly: fatal("no interface %s exists", ifname); /*NOTREACHED*/ } - iff_obj = (struct iff *)malloc(sizeof(struct iff)); + iff_obj = malloc(sizeof(struct iff)); if (iff_obj == NULL) { fatal("malloc of iff_obj"); /*NOTREACHED*/ @@ -3049,7 +3047,7 @@ ifonly: if (filtertype[i] != 'A') continue; /* put the aggregate to the kernel routing table */ - rrt = (struct riprt *)malloc(sizeof(struct riprt)); + rrt = malloc(sizeof(struct riprt)); if (rrt == NULL) { fatal("malloc: rrt"); /*NOTREACHED*/ @@ -3234,7 +3232,7 @@ char * allocopy(char *p) { int len = strlen(p) + 1; - char *q = (char *)malloc(len); + char *q = malloc(len); if (!q) { fatal("malloc"); diff --git a/usr.sbin/rpc.statd/procs.c b/usr.sbin/rpc.statd/procs.c index 285a7b88afb..548d797d49e 100644 --- a/usr.sbin/rpc.statd/procs.c +++ b/usr.sbin/rpc.statd/procs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: procs.c,v 1.1 2008/06/15 04:43:28 sturm Exp $ */ +/* $OpenBSD: procs.c,v 1.2 2015/08/20 22:39:29 deraadt Exp $ */ /* * Copyright (c) 1995 @@ -113,7 +113,7 @@ sm_mon_1_svc(mon *arg, struct svc_req *req) if ((hp = find_host(arg->mon_id.mon_name, &h)) == NULL) memset(hp = &h, 0, sizeof(h)); - lp = (MonList *)malloc(sizeof(MonList)); + lp = malloc(sizeof(MonList)); if (!lp) syslog(LOG_ERR, "Out of memory"); else { diff --git a/usr.sbin/rtadvd/if.c b/usr.sbin/rtadvd/if.c index d530c538229..ff5358f8858 100644 --- a/usr.sbin/rtadvd/if.c +++ b/usr.sbin/rtadvd/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.27 2015/01/16 06:40:20 deraadt Exp $ */ +/* $OpenBSD: if.c,v 1.28 2015/08/20 22:39:29 deraadt Exp $ */ /* $KAME: if.c,v 1.17 2001/01/21 15:27:30 itojun Exp $ */ /* @@ -472,7 +472,7 @@ parse_iflist(struct if_msghdr ***ifmlist_p, char *buf, size_t bufsize) iflentry_size = sizeof(struct if_msghdr); /* roughly estimate max list size of pointers to each if_msghdr */ malloc_size = (bufsize/iflentry_size) * sizeof(size_t); - if ((*ifmlist_p = (struct if_msghdr **)malloc(malloc_size)) == NULL) + if ((*ifmlist_p = malloc(malloc_size)) == NULL) fatal("malloc"); lim = buf + bufsize; diff --git a/usr.sbin/rtadvd/rtadvd.c b/usr.sbin/rtadvd/rtadvd.c index b182e4ce1de..52484d1b2eb 100644 --- a/usr.sbin/rtadvd/rtadvd.c +++ b/usr.sbin/rtadvd/rtadvd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtadvd.c,v 1.54 2015/08/18 20:25:28 miod Exp $ */ +/* $OpenBSD: rtadvd.c,v 1.55 2015/08/20 22:39:29 deraadt Exp $ */ /* $KAME: rtadvd.c,v 1.66 2002/05/29 14:18:36 itojun Exp $ */ /* @@ -721,7 +721,7 @@ rs_input(int len, struct nd_router_solicit *rs, /* * record sockaddr waiting for RA, if possible */ - sol = (struct soliciter *)malloc(sizeof(*sol)); + sol = malloc(sizeof(*sol)); if (sol) { sol->addr = *from; /*XXX RFC2553 need clarification on flowinfo */ @@ -1197,13 +1197,13 @@ sock_open() rcvcmsgbuflen = CMSG_SPACE(sizeof(struct in6_pktinfo)) + CMSG_SPACE(sizeof(int)); - rcvcmsgbuf = (u_char *)malloc(rcvcmsgbuflen); + rcvcmsgbuf = malloc(rcvcmsgbuflen); if (rcvcmsgbuf == NULL) fatal("malloc"); sndcmsgbuflen = CMSG_SPACE(sizeof(struct in6_pktinfo)) + CMSG_SPACE(sizeof(int)); - sndcmsgbuf = (u_char *)malloc(sndcmsgbuflen); + sndcmsgbuf = malloc(sndcmsgbuflen); if (sndcmsgbuf == NULL) fatal("malloc"); diff --git a/usr.sbin/sasyncd/conf.y b/usr.sbin/sasyncd/conf.y index fb3a0b2b365..5be15a4e5e7 100644 --- a/usr.sbin/sasyncd/conf.y +++ b/usr.sbin/sasyncd/conf.y @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.y,v 1.17 2012/12/21 13:53:01 gsoares Exp $ */ +/* $OpenBSD: conf.y,v 1.18 2015/08/20 22:39:29 deraadt Exp $ */ /* * Copyright (c) 2005 Håkan Olsson. All rights reserved. @@ -33,6 +33,7 @@ #include <ctype.h> #include <fcntl.h> #include <stdio.h> +#include <stdlib.h> #include <string.h> #include <unistd.h> #include <pwd.h> @@ -182,8 +183,7 @@ setting : INTERFACE STRING if (duplicate) free($2); else { - peer = (struct syncpeer *)calloc(1, - sizeof *peer); + peer = calloc(1, sizeof *peer); if (!peer) { log_err("config: calloc(1, %lu) " "failed", sizeof *peer); @@ -372,7 +372,7 @@ conf_parse_file(char *cfgfile) goto bad; conflen = st.st_size; - buf = (char *)malloc(conflen + 1); + buf = malloc(conflen + 1); if (!buf) { log_err("malloc(%d) failed", conflen + 1); close(fd); diff --git a/usr.sbin/sasyncd/monitor.c b/usr.sbin/sasyncd/monitor.c index 27c734ed7ef..a02ab5dc3d0 100644 --- a/usr.sbin/sasyncd/monitor.c +++ b/usr.sbin/sasyncd/monitor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: monitor.c,v 1.19 2015/01/16 06:40:20 deraadt Exp $ */ +/* $OpenBSD: monitor.c,v 1.20 2015/08/20 22:39:29 deraadt Exp $ */ /* * Copyright (c) 2005 Håkan Olsson. All rights reserved. @@ -277,7 +277,7 @@ monitor_get_pfkey_snap(u_int8_t **sadb, u_int32_t *sadbsize, u_int8_t **spd, if (m_read(m_state.s, sadbsize, sizeof *sadbsize) < 1) return -1; if (*sadbsize) { - *sadb = (u_int8_t *)malloc(*sadbsize); + *sadb = malloc(*sadbsize); if (!*sadb) { log_err("monitor_get_pfkey_snap: malloc()"); monitor_drain_input(); @@ -300,7 +300,7 @@ monitor_get_pfkey_snap(u_int8_t **sadb, u_int32_t *sadbsize, u_int8_t **spd, return -1; } if (*spdsize) { - *spd = (u_int8_t *)malloc(*spdsize); + *spd = malloc(*spdsize); if (!*spd) { log_err("monitor_get_pfkey_snap: malloc()"); monitor_drain_input(); diff --git a/usr.sbin/sasyncd/net.c b/usr.sbin/sasyncd/net.c index 3fabe2f05dd..507a7ba3d12 100644 --- a/usr.sbin/sasyncd/net.c +++ b/usr.sbin/sasyncd/net.c @@ -1,4 +1,4 @@ -/* $OpenBSD: net.c,v 1.21 2014/07/04 22:32:29 guenther Exp $ */ +/* $OpenBSD: net.c,v 1.22 2015/08/20 22:39:29 deraadt Exp $ */ /* * Copyright (c) 2005 Håkan Olsson. All rights reserved. @@ -86,7 +86,7 @@ dump_buf(int lvl, u_int8_t *b, u_int32_t len, char *title) return; blen = 2 * (len + len / 36) + 3 + (title ? strlen(title) : sizeof def); - if (!(buf = (u_int8_t *)calloc(1, blen))) + if (!(buf = calloc(1, blen))) return; snprintf(buf, blen, "%s\n ", title ? title : def); @@ -162,7 +162,7 @@ net_setup_listeners(void) /* Setup listening sockets. */ memset(&sa_storage, 0, sizeof sa_storage); if (net_set_sa(sa, cfgstate.listen_on, cfgstate.listen_port) == 0) { - listeners = (int *)calloc(2, sizeof(int)); + listeners = calloc(2, sizeof(int)); if (!listeners) { perror("net_setup_listeners: calloc()"); goto errout; @@ -208,7 +208,7 @@ net_setup_listeners(void) } /* Allocate one extra slot and set to -1, marking end of array. */ - listeners = (int *)calloc(count + 1, sizeof(int)); + listeners = calloc(count + 1, sizeof(int)); if (!listeners) { perror("net_setup_listeners: calloc()"); goto errout; @@ -330,7 +330,7 @@ net_queue(struct syncpeer *p0, u_int32_t msgtype, u_int8_t *buf, u_int32_t len) u_int32_t v, padlen = 0; int i, offset; - m = (struct msg *)calloc(1, sizeof *m); + m = calloc(1, sizeof *m); if (!m) { log_err("net_queue: calloc()"); free(buf); @@ -376,7 +376,7 @@ net_queue(struct syncpeer *p0, u_int32_t msgtype, u_int8_t *buf, u_int32_t len) /* Allocate send buffer */ m->len = len + sizeof iv + sizeof hash + 3 * sizeof(u_int32_t); - m->buf = (u_int8_t *)malloc(m->len); + m->buf = malloc(m->len); if (!m->buf) { free(m); free(buf); @@ -687,7 +687,7 @@ net_read(struct syncpeer *p, u_int32_t *msgtype, u_int32_t *msglen) return NULL; /* Read message blob */ - blob = (u_int8_t *)malloc(blob_len); + blob = malloc(blob_len); if (!blob) { log_err("net_read: malloc()"); return NULL; @@ -725,7 +725,7 @@ net_read(struct syncpeer *p, u_int32_t *msgtype, u_int32_t *msglen) rhash = blob + offset; iv = rhash + sizeof hash; - msg = (u_int8_t *)malloc(*msglen); + msg = malloc(*msglen); if (!msg) { free(blob); return NULL; @@ -807,8 +807,7 @@ net_connect(void) if (p->socket > -1) continue; if (!p->sa) { - p->sa = (void *)calloc(1, - sizeof(struct sockaddr_storage)); + p->sa = calloc(1, sizeof(struct sockaddr_storage)); if (!p->sa) return; if (net_set_sa(p->sa, p->name, cfgstate.listen_port)) diff --git a/usr.sbin/sasyncd/net_ctl.c b/usr.sbin/sasyncd/net_ctl.c index d79052259fc..b8d3296a4b7 100644 --- a/usr.sbin/sasyncd/net_ctl.c +++ b/usr.sbin/sasyncd/net_ctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: net_ctl.c,v 1.9 2010/06/29 18:10:04 kjell Exp $ */ +/* $OpenBSD: net_ctl.c,v 1.10 2015/08/20 22:39:29 deraadt Exp $ */ /* * Copyright (c) 2005 Håkan Olsson. All rights reserved. @@ -155,7 +155,7 @@ net_ctl_handle_msg(struct syncpeer *p, u_int8_t *msg, u_int32_t msglen) static int net_ctl_send(struct syncpeer *p, u_int32_t type, u_int32_t d, u_int32_t d2) { - struct ctlmsg *m = (struct ctlmsg *)malloc(sizeof *m); + struct ctlmsg *m = malloc(sizeof *m); if (!m) { log_err("malloc(%u)", sizeof *m); diff --git a/usr.sbin/sasyncd/pfkey.c b/usr.sbin/sasyncd/pfkey.c index a0ee2d80276..7e91fdc7122 100644 --- a/usr.sbin/sasyncd/pfkey.c +++ b/usr.sbin/sasyncd/pfkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfkey.c,v 1.23 2015/01/16 06:40:20 deraadt Exp $ */ +/* $OpenBSD: pfkey.c,v 1.24 2015/08/20 22:39:29 deraadt Exp $ */ /* * Copyright (c) 2005 Håkan Olsson. All rights reserved. @@ -110,7 +110,7 @@ pfkey_set_promisc(void) static void pfkey_send_flush(struct syncpeer *p) { - struct sadb_msg *m = (struct sadb_msg *)calloc(1, sizeof *m); + struct sadb_msg *m = calloc(1, sizeof *m); static u_int32_t seq = 1; if (m) { @@ -412,7 +412,7 @@ pfkey_queue_message(u_int8_t *data, u_int32_t datalen) struct sadb_msg *sadb = (struct sadb_msg *)data; static u_int32_t seq = 1; - pmsg = (struct pfkey_msg *)malloc(sizeof *pmsg); + pmsg = malloc(sizeof *pmsg); if (!pmsg) { log_err("malloc()"); return -1; @@ -486,7 +486,7 @@ pfkey_snapshot(void *v) continue; /* Allocate msgbuffer, net_queue() will free it. */ - sendbuf = (u_int8_t *)calloc(m->sadb_msg_len, CHUNK); + sendbuf = calloc(m->sadb_msg_len, CHUNK); if (sendbuf) { memcpy(sendbuf, m, m->sadb_msg_len * CHUNK); net_queue(p, MSG_PFKEYDATA, sendbuf, @@ -516,7 +516,7 @@ pfkey_snapshot(void *v) continue; /* Allocate msgbuffer, freed by net_queue(). */ - sendbuf = (u_int8_t *)calloc(m->sadb_msg_len, CHUNK); + sendbuf = calloc(m->sadb_msg_len, CHUNK); if (sendbuf) { memcpy(sendbuf, m, m->sadb_msg_len * CHUNK); net_queue(p, MSG_PFKEYDATA, sendbuf, diff --git a/usr.sbin/sasyncd/sasyncd.c b/usr.sbin/sasyncd/sasyncd.c index 0efefe182a9..ac17dca53b8 100644 --- a/usr.sbin/sasyncd/sasyncd.c +++ b/usr.sbin/sasyncd/sasyncd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sasyncd.c,v 1.23 2012/04/14 12:11:08 haesbaert Exp $ */ +/* $OpenBSD: sasyncd.c,v 1.24 2015/08/20 22:39:29 deraadt Exp $ */ /* * Copyright (c) 2005 Håkan Olsson. All rights reserved. @@ -63,13 +63,13 @@ sasyncd_run(pid_t ppid) n = getdtablesize(); fdsetsize = howmany(n, NFDBITS) * sizeof(fd_mask); - rfds = (fd_set *)malloc(fdsetsize); + rfds = malloc(fdsetsize); if (!rfds) { log_err("malloc(%lu) failed", (unsigned long)fdsetsize); return -1; } - wfds = (fd_set *)malloc(fdsetsize); + wfds = malloc(fdsetsize); if (!wfds) { log_err("malloc(%lu) failed", (unsigned long)fdsetsize); free(rfds); diff --git a/usr.sbin/sasyncd/timer.c b/usr.sbin/sasyncd/timer.c index 86aaa3df271..d31a7a1d1ad 100644 --- a/usr.sbin/sasyncd/timer.c +++ b/usr.sbin/sasyncd/timer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: timer.c,v 1.4 2010/06/29 18:10:04 kjell Exp $ */ +/* $OpenBSD: timer.c,v 1.5 2015/08/20 22:39:29 deraadt Exp $ */ /* * Copyright (c) 2005 Håkan Olsson. All rights reserved. @@ -113,7 +113,7 @@ timer_add(char *name, u_int32_t when, void (*function)(void *), void *arg) struct timeval now, tmp; struct event *e, *new; - new = (struct event *)calloc(1, sizeof *new); + new = calloc(1, sizeof *new); if (!new) { log_err("timer_add: calloc (1, %u) failed", sizeof *new); return -1; diff --git a/usr.sbin/tcpdump/print-tcp.c b/usr.sbin/tcpdump/print-tcp.c index 96730025ad7..9e41bf803e1 100644 --- a/usr.sbin/tcpdump/print-tcp.c +++ b/usr.sbin/tcpdump/print-tcp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-tcp.c,v 1.32 2015/01/16 06:40:21 deraadt Exp $ */ +/* $OpenBSD: print-tcp.c,v 1.33 2015/08/20 22:39:29 deraadt Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 @@ -392,8 +392,7 @@ tcp_print(register const u_char *bp, register u_int length, if (!th->nxt || flags & TH_SYN) { /* didn't find it or new conversation */ if (th->nxt == NULL) { - th->nxt = (struct tcp_seq_hash *) - calloc(1, sizeof(*th)); + th->nxt = calloc(1, sizeof(*th)); if (th->nxt == NULL) error("tcp_print: calloc"); } diff --git a/usr.sbin/user/defs.h b/usr.sbin/user/defs.h index 2891fdda929..18bc9d2f3c9 100644 --- a/usr.sbin/user/defs.h +++ b/usr.sbin/user/defs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: defs.h,v 1.5 2014/12/01 23:08:23 deraadt Exp $ */ +/* $OpenBSD: defs.h,v 1.6 2015/08/20 22:39:29 deraadt Exp $ */ /* $NetBSD: defs.h,v 1.5 1999/12/24 09:08:49 agc Exp $ */ /* @@ -35,7 +35,7 @@ #define DEFS_H_ #define NEWARRAY(type,ptr,size,action) do { \ - if ((ptr = (type *) calloc((size), \ + if ((ptr = calloc((size), \ sizeof(type))) == (type *) NULL) { \ warn("can't allocate %ld bytes", \ (long)((size) * sizeof(type))); \ @@ -44,7 +44,7 @@ } while( /* CONSTCOND */ 0) #define RENEW(type,ptr,size,action) do { \ - if ((ptr = (type *) reallocarray(ptr, \ + if ((ptr = reallocarray(ptr, \ (size), sizeof(type))) == (type *) NULL) { \ warn("can't realloc %ld bytes", \ (long)((size) * sizeof(type))); \ diff --git a/usr.sbin/ypbind/ypbind.c b/usr.sbin/ypbind/ypbind.c index fb06598411b..5ab2140774a 100644 --- a/usr.sbin/ypbind/ypbind.c +++ b/usr.sbin/ypbind/ypbind.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ypbind.c,v 1.63 2015/01/16 06:40:22 deraadt Exp $ */ +/* $OpenBSD: ypbind.c,v 1.64 2015/08/20 22:39:30 deraadt Exp $ */ /* * Copyright (c) 1992, 1993, 1996, 1997, 1998 Theo de Raadt <deraadt@openbsd.org> @@ -153,7 +153,7 @@ ypbindproc_domain_2x(SVCXPRT *transp, domainname *argp, CLIENT *clnt) break; if (ypdb == NULL) { - ypdb = (struct _dom_binding *)malloc(sizeof *ypdb); + ypdb = malloc(sizeof *ypdb); if (ypdb == NULL) return NULL; memset(ypdb, 0, sizeof *ypdb); @@ -512,7 +512,7 @@ main(int argc, char *argv[]) errx(1, "bad domainname %s", domain); /* build initial domain binding, make it "unsuccessful" */ - ypbindlist = (struct _dom_binding *)malloc(sizeof *ypbindlist); + ypbindlist = malloc(sizeof *ypbindlist); if (ypbindlist == NULL) errx(1, "no memory"); memset(ypbindlist, 0, sizeof *ypbindlist); @@ -545,8 +545,7 @@ main(int argc, char *argv[]) width = rpcsock; if (pingsock > __svc_fdsetsize) width = pingsock; - fdsrp = (fd_set *)calloc(howmany(width+1, NFDBITS), - sizeof(fd_mask)); + fdsrp = calloc(howmany(width+1, NFDBITS), sizeof(fd_mask)); if (fdsrp == NULL) errx(1, "no memory"); } @@ -990,7 +989,7 @@ rpc_received(char *dom, struct sockaddr_in *raddrp, int force) if (ypdb == NULL) { if (force == 0) return; - ypdb = (struct _dom_binding *)malloc(sizeof *ypdb); + ypdb = malloc(sizeof *ypdb); if (ypdb == NULL) return; memset(ypdb, 0, sizeof *ypdb); diff --git a/usr.sbin/ztsscale/ztsscale.c b/usr.sbin/ztsscale/ztsscale.c index 394a123279b..ef5e268fbe5 100644 --- a/usr.sbin/ztsscale/ztsscale.c +++ b/usr.sbin/ztsscale/ztsscale.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ztsscale.c,v 1.18 2015/01/16 06:40:23 deraadt Exp $ */ +/* $OpenBSD: ztsscale.c,v 1.19 2015/08/20 22:39:30 deraadt Exp $ */ /* * Copyright (c) 2005 Matthieu Herrb @@ -135,7 +135,7 @@ save_screen(void) PROT_READ|PROT_WRITE, MAP_SHARED, fd, (off_t)0); if (mapaddr == MAP_FAILED) err(2, "mmap"); - save = (u_short *)malloc(WIDTH*HEIGHT*sizeof(u_short)); + save = malloc(WIDTH*HEIGHT*sizeof(u_short)); if (save == NULL) err(2, "malloc"); memcpy(save, mapaddr, WIDTH*HEIGHT*sizeof(u_short)); |