Use a safe transmute crate
Currently, many of the redox_syscall structs are repr(C) although using Deref impls to be convertible to regular slices. This has a few downsides, such as requiring explicit unsafe when casting slices of structs, as well as unsafe boilerplate. Reading padding bytes from a struct is UB, and Stat
(on x86_64 at least) does contain implicit padding, making its Deref impl unsound (cf. #29).
Some Redox drivers use plain
, which would be a great improvement, although requiring manual unsafe impl Plain for Struct
, and only allowing slice_from_bytes
(as opposed to slice_to_bytes
, which is impossible since plain does not forbid padding bytes). A better alternative might be bytemuck
, which uses a derive-macro to safely implement traits, with the addition of being able to safely convert contiguous enums to/from ints (zerocopy would also work, but might not be ideal due to licensing).