HomeFreeBSD

libutil: eliminate one syscall from kinfo_getproc

Description

libutil: eliminate one syscall from kinfo_getproc

Previously we invoked the sysctl with a NULL buffer to query the size,
allocated a buffer, then invoked it again to fetch the data.

As we only handle the case where the sysctl provides data of the
expected size we can just allocate a correctly-sized buffer to begin
with.

Reported by: Thomas Hurst via Twitter
Reviewed by: kevans
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35140

(cherry picked from commit 904c148f1c939f080b9fad345b76caa8ccb6d03c)

Details

Provenance
emasteAuthored on May 6 2022, 4:41 PM
Reviewer
kevans
Differential Revision
D35140: Eliminate one syscall from kinfo_getproc
Parents
rG0ddb544b17d0: arm: Add extres pseudo devices to some kernel
Branches
Unknown
Tags
Unknown