From ee353af9ca6a214d130ac4c31183f294949ab49a Mon Sep 17 00:00:00 2001 From: tedu Date: Wed, 7 May 2014 01:14:21 +0000 Subject: [PATCH] use calloc. from Peter Malone --- lib/libusbhid/parse.c | 5 ++--- usr.sbin/npppd/l2tp/l2tpd.c | 9 ++++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/libusbhid/parse.c b/lib/libusbhid/parse.c index 08ac1864d9a..0a0bfe7a84d 100644 --- a/lib/libusbhid/parse.c +++ b/lib/libusbhid/parse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.c,v 1.7 2012/07/16 19:57:17 jasper Exp $ */ +/* $OpenBSD: parse.c,v 1.8 2014/05/07 01:14:21 tedu Exp $ */ /* $NetBSD: parse.c,v 1.2 2001/12/29 20:44:22 augustss Exp $ */ /* @@ -91,10 +91,9 @@ hid_start_parse(report_desc_t d, int kindset, int id) { struct hid_data *s; - s = malloc(sizeof *s); + s = calloc(1, sizeof *s); if (s == NULL) return (NULL); - memset(s, 0, sizeof *s); s->start = s->p = d->data; s->end = d->data + d->size; s->kindset = kindset; diff --git a/usr.sbin/npppd/l2tp/l2tpd.c b/usr.sbin/npppd/l2tp/l2tpd.c index 2dd8827ec32..f1e9d74a9d6 100644 --- a/usr.sbin/npppd/l2tp/l2tpd.c +++ b/usr.sbin/npppd/l2tp/l2tpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: l2tpd.c,v 1.14 2014/03/22 04:32:39 yasuoka Exp $ */ +/* $OpenBSD: l2tpd.c,v 1.15 2014/05/07 01:16:15 tedu Exp $ */ /*- * Copyright (c) 2009 Internet Initiative Japan Inc. @@ -26,7 +26,7 @@ * SUCH DAMAGE. */ /**@file L2TP(Layer Two Tunneling Protocol "L2TP") / RFC2661 */ -/* $Id: l2tpd.c,v 1.14 2014/03/22 04:32:39 yasuoka Exp $ */ +/* $Id: l2tpd.c,v 1.15 2014/05/07 01:16:15 tedu Exp $ */ #include #include #include @@ -162,12 +162,11 @@ l2tpd_add_listener(l2tpd *_this, int idx, struct l2tp_conf *conf, __func__, slist_length(&_this->listener), idx); goto fail; } - if ((plistener = malloc(sizeof(l2tpd_listener))) == NULL) { - l2tpd_log(_this, LOG_ERR, "malloc() failed in %s: %m", + if ((plistener = calloc(1, sizeof(l2tpd_listener))) == NULL) { + l2tpd_log(_this, LOG_ERR, "calloc() failed in %s: %m", __func__); goto fail; } - memset(plistener, 0, sizeof(l2tpd_listener)); L2TPD_ASSERT(sizeof(plistener->bind) >= addr->sa_len); memcpy(&plistener->bind, addr, addr->sa_len); -- 2.20.1