summaryrefslogtreecommitdiffstats
path: root/osdep-netbsd.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2017-02-19 08:31:05 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2017-02-19 08:31:05 +0000
commit55e76edd3cc9bfa8aeac60b17d3344031097b1b6 (patch)
tree02403e27dad1e2015de93dda87e49e11c3f853b1 /osdep-netbsd.c
parent203d604bf7a439648707517c7dc4770fe7f4d8a3 (diff)
Improve NetBSD KERN_PROC2 bit, mostly from Kamil Rytarowski.
Diffstat (limited to 'osdep-netbsd.c')
-rw-r--r--osdep-netbsd.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/osdep-netbsd.c b/osdep-netbsd.c
index d8aa41b5..823eeebf 100644
--- a/osdep-netbsd.c
+++ b/osdep-netbsd.c
@@ -80,30 +80,32 @@ osdep_get_name(int fd, __unused char *tty)
return (NULL);
buf = NULL;
- len = sizeof(bestp);
+ len = sizeof bestp;
+
mib[0] = CTL_KERN;
mib[1] = KERN_PROC2;
mib[2] = KERN_PROC_PGRP;
- mib[4] = sizeof (*buf);
- mib[5] = 0;
+ mib[4] = sizeof *buf;
retry:
+ mib[5] = 0;
+
if (sysctl(mib, __arraycount(mib), NULL, &len, NULL, 0) == -1)
return (NULL);
- if ((newbuf = realloc(buf, len * sizeof (*buf))) == NULL)
+ if ((newbuf = realloc(buf, len)) == NULL)
goto error;
buf = newbuf;
- mib[5] = len / sizeof(*buf);
+ mib[5] = len / (sizeof *buf);
if (sysctl(mib, __arraycount(mib), buf, &len, NULL, 0) == -1) {
if (errno == ENOMEM)
- goto retry; /* possible infinite loop? */
+ goto retry;
goto error;
}
bestp = NULL;
- for (i = 0; i < len / sizeof (*buf); i++) {
+ for (i = 0; i < len / (sizeof *buf); i++) {
if (buf[i].p_tdev != sb.st_rdev)
continue;
if (bestp == NULL)