diff options
author | dwmalone <dwmalone@FreeBSD.org> | 2000-12-08 21:51:06 +0000 |
---|---|---|
committer | dwmalone <dwmalone@FreeBSD.org> | 2000-12-08 21:51:06 +0000 |
commit | dd75d1d73b4f3034c1d9f621a49fff58b1d71eb1 (patch) | |
tree | 197ae73617ae75afe008897f6906b84835589ea2 /sys/netinet | |
parent | ed5dbfbd3cd619638a7baac288f548aa1398edac (diff) | |
download | FreeBSD-src-dd75d1d73b4f3034c1d9f621a49fff58b1d71eb1.zip FreeBSD-src-dd75d1d73b4f3034c1d9f621a49fff58b1d71eb1.tar.gz |
Convert more malloc+bzero to malloc+M_ZERO.
Submitted by: josh@zipperup.org
Submitted by: Robert Drehmel <robd@gmx.net>
Diffstat (limited to 'sys/netinet')
-rw-r--r-- | sys/netinet/in.c | 7 | ||||
-rw-r--r-- | sys/netinet/in_hostcache.c | 4 | ||||
-rw-r--r-- | sys/netinet/in_pcb.c | 8 | ||||
-rw-r--r-- | sys/netinet/ip_dummynet.c | 16 | ||||
-rw-r--r-- | sys/netinet/ip_fw.c | 9 | ||||
-rw-r--r-- | sys/netinet/tcp_input.c | 3 | ||||
-rw-r--r-- | sys/netinet/tcp_reass.c | 3 |
7 files changed, 20 insertions, 30 deletions
diff --git a/sys/netinet/in.c b/sys/netinet/in.c index 7dcfe87..f8d591e 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -283,10 +283,9 @@ in_control(so, cmd, data, ifp, p) return (EADDRNOTAVAIL); if (ia == (struct in_ifaddr *)0) { ia = (struct in_ifaddr *) - malloc(sizeof *ia, M_IFADDR, M_WAITOK); + malloc(sizeof *ia, M_IFADDR, M_WAITOK | M_ZERO); if (ia == (struct in_ifaddr *)NULL) return (ENOBUFS); - bzero((caddr_t)ia, sizeof *ia); /* * Protect from ipintr() traversing address list * while we're modifying it. @@ -802,13 +801,13 @@ in_addmulti(ap, ifp) /* XXX - if_addmulti uses M_WAITOK. Can this really be called at interrupt time? If so, need to fix if_addmulti. XXX */ - inm = (struct in_multi *)malloc(sizeof(*inm), M_IPMADDR, M_NOWAIT); + inm = (struct in_multi *)malloc(sizeof(*inm), M_IPMADDR, + M_NOWAIT | M_ZERO); if (inm == NULL) { splx(s); return (NULL); } - bzero(inm, sizeof *inm); inm->inm_addr = *ap; inm->inm_ifp = ifp; inm->inm_ifma = ifma; diff --git a/sys/netinet/in_hostcache.c b/sys/netinet/in_hostcache.c index 33e0187..36a92fd 100644 --- a/sys/netinet/in_hostcache.c +++ b/sys/netinet/in_hostcache.c @@ -78,8 +78,8 @@ inhc_alloc(struct sockaddr_in *sin) if (rt == 0) return 0; - MALLOC(inhc, struct in_hcentry *, sizeof *inhc, M_HOSTCACHE, M_WAITOK); - bzero(inhc, sizeof *inhc); + MALLOC(inhc, struct in_hcentry *, sizeof *inhc, M_HOSTCACHE, + M_WAITOK | M_ZERO); inhc->inhc_hc.hc_host = dup_sockaddr((struct sockaddr *)sin, 1); if (in_broadcast(sin->sin_addr, rt->rt_ifp)) inhc->inhc_flags |= INHC_BROADCAST; diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index 4fc9b92..fd0f248 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -605,8 +605,8 @@ in_setsockaddr(so, nam) /* * Do the malloc first in case it blocks. */ - MALLOC(sin, struct sockaddr_in *, sizeof *sin, M_SONAME, M_WAITOK); - bzero(sin, sizeof *sin); + MALLOC(sin, struct sockaddr_in *, sizeof *sin, M_SONAME, + M_WAITOK | M_ZERO); sin->sin_family = AF_INET; sin->sin_len = sizeof(*sin); @@ -637,8 +637,8 @@ in_setpeeraddr(so, nam) /* * Do the malloc first in case it blocks. */ - MALLOC(sin, struct sockaddr_in *, sizeof *sin, M_SONAME, M_WAITOK); - bzero(sin, sizeof (*sin)); + MALLOC(sin, struct sockaddr_in *, sizeof *sin, M_SONAME, + M_WAITOK | M_ZERO); sin->sin_family = AF_INET; sin->sin_len = sizeof(*sin); diff --git a/sys/netinet/ip_dummynet.c b/sys/netinet/ip_dummynet.c index f8882bb..ed43449 100644 --- a/sys/netinet/ip_dummynet.c +++ b/sys/netinet/ip_dummynet.c @@ -751,12 +751,11 @@ create_queue(struct dn_flow_set *fs, int i) if ( fs->rq[i] != NULL ) return fs->rq[i] ; } - q = malloc(sizeof(*q), M_IPFW, M_DONTWAIT) ; + q = malloc(sizeof(*q), M_IPFW, M_DONTWAIT | M_ZERO); /* M_ZERO needed */ if (q == NULL) { printf("sorry, cannot allocate queue for new flow\n"); return NULL ; } - bzero(q, sizeof(*q) ); /* needed */ q->fs = fs ; q->hash_slot = i ; q->next = fs->rq[i] ; @@ -1011,11 +1010,11 @@ dummynet_io(int pipe_nr, int dir, /* pipe_nr can also be a fs_nr */ if ( fs->flags_fs & DN_IS_RED && red_drops(fs, q, len) ) goto dropit ; - pkt = (struct dn_pkt *)malloc(sizeof (*pkt), M_IPFW, M_NOWAIT) ; + /* XXX expensive to zero, see if we can remove it*/ + pkt = (struct dn_pkt *)malloc(sizeof (*pkt), M_IPFW, M_NOWAIT | M_ZERO); if ( pkt == NULL ) goto dropit ; /* cannot allocate packet header */ /* ok, i can handle the pkt now... */ - bzero(pkt, sizeof(*pkt) ); /* XXX expensive, see if we can remove it*/ /* build and enqueue packet + parameters */ pkt->hdr.mh_type = MT_DUMMYNET ; (struct ip_fw_chain *)pkt->hdr.mh_data = rule ; @@ -1322,12 +1321,11 @@ alloc_hash(struct dn_flow_set *x, struct dn_flow_set *pfs) } else /* one is enough for null mask */ x->rq_size = 1; x->rq = malloc((1 + x->rq_size) * sizeof(struct dn_flow_queue *), - M_IPFW, M_DONTWAIT); + M_IPFW, M_DONTWAIT | M_ZERO); if (x->rq == NULL) { printf("sorry, cannot allocate queue\n"); return ENOSPC; } - bzero(x->rq, (1+x->rq_size) * sizeof(struct dn_flow_queue *)); x->rq_elements = 0; return 0 ; } @@ -1382,12 +1380,11 @@ config_pipe(struct dn_pipe *p) a = b , b = b->next) ; if (b == NULL || b->pipe_nr != p->pipe_nr) { /* new pipe */ - x = malloc(sizeof(struct dn_pipe), M_IPFW, M_DONTWAIT) ; + x = malloc(sizeof(struct dn_pipe), M_IPFW, M_DONTWAIT | M_ZERO); if (x == NULL) { printf("ip_dummynet.c: no memory for new pipe\n"); return ENOSPC; } - bzero(x, sizeof(struct dn_pipe)); x->pipe_nr = p->pipe_nr; x->fs.pipe = x ; x->backlogged_heap.size = x->backlogged_heap.elements = 0 ; @@ -1427,12 +1424,11 @@ config_pipe(struct dn_pipe *p) if (b == NULL || b->fs_nr != pfs->fs_nr) { /* new */ if (pfs->parent_nr == 0) /* need link to a pipe */ return EINVAL ; - x = malloc(sizeof(struct dn_flow_set), M_IPFW, M_DONTWAIT); + x = malloc(sizeof(struct dn_flow_set), M_IPFW, M_DONTWAIT | M_ZERO); if (x == NULL) { printf("ip_dummynet.c: no memory for new flow_set\n"); return ENOSPC; } - bzero(x, sizeof(struct dn_flow_set)); x->fs_nr = pfs->fs_nr; x->parent_nr = pfs->parent_nr; x->weight = pfs->weight ; diff --git a/sys/netinet/ip_fw.c b/sys/netinet/ip_fw.c index fbbaa9e..7e69223 100644 --- a/sys/netinet/ip_fw.c +++ b/sys/netinet/ip_fw.c @@ -804,20 +804,18 @@ add_dyn_rule(struct ipfw_flow_id *id, struct ipfw_flow_id *mask, if (ipfw_dyn_v != NULL) free(ipfw_dyn_v, M_IPFW); ipfw_dyn_v = malloc(curr_dyn_buckets * sizeof r, - M_IPFW, M_DONTWAIT); + M_IPFW, M_DONTWAIT | M_ZERO); if (ipfw_dyn_v == NULL) return ; /* failed ! */ - bzero(ipfw_dyn_v, curr_dyn_buckets * sizeof r); } } i = hash_packet(id); - r = malloc(sizeof *r, M_IPFW, M_DONTWAIT); + r = malloc(sizeof *r, M_IPFW, M_DONTWAIT | M_ZERO); if (r == NULL) { printf ("sorry cannot allocate state\n"); return ; } - bzero (r, sizeof (*r) ); if (mask) r->mask = *mask ; @@ -1465,7 +1463,7 @@ add_entry(struct ip_fw_head *chainptr, struct ip_fw *frwl) int s; fwc = malloc(sizeof *fwc, M_IPFW, M_DONTWAIT); - ftmp_ext = malloc(sizeof *ftmp_ext, M_IPFW, M_DONTWAIT); + ftmp_ext = malloc(sizeof *ftmp_ext, M_IPFW, M_DONTWAIT | M_ZERO); ftmp = &ftmp_ext->rule ; if (!fwc || !ftmp) { dprintf(("%s malloc said no\n", err_prefix)); @@ -1474,7 +1472,6 @@ add_entry(struct ip_fw_head *chainptr, struct ip_fw *frwl) return (ENOSPC); } - bzero(ftmp_ext, sizeof(*ftmp_ext)); /* play safe! */ bcopy(frwl, ftmp, sizeof(*ftmp)); if (ftmp->fw_flg & IP_FW_F_RND_MATCH) ftmp_ext->dont_match_prob = (intptr_t)ftmp->pipe_ptr; diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index 1f7d0fb..cb7e05e 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -1050,10 +1050,9 @@ findpcb: #ifdef INET6 if (isipv6) { MALLOC(sin6, struct sockaddr_in6 *, sizeof *sin6, - M_SONAME, M_NOWAIT); + M_SONAME, M_NOWAIT | M_ZERO); if (sin6 == NULL) goto drop; - bzero(sin6, sizeof(*sin6)); sin6->sin6_family = AF_INET6; sin6->sin6_len = sizeof(*sin6); sin6->sin6_addr = ip6->ip6_src; diff --git a/sys/netinet/tcp_reass.c b/sys/netinet/tcp_reass.c index 1f7d0fb..cb7e05e 100644 --- a/sys/netinet/tcp_reass.c +++ b/sys/netinet/tcp_reass.c @@ -1050,10 +1050,9 @@ findpcb: #ifdef INET6 if (isipv6) { MALLOC(sin6, struct sockaddr_in6 *, sizeof *sin6, - M_SONAME, M_NOWAIT); + M_SONAME, M_NOWAIT | M_ZERO); if (sin6 == NULL) goto drop; - bzero(sin6, sizeof(*sin6)); sin6->sin6_family = AF_INET6; sin6->sin6_len = sizeof(*sin6); sin6->sin6_addr = ip6->ip6_src; |