Skip to content

Commit d2c47ff

Browse files
committed
unistd::getgrouplist: respond to comments
1 parent f2ada86 commit d2c47ff

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/unistd.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,12 +1051,12 @@ pub fn getgrouplist(user: &CString, group: Gid) -> Result<Vec<Gid>> {
10511051
if ret >= 0 {
10521052
unsafe { groups.set_len(ngroups as usize) };
10531053
return Ok(groups);
1054-
}
1054+
} else if ret == -1 {
1055+
// Returns -1 if ngroups is too small, but does not set errno.
1056+
// BSD systems will still fill the groups buffer with as many
1057+
// groups as possible, but Linux manpages do not mention this
1058+
// behavior.
10551059

1056-
// Returns -1 if ngroups is too small, but does not set errno.
1057-
// BSD systems will still fill the groups buffer with as many groups
1058-
// as possible, but Linux manpages do not mention this behavior.
1059-
if ret == -1 {
10601060
let cap = groups.capacity();
10611061
if cap >= ngroups_max as usize {
10621062
// We already have the largest capacity we can, give up

0 commit comments

Comments
 (0)