summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authornia <nia@NetBSD.org>2021-10-30 10:34:18 +0000
committernia <nia@NetBSD.org>2021-10-30 10:34:18 +0000
commitb22e765bffe0dc4b7118d677aa8bb2d7daf85d43 (patch)
tree94087124c846224080cc2394418060e029c1db8d /lib
parent09cbc758adf3710049ec26abb4901f38ee196072 (diff)
puffs(3): Replace realloc(x * y) with reallocarr
Diffstat (limited to 'lib')
-rw-r--r--lib/libpuffs/framebuf.c11
-rw-r--r--lib/libpuffs/puffs.c12
2 files changed, 12 insertions, 11 deletions
diff --git a/lib/libpuffs/framebuf.c b/lib/libpuffs/framebuf.c
index 247cef1d0b4..41ba35656e3 100644
--- a/lib/libpuffs/framebuf.c
+++ b/lib/libpuffs/framebuf.c
@@ -1,4 +1,4 @@
-/* $NetBSD: framebuf.c,v 1.35 2017/06/14 16:39:41 christos Exp $ */
+/* $NetBSD: framebuf.c,v 1.36 2021/10/30 10:34:18 nia Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#if !defined(lint)
-__RCSID("$NetBSD: framebuf.c,v 1.35 2017/06/14 16:39:41 christos Exp $");
+__RCSID("$NetBSD: framebuf.c,v 1.36 2021/10/30 10:34:18 nia Exp $");
#endif /* !lint */
#include <sys/types.h>
@@ -778,16 +778,15 @@ puffs__framev_addfd_ctrl(struct puffs_usermount *pu, int fd, int what,
struct puffs_framectrl *pfctrl)
{
struct puffs_fctrl_io *fio;
- struct kevent *newevs;
struct kevent kev[2];
size_t nevs;
int rv, readenable;
nevs = pu->pu_nevs+2;
- newevs = realloc(pu->pu_evs, nevs*sizeof(struct kevent));
- if (newevs == NULL)
+ if (reallocarr(&pu->pu_evs, nevs, sizeof(struct kevent)) != 0) {
+ errno = ENOMEM;
return -1;
- pu->pu_evs = newevs;
+ }
fio = malloc(sizeof(struct puffs_fctrl_io));
if (fio == NULL)
diff --git a/lib/libpuffs/puffs.c b/lib/libpuffs/puffs.c
index 100200a1e4e..826bbad9a98 100644
--- a/lib/libpuffs/puffs.c
+++ b/lib/libpuffs/puffs.c
@@ -1,4 +1,4 @@
-/* $NetBSD: puffs.c,v 1.124 2018/06/30 16:05:44 christos Exp $ */
+/* $NetBSD: puffs.c,v 1.125 2021/10/30 10:34:18 nia Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#if !defined(lint)
-__RCSID("$NetBSD: puffs.c,v 1.124 2018/06/30 16:05:44 christos Exp $");
+__RCSID("$NetBSD: puffs.c,v 1.125 2021/10/30 10:34:18 nia Exp $");
#endif /* !lint */
#include <sys/param.h>
@@ -962,12 +962,14 @@ puffs_mainloop(struct puffs_usermount *pu)
goto out;
nevs = pu->pu_nevs + sigcatch;
- curev = realloc(pu->pu_evs, nevs * sizeof(struct kevent));
- if (curev == NULL)
+ if (reallocarr(&pu->pu_evs, nevs, sizeof(struct kevent)) != 0) {
+ errno = ENOMEM;
goto out;
- pu->pu_evs = curev;
+ }
pu->pu_nevs = nevs;
+ curev = pu->pu_evs;
+
LIST_FOREACH(fio, &pu->pu_ios, fio_entries) {
EV_SET(curev, fio->io_fd, EVFILT_READ, EV_ADD,
0, 0, (intptr_t)fio);