diff options
author | 2014-06-09 13:13:48 +0000 | |
---|---|---|
committer | 2014-06-09 13:13:48 +0000 | |
commit | 210008b3130591ff79d2d5024ffeaba6feea47ff (patch) | |
tree | 70f086223637682b9fabcc0405785eb6ab04ab26 | |
parent | Split the 88100 floating point support code in two files, one for the precise (diff) | |
download | wireguard-openbsd-210008b3130591ff79d2d5024ffeaba6feea47ff.tar.xz wireguard-openbsd-210008b3130591ff79d2d5024ffeaba6feea47ff.zip |
Use calloc() instead of malloc()/memset().
From Benjamin Baier.
-rw-r--r-- | usr.sbin/installboot/bootstrap.c | 5 | ||||
-rw-r--r-- | usr.sbin/installboot/i386_softraid.c | 5 | ||||
-rw-r--r-- | usr.sbin/installboot/sparc64_installboot.c | 7 |
3 files changed, 7 insertions, 10 deletions
diff --git a/usr.sbin/installboot/bootstrap.c b/usr.sbin/installboot/bootstrap.c index 7e4f35b773d..48a2998ad00 100644 --- a/usr.sbin/installboot/bootstrap.c +++ b/usr.sbin/installboot/bootstrap.c @@ -68,10 +68,9 @@ bootstrap(int devfd, char *dev, char *bootfile) fprintf(stderr, "bootstrap is %zu bytes " "(%zu sectors @ %u bytes = %zu bytes)\n", (ssize_t)sb.st_size, bootsec, dl.d_secsize, bootsize); - boot = malloc(bootsize); + boot = calloc(1, bootsize); if (boot == NULL) - err(1, "malloc"); - memset(boot, 0, bootsize); + err(1, "calloc"); if (read(fd, boot, bootsize) != (ssize_t)sb.st_size) err(1, "read"); close(fd); diff --git a/usr.sbin/installboot/i386_softraid.c b/usr.sbin/installboot/i386_softraid.c index c2409744fda..a5a05807387 100644 --- a/usr.sbin/installboot/i386_softraid.c +++ b/usr.sbin/installboot/i386_softraid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: i386_softraid.c,v 1.1 2014/01/19 02:58:50 jsing Exp $ */ +/* $OpenBSD: i386_softraid.c,v 1.2 2014/06/09 13:13:48 jsing Exp $ */ /* * Copyright (c) 2012 Joel Sing <jsing@openbsd.org> * @@ -129,11 +129,10 @@ sr_install_bootldr(int devfd, char *dev) inodeblk = nblocks - 1; bootsize = nblocks * SR_FS_BLOCKSIZE; - p = malloc(bootsize); + p = calloc(1, bootsize); if (p == NULL) err(1, NULL); - memset(p, 0, bootsize); fd = open(stage2, O_RDONLY, 0); if (fd == -1) err(1, NULL); diff --git a/usr.sbin/installboot/sparc64_installboot.c b/usr.sbin/installboot/sparc64_installboot.c index 1a82392affb..cc2f48da497 100644 --- a/usr.sbin/installboot/sparc64_installboot.c +++ b/usr.sbin/installboot/sparc64_installboot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sparc64_installboot.c,v 1.1 2014/01/19 02:58:50 jsing Exp $ */ +/* $OpenBSD: sparc64_installboot.c,v 1.2 2014/06/09 13:13:48 jsing Exp $ */ /* * Copyright (c) 2012, 2013 Joel Sing <jsing@openbsd.org> @@ -68,10 +68,9 @@ md_loadboot(void) if (blksize > SBSIZE - DEV_BSIZE) errx(1, "boot blocks too big (%zu > %d)", blksize, SBSIZE - DEV_BSIZE); - blkstore = malloc(blksize); + blkstore = calloc(1, blksize); if (blkstore == NULL) - err(1, "malloc"); - memset(blkstore, 0, blksize); + err(1, "calloc"); if (read(fd, blkstore, sb.st_size) != (ssize_t)sb.st_size) err(1, "read"); close(fd); |