You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was hacking on #7728, trying to get rid of numerous suspiscious u32 casts, and realized that many of them have to do with libc::mode_t alias. In most unix-like OS, it uses u32, but some use u16 and Redux uses i32, making this somewhat problematic.
Coreutils code constantly casts from mode_t to u32 and back. I think a better paradigm might be to introduce a dedicated type, probably based on bitflags? In general, a strongly typed flag type should be better than a generic u32 passed around. My only reservation is that maybe this should be part of libc itself?
I doubt libc will do that, because they have 0 dependencies and are just meant to be a raw wrapper. But the nix crate already has something like this: https://docs.rs/nix/latest/nix/sys/stat/struct.Mode.html. We should probably use that instead of raw libc in most cases.
I was hacking on #7728, trying to get rid of numerous suspiscious u32 casts, and realized that many of them have to do with
libc::mode_t
alias. In most unix-like OS, it uses u32, but some use u16 and Redux uses i32, making this somewhat problematic.Coreutils code constantly casts from
mode_t
tou32
and back. I think a better paradigm might be to introduce a dedicated type, probably based on bitflags? In general, a strongly typed flag type should be better than a generic u32 passed around. My only reservation is that maybe this should be part of libc itself?See also rust-lang/libc#4404
The text was updated successfully, but these errors were encountered: