svn commit: r299711 - head/usr.sbin/bsnmpd/tools/libbsnmptools
Garrett Cooper
ngie at FreeBSD.org
Sat May 14 04:00:18 UTC 2016
Author: ngie
Date: Sat May 14 04:00:17 2016
New Revision: 299711
URL: https://svnweb.freebsd.org/changeset/base/299711
Log:
Fold two malloc + memset(.., 0, ..) calls into equivalent calloc calls
MFC after: 3 weeks
Sponsored by: EMC / Isilon Storage Division
Modified:
head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpimport.c
Modified: head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpimport.c
==============================================================================
--- head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpimport.c Sat May 14 03:57:18 2016 (r299710)
+++ head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpimport.c Sat May 14 04:00:17 2016 (r299711)
@@ -635,12 +635,11 @@ snmp_import_table(struct snmp_toolinfo *
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
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
return (-1);
}
- memset(oid2str, 0, sizeof(struct snmp_oid2str));
strlcpy(string, nexttok, strlen(nexttok) + 1);
oid2str->string = string;
oid2str->strlen = strlen(nexttok);
More information about the svn-src-all
mailing list