Skip to content
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

Remove the cast dependency. #124

Merged
merged 2 commits into from
Feb 10, 2020
Merged

Remove the cast dependency. #124

merged 2 commits into from
Feb 10, 2020

Conversation

m-ou-se
Copy link
Contributor

@m-ou-se m-ou-se commented Feb 10, 2020

It was only used between usize and u64 in parts of the code that were
marked with #[cfg(target_pointer_width = "64")], which guarantees
usize is 64 bits.

See #90.

It was only used between usize and u64 in parts of the code that were
marked with `#[cfg(target_pointer_width = "64")]`, which guarantees
usize is 64 bits.
Copy link
Member

@phil-opp phil-opp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thank you! I left one small comment, otherwise this looks good to me.

src/addr.rs Outdated
Comment on lines 90 to 93
/// Creates a virtual address from the given pointer
pub fn from_ptr<T>(ptr: *const T) -> Self {
Self::new(cast::u64(ptr as usize))
Self::new(ptr as u64)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function does not have a #[cfg(target_pointer_width = "64")]. There are no >64-architectures right now, so this cast should never be truncating in practice, but maybe we should add the cfg attribute anyway?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like cfg was already missing there. Adding it would technically be a breaking change.

It could also get a #[cfg(any(target_pointer_width = "32", target_pointer_width = "64")] to make it 'less breaking'. Not sure if anybody would want to use this function on 32-bit though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding #[cfg(any(target_pointer_width = "32", target_pointer_width = "64")] with a short comment that target_pointer_width = "32" is only added for reducing breakage seems like the best option to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Done.

@phil-opp
Copy link
Member

Perfect, thanks!

@phil-opp phil-opp merged commit 0a69f1d into rust-osdev:master Feb 10, 2020
phil-opp added a commit that referenced this pull request Feb 10, 2020
@phil-opp
Copy link
Member

Released as version 0.9.2.

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.

2 participants