HomeFreeBSD

initgroups(3): Fix return value on allocation failure

Description

initgroups(3): Fix return value on allocation failure

We must not return ENOMEM, but rather -1 with 'errno' set to ENOMEM, as
described in the manual page and as other implementations are doing.
A malloc() failure actually already sets ENOMEM for us. Add comments
indicating which function set 'errno' each time we return.

While here, improve style and remove useless headers.

Reviewed by: kib, emaste
Fixes: 54404cfb13d4 ("In preparation for raising NGROUPS and NGROUPS_MAX, ...")
MFC after: 5 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D52580

(cherry picked from commit 0b018cfd81d8fdd64af3fe94c6989a82c0d3afa9)

Details

Provenance
olceAuthored on Sep 16 2025, 3:52 PM
Reviewer
kib
Differential Revision
D52580: initgroups(3): Fix return value on allocation failure
Parents
rGbea59ce7c96a: syscalls: Old setgroups(2)/getgroups(2): Remove superfluous STD type
Branches
Unknown
Tags
Unknown