Skip to content

Commit

Permalink
Avoid extra cast()s after CStr::as_ptr()
Browse files Browse the repository at this point in the history
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
cuviper committed Aug 20, 2024
1 parent 91439ce commit 32b574e
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 32b574e

Please sign in to comment.