From 6047e12ca5c1072eeccb2925044af48f3db4c10c Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Sun, 15 May 2016 00:40:05 +0000 Subject: [PATCH] Replace malloc + memset(.., 0, ..) with calloc calls MFC after: 1 week Sponsored by: EMC / Isilon Storage Division --- usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpmap.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpmap.c b/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpmap.c index 07fc83be18f0..7e2b721e6ece 100644 --- a/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpmap.c +++ b/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpmap.c @@ -55,12 +55,11 @@ snmp_mapping_init(void) { struct snmp_mappings *m; - if ((m = malloc(sizeof(struct snmp_mappings))) == NULL) { + if ((m = calloc(1, sizeof(struct snmp_mappings))) == NULL) { syslog(LOG_ERR, "malloc() failed: %s", strerror(errno)); return (NULL); } - memset(m, 0, sizeof(struct snmp_mappings)); return (m); } @@ -478,13 +477,11 @@ snmp_syntax_insert(struct snmp_idxlist *headp, struct enum_pairs *enums, { struct index *idx; - if ((idx = malloc(sizeof(struct index))) == NULL) { + if ((idx = calloc(1, sizeof(struct index))) == NULL) { syslog(LOG_ERR, "malloc() failed: %s", strerror(errno)); return (-1); } - memset(idx, 0, sizeof(struct index)); - if (snmp_index_insert(headp, idx) < 0) { free(idx); return (-1);