Skip to content

Conversation

@newpavlov
Copy link
Member

@newpavlov newpavlov commented Dec 10, 2025

This PR refactors util_libc, sanitizer, and lazy modules. The modules are moved into the utils directory and "mounted" with #[path = ".."]. With this change all uses of #[path = ".."] point towards the utils directory.

@newpavlov newpavlov requested a review from josephlr December 10, 2025 13:15
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) };
Copy link
Member Author

@newpavlov newpavlov Dec 10, 2025

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;
Copy link
Member Author

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.

Copy link
Member

@dhardy dhardy left a 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.

@newpavlov newpavlov merged commit 2fe4e79 into master Dec 27, 2025
100 of 101 checks passed
@newpavlov newpavlov deleted the refactor_util_libc branch December 27, 2025 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants