Skip to content

Commit 01e29e5

Browse files
committed
unistd: groups: Update comment about casting Gid pointer to gid_t
1 parent 5099ead commit 01e29e5

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/unistd.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,8 +1002,9 @@ pub fn getgroups() -> Result<Vec<Gid>> {
10021002
// now too small
10031003
let mut groups = Vec::<Gid>::with_capacity(size as usize);
10041004
loop {
1005-
// We can coerce a pointer to some `Gid`s as a pointer to some `gid_t`s
1006-
// as they have the same representation in memory.
1005+
// FIXME: On the platforms we currently support, the `Gid` struct has
1006+
// the same representation in memory as a bare `gid_t`. This is not
1007+
// necessarily the case on all Rust platforms, though. See RFC 1785.
10071008
let ret = unsafe { libc::getgroups(size, groups.as_mut_ptr() as *mut gid_t) };
10081009

10091010
match Errno::result(ret) {
@@ -1043,8 +1044,9 @@ pub fn setgroups(groups: &[Gid]) -> Result<()> {
10431044
type setgroups_ngroups_t = size_t;
10441045
}
10451046
}
1046-
// We can coerce a pointer to some `Gid`s as a pointer to some `gid_t`s as
1047-
// they have the same representation in memory.
1047+
// FIXME: On the platforms we currently support, the `Gid` struct has the
1048+
// same representation in memory as a bare `gid_t`. This is not necessarily
1049+
// the case on all Rust platforms, though. See RFC 1785.
10481050
let res = unsafe {
10491051
libc::setgroups(groups.len() as setgroups_ngroups_t, groups.as_ptr() as *const gid_t)
10501052
};

0 commit comments

Comments
 (0)