Skip to content

Please add clarification for casting mode_t to c_uint here #21

@phi-gamma

Description

@phi-gamma

Regarding:

mode as libc::c_uint);

The cast was added in 8a25eae
which concerns freebsd support without further explanation. According to
the freebsd docs though, the mode argument is supposed to be of type
mode_t as well:

https://www.freebsd.org/cgi/man.cgi?query=openat&apropos=0&sektion=0&manpath=FreeBSD+12.0-RELEASE+and+Ports&arch=default&format=html

If I’m reading the libc source correctly:

src/unix/mod.rs:pub type c_uint = u32;
src/unix/bsd/freebsdlike/mod.rs:pub type mode_t = u16;
src/unix/linux_like/linux/mod.rs:pub type mode_t = u32;

this is a no-op on Linux but a cast of u16 to a u32 on Freebsd.

Does the build actually fail on Freebsd if the cast is omitted? If so, maybe
this should be highlighted by a cfg guard. I don’t have a Freebsd system
at my disposal so I cannot test this myself.

(Sorry for being nitpicky here. I’m currently subjecting the crate to a crev
review so I had to waste some extra attention to the unsafe blocks.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions