eminence / procfs

Rust library for reading the Linux procfs filesystem
Other
367 stars 106 forks source link

please remove expects! #131

Closed int5-grey closed 3 years ago

int5-grey commented 3 years ago

This crate is great and id really like to use it, but there's one issue and thats the expects!. Imho a library shouldn't act on global of program state (like terminating it) based on an unexpected condition - it should only do that if the state could lead to undefined behavior - which can occur in things like libc. Here we are expecting procfs to follow a certain standard in terms of layout - which should be pretty reliable - but worst case should cause an API to return an error not a panic. Don't mind helping with this effort - but wanted to get your thoughts.

eminence commented 3 years ago

Hi there.

Can you give an example where procfs will panic? Procfs tries pretty hard to never do that, and will always return an error instead (though I have occasionally found a few panics while fuzzing some of parsers, and there are probably a few such panics still hiding somewhere).

See also #44 (edit: and see this note in the docs)

int5-grey commented 3 years ago

@eminence Awesome - didn't see you defined the expect! macro - I just assumed it was this one