Uh oh!
There was an error while loading. Please reload this page.
Improve safety & usability of |size_t| and |ssize_t|. - #29222
Conversation
rust-highfive
commented
Oct 22, 2015
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
briansmith
commented
Oct 22, 2015
bors
commented
Oct 22, 2015
☔ The latest upstream changes (presumably #29045) made this pull request unmergeable. Please resolve the merge conflicts. |
Also, improve the documentation related to the range of usize and isize.
Since |usize| may be larger than |libc::size_t|, it is generally not safe to cast from |usize| to |libc::size_t|. The effect of this commit is to cause the build to fail on a platform where `libc::size_t` isn't the same as `usize`. But, that is better than the current state of affairs, where unsafe truncations can occur on such platforms, potentially leading to buffer overflows and other unsafety.
I didn't try to find every such cast. I concentrated on the files that had now-unnecessary casts from |usize| to |size_t|.
7a1906f to
5864ba9Comparebriansmith
commented
Oct 22, 2015
This is now against the wrong repo. |
This has been rebased on top of #28779 and #29220. It is intended to address the
usize/isizerelated aspects of RFC 1291.Note in particular that one of these changesets removes casts that would actually result in unsafe memory usage on any platform where
libc::size_tis smaller thanusize.r? @alexcrichton