sos-os / kernel

The Stupid Operating System
Apache License 2.0
264 stars 17 forks source link

A bunch of improvements to elf::extract_from_slice #91

Open hawkw opened 7 years ago

hawkw commented 7 years ago

As of 014adb91642c6fea6ad273ebadb6437df79edc78, there are a lot of TODOs on this function, so it probably deserves its own issue:

/// TODO: rewrite this as a `TryFrom` implementation (see issue #85)
//          - eliza, 03/09/2017
///       wait, possibly we should NOT do that. actually we should
///       almost certainly not do that. since this function is unsafe,
///       but `TryFrom` is not, and because this would be WAY generic.
//          - eliza, 03/09/2017
/// TODO: is this general enough to move into util?
//          - eliza, 03/09/2017
/// TODO: should this be refactored to return a `Result`?
//          - eliza, 03/13/2017
/// TODO: can we ensure that the lifetime of the returned slice is the same
///       as the lifetime of the input byte slice, rather than inferred by
///       [`slice::from_raw_parts`]?
//          - eliza, 03/13/2017
/// TODO: assert that `offset` is aligned on a `T`-sized boundary
//          - eliza, 03/13/2017
/// TODO: do we want to assert that `offset` is less than the length of `data`
///       separately from asserting that the slice is long enough, so that
///       we can panic with different messages?
//          - eliza, 03/13/2017
///
hawkw commented 7 years ago

Returns Result as of 5e359b01777d8464f41b8b84aea603c972cda0fe