From 905d53ad9a6a69f6e4b51bd5613b39a9747bba45 Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 14 May 2016 04:00:17 +0000 Subject: [PATCH] Fold two malloc + memset(.., 0, ..) calls into equivalent calloc calls MFC after: 3 weeks Sponsored by: EMC / Isilon Storage Division --- usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpimport.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpimport.c b/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpimport.c index 4ced51eb9655..de5a60b3022b 100644 --- a/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpimport.c +++ b/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpimport.c @@ -635,12 +635,11 @@ snmp_import_table(struct snmp_toolinfo *snmptoolctx, struct snmp_oid2str *obj) enum tok tok; struct snmp_index_entry *entry; - if ((entry = malloc(sizeof(struct snmp_index_entry))) == NULL) { + if ((entry = calloc(1, sizeof(struct snmp_index_entry))) == NULL) { syslog(LOG_ERR, "malloc() failed: %s", strerror(errno)); return (-1); } - memset(entry, 0, sizeof(struct snmp_index_entry)); STAILQ_INIT(&(entry->index_list)); for (i = 0, tok = gettoken(snmptoolctx); i < SNMP_INDEXES_MAX; i++) { @@ -764,7 +763,7 @@ snmp_import_object(struct snmp_toolinfo *snmptoolctx) if (snmp_import_head(snmptoolctx) < 0) return (-1); - if ((oid2str = malloc(sizeof(struct snmp_oid2str))) == NULL) { + if ((oid2str = calloc(1, sizeof(struct snmp_oid2str))) == NULL) { syslog(LOG_ERR, "malloc() failed: %s", strerror(errno)); return (-1); } @@ -775,7 +774,6 @@ snmp_import_object(struct snmp_toolinfo *snmptoolctx) return (-1); } - memset(oid2str, 0, sizeof(struct snmp_oid2str)); strlcpy(string, nexttok, strlen(nexttok) + 1); oid2str->string = string; oid2str->strlen = strlen(nexttok);