Skip to content

Commit

Permalink
Rollup merge of rust-lang#129332 - cuviper:cstr-cast, r=compiler-errors
Browse files Browse the repository at this point in the history
Avoid extra `cast()`s after `CStr::as_ptr()`

These used to be `&str` literals that did need a pointer cast, but that
became a no-op after switching to `c""` literals in rust-lang#118566.
  • Loading branch information
matthiaskrgr authored Aug 21, 2024
2 parents 6d01ed8 + 32b574e commit d37ebfe
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions std/src/sys/pal/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) {
if pfd.revents & libc::POLLNVAL == 0 {
continue;
}
if open64(c"/dev/null".as_ptr().cast(), libc::O_RDWR, 0) == -1 {
if open64(c"/dev/null".as_ptr(), libc::O_RDWR, 0) == -1 {
// If the stream is closed but we failed to reopen it, abort the
// process. Otherwise we wouldn't preserve the safety of
// operations on the corresponding Rust object Stdin, Stdout, or
Expand Down Expand Up @@ -147,7 +147,7 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) {
use crate::sys::os::errno;
for fd in 0..3 {
if libc::fcntl(fd, libc::F_GETFD) == -1 && errno() == libc::EBADF {
if open64(c"/dev/null".as_ptr().cast(), libc::O_RDWR, 0) == -1 {
if open64(c"/dev/null".as_ptr(), libc::O_RDWR, 0) == -1 {
// If the stream is closed but we failed to reopen it, abort the
// process. Otherwise we wouldn't preserve the safety of
// operations on the corresponding Rust object Stdin, Stdout, or
Expand Down

0 comments on commit d37ebfe

Please sign in to comment.