diff options
author | ngie <ngie@FreeBSD.org> | 2017-01-09 01:08:43 +0000 |
---|---|---|
committer | ngie <ngie@FreeBSD.org> | 2017-01-09 01:08:43 +0000 |
commit | d9fd0c833cb99a6b80f3dcc2af1b292914d7b707 (patch) | |
tree | 7c0430973b8d6e95294e25e3f9c1c3f8917e2534 /contrib/bsnmp | |
parent | 50fbe764d5e4b2f76f5248fd311e24b90867c360 (diff) | |
download | FreeBSD-src-d9fd0c833cb99a6b80f3dcc2af1b292914d7b707.zip FreeBSD-src-d9fd0c833cb99a6b80f3dcc2af1b292914d7b707.tar.gz |
MFC r311382:
Use calloc instead of malloc + memset(.., 0, ..)
Diffstat (limited to 'contrib/bsnmp')
-rw-r--r-- | contrib/bsnmp/snmpd/trans_lsock.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/contrib/bsnmp/snmpd/trans_lsock.c b/contrib/bsnmp/snmpd/trans_lsock.c index 1b4b2df..6c168ac 100644 --- a/contrib/bsnmp/snmpd/trans_lsock.c +++ b/contrib/bsnmp/snmpd/trans_lsock.c @@ -143,16 +143,14 @@ lsock_open_port(u_char *name, size_t namelen, struct lsock_port **pp, return (SNMP_ERR_BADVALUE); } - if ((port = malloc(sizeof(*port))) == NULL) + if ((port = calloc(1, sizeof(*port))) == NULL) return (SNMP_ERR_GENERR); - memset(port, 0, sizeof(*port)); if (!is_stream) { - if ((peer = malloc(sizeof(*peer))) == NULL) { + if ((peer = calloc(1, sizeof(*peer))) == NULL) { free(port); return (SNMP_ERR_GENERR); } - memset(peer, 0, sizeof(*peer)); } if ((port->name = malloc(namelen + 1)) == NULL) { free(port); @@ -258,12 +256,11 @@ lsock_listen_input(int fd, void *udata) struct lsock_port *p = udata; struct lsock_peer *peer; - if ((peer = malloc(sizeof(*peer))) == NULL) { + if ((peer = calloc(1, sizeof(*peer))) == NULL) { syslog(LOG_WARNING, "%s: peer malloc failed", p->name); (void)close(accept(fd, NULL, NULL)); return; } - memset(peer, 0, sizeof(*peer)); peer->port = p; |