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

libc::posix_memalign, libc::pwrite and pread are not considered unsafe operation during library build #128582

Open
biabbas opened this issue Aug 3, 2024 · 1 comment
Labels
C-bug Category: This is a bug. O-vxworks Target: when they made us, they called us Curiosity, and Spirit, and told us to tell you hello T-libs Relevant to the library team, which will review and decide on the PR/issue.

Comments

@biabbas
Copy link
Contributor

biabbas commented Aug 3, 2024

To resolve build errors, ununused_unsafe is allowed for target VxWorks.
We use libc::pread as pread64 which is declared as unsafe in libc for VxWorks
https://github.com/rust-lang/rust/blob/master/library/std/src/sys/pal/unix/fd.rs#L129
We use libc::pwrite as pwrite64 which is also an unsafe fn
https://github.com/rust-lang/rust/blob/master/library/std/src/sys/pal/unix/fd.rs#L323

Error

error: unnecessary `unsafe` block
  --> std/src/sys/alloc/unix.rs:84:23
   |
84 |             let ret = unsafe { libc::posix_memalign(&mut out, align, layout.size()) };
   |                       ^^^^^^ unnecessary `unsafe` block

error: unnecessary `unsafe` block
   --> library/std/src/sys/pal/unix/fd.rs:137:9
    |
137 |         unsafe {
    |         ^^^^^^ unnecessary `unsafe` block
    |
    = note: `-D unused-unsafe` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(unused_unsafe)]`

error: unnecessary `unsafe` block
   --> library/std/src/sys/pal/unix/fd.rs:330:9
    |
330 |         unsafe {
    |         ^^^^^^ unnecessary `unsafe` block
@biabbas biabbas added the C-bug Category: This is a bug. label Aug 3, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 3, 2024
@jieyouxu jieyouxu added T-libs Relevant to the library team, which will review and decide on the PR/issue. O-vxworks Target: when they made us, they called us Curiosity, and Spirit, and told us to tell you hello and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Aug 4, 2024
@biabbas biabbas changed the title Libc::pwrite and pread are not considered unsafe operation in fd.rs libc::posix_memalign, libc::pwrite and pread are not considered unsafe operation during library build Sep 20, 2024
@biabbas
Copy link
Contributor Author

biabbas commented Sep 20, 2024

rust-lang/libc#3727 Getting this into a libc release would probably solve this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. O-vxworks Target: when they made us, they called us Curiosity, and Spirit, and told us to tell you hello T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants