diff options
author | Sebastien Marie <semarie@cvs.openbsd.org> | 2015-09-08 04:28:35 +0000 |
---|---|---|
committer | Sebastien Marie <semarie@cvs.openbsd.org> | 2015-09-08 04:28:35 +0000 |
commit | 16414ff834b8904432e33c05c8a65a2fa7c5a44a (patch) | |
tree | 51a4c713152e9967b61812805844cf6a80bbd624 /sys/arch/amd64 | |
parent | 751a0fce1083a787f8b3a4a3622a921951968a29 (diff) |
convert several malloc(9) to mallocarray(9).
ok deraadt@ guenther@ "re-wrap the long lines" kettenis@
Diffstat (limited to 'sys/arch/amd64')
-rw-r--r-- | sys/arch/amd64/amd64/est.c | 6 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/mem.c | 7 |
2 files changed, 6 insertions, 7 deletions
diff --git a/sys/arch/amd64/amd64/est.c b/sys/arch/amd64/amd64/est.c index 7f9900485a0..2e0b1c16524 100644 --- a/sys/arch/amd64/amd64/est.c +++ b/sys/arch/amd64/amd64/est.c @@ -1,4 +1,4 @@ -/* $OpenBSD: est.c,v 1.37 2015/08/28 00:03:53 deraadt Exp $ */ +/* $OpenBSD: est.c,v 1.38 2015/09/08 04:28:34 semarie Exp $ */ /* * Copyright (c) 2003 Michael Eriksson. * All rights reserved. @@ -379,8 +379,8 @@ est_init(struct cpu_info *ci) } - if ((fake_table = malloc(sizeof(struct est_op) * 3, M_DEVBUF, - M_NOWAIT)) == NULL) { + if ((fake_table = mallocarray(3, sizeof(struct est_op), + M_DEVBUF, M_NOWAIT)) == NULL) { free(fake_fqlist, M_DEVBUF, sizeof(struct fqlist)); printf("%s: EST: cannot allocate memory for fake " "table\n", cpu_device); diff --git a/sys/arch/amd64/amd64/mem.c b/sys/arch/amd64/amd64/mem.c index 66dd603c77f..4f22d1f2760 100644 --- a/sys/arch/amd64/amd64/mem.c +++ b/sys/arch/amd64/amd64/mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mem.c,v 1.27 2015/08/29 12:30:30 sthen Exp $ */ +/* $OpenBSD: mem.c,v 1.28 2015/09/08 04:28:34 semarie Exp $ */ /* * Copyright (c) 1988 University of Utah. * Copyright (c) 1982, 1986, 1990, 1993 @@ -278,9 +278,8 @@ mem_ioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) case MEMRANGE_GET: nd = imin(mo->mo_arg[0], mem_range_softc.mr_ndesc); if (nd > 0) { - md = (struct mem_range_desc *) - malloc(nd * sizeof(struct mem_range_desc), - M_MEMDESC, M_WAITOK); + md = mallocarray(nd, sizeof(struct mem_range_desc), + M_MEMDESC, M_WAITOK); error = mem_range_attr_get(md, &nd); if (!error) error = copyout(md, mo->mo_desc, |