From: tedu Date: Tue, 22 Apr 2014 20:42:01 +0000 (+0000) Subject: malloc/memset -> calloc. from peter malone X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=f9b0dfcf0ddd89f9bfad21b31e8c948f509b5a5b;p=openbsd malloc/memset -> calloc. from peter malone --- diff --git a/sbin/bioctl/bioctl.c b/sbin/bioctl/bioctl.c index a3d68c18118..cfd5b243cb2 100644 --- a/sbin/bioctl/bioctl.c +++ b/sbin/bioctl/bioctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bioctl.c,v 1.119 2014/01/18 09:11:12 jsing Exp $ */ +/* $OpenBSD: bioctl.c,v 1.120 2014/04/22 20:42:01 tedu Exp $ */ /* * Copyright (c) 2004, 2005 Marco Peereboom @@ -836,10 +836,9 @@ bio_createraid(u_int16_t level, char *dev_list, char *key_disk) } else #endif /* AOE */ { - dt = (dev_t *)malloc(BIOC_CRMAXLEN); + dt = calloc(1, BIOC_CRMAXLEN); if (!dt) err(1, "not enough memory for dev_t list"); - memset(dt, 0, BIOC_CRMAXLEN); no_dev = bio_parse_devlist(dev_list, dt); } diff --git a/sbin/dmesg/dmesg.c b/sbin/dmesg/dmesg.c index f9adf239c53..35fe2d81ef4 100644 --- a/sbin/dmesg/dmesg.c +++ b/sbin/dmesg/dmesg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dmesg.c,v 1.22 2010/07/02 22:02:06 deraadt Exp $ */ +/* $OpenBSD: dmesg.c,v 1.23 2014/04/22 20:43:12 tedu Exp $ */ /* $NetBSD: dmesg.c,v 1.8 1995/03/18 14:54:49 cgd Exp $ */ /*- @@ -95,11 +95,10 @@ main(int argc, char *argv[]) err(1, "sysctl: KERN_MSGBUFSIZE"); msgbufsize += sizeof(struct msgbuf) - 1; - bufdata = malloc(msgbufsize); + bufdata = calloc(1, msgbufsize); if (bufdata == NULL) errx(1, "couldn't allocate space for buffer data"); - memset(bufdata, 0, msgbufsize); mib[1] = KERN_MSGBUF; len = msgbufsize; if (sysctl(mib, 2, bufdata, &len, NULL, 0))