Skip to content

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

Open
@biabbas

Description

@biabbas

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.O-vxworksTarget: when they made us, they called us Curiosity, and Spirit, and told us to tell you helloT-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions