-
Notifications
You must be signed in to change notification settings - Fork 242
Refactor util_libc
#765
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor util_libc
#765
Conversation
| res if res > 0 => { | ||
| let len = usize::try_from(res).map_err(|_| Error::UNEXPECTED)?; | ||
| let (l, r) = buf.split_at_mut_checked(len).ok_or(Error::UNEXPECTED)?; | ||
| unsafe { sanitizer::unpoison(l) }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that it applies unpoison to all users of sys_fill_exact. It's redundant in some cases (e.g. when we read from /dev/urandom), but AFAIK it has no negative consequences (outside of outlandish scenarios of misbehaving libc), while allowing to simplify the code a fair bit.
| #[path = "../util_libc.rs"] | ||
| mod util_libc; | ||
| #[path = "../utils/get_errno.rs"] | ||
| mod utils; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could move imports of errno_location for 4 targets which use this backends here, but I don't think it's worth the trouble since all 4 targets use different names.
dhardy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, esp. the changes to get_errno.
This PR refactors
util_libc,sanitizer, andlazymodules. The modules are moved into theutilsdirectory and "mounted" with#[path = ".."]. With this change all uses of#[path = ".."]point towards theutilsdirectory.