|
1 | 1 | #![allow(missing_docs, nonstandard_style)]
|
2 | 2 |
|
| 3 | +use crate::ffi::CStr; |
3 | 4 | use crate::io::ErrorKind;
|
4 | 5 |
|
5 | 6 | pub use self::rand::hashmap_random_keys;
|
@@ -74,7 +75,7 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) {
|
74 | 75 | // thread-id for the main thread and so renaming the main thread will rename the
|
75 | 76 | // process and we only want to enable this on platforms we've tested.
|
76 | 77 | if cfg!(target_os = "macos") {
|
77 |
| - thread::Thread::set_name(&c"main"); |
| 78 | + thread::Thread::set_name(&CStr::from_bytes_with_nul_unchecked(b"main\0")); |
78 | 79 | }
|
79 | 80 |
|
80 | 81 | unsafe fn sanitize_standard_fds() {
|
@@ -126,7 +127,7 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) {
|
126 | 127 | if pfd.revents & libc::POLLNVAL == 0 {
|
127 | 128 | continue;
|
128 | 129 | }
|
129 |
| - if open64(c"/dev/null".as_ptr().cast(), libc::O_RDWR, 0) == -1 { |
| 130 | + if open64("/dev/null\0".as_ptr().cast(), libc::O_RDWR, 0) == -1 { |
130 | 131 | // If the stream is closed but we failed to reopen it, abort the
|
131 | 132 | // process. Otherwise we wouldn't preserve the safety of
|
132 | 133 | // operations on the corresponding Rust object Stdin, Stdout, or
|
@@ -156,7 +157,7 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) {
|
156 | 157 | use libc::open64;
|
157 | 158 | for fd in 0..3 {
|
158 | 159 | if libc::fcntl(fd, libc::F_GETFD) == -1 && errno() == libc::EBADF {
|
159 |
| - if open64(c"/dev/null".as_ptr().cast(), libc::O_RDWR, 0) == -1 { |
| 160 | + if open64("/dev/null\0".as_ptr().cast(), libc::O_RDWR, 0) == -1 { |
160 | 161 | // If the stream is closed but we failed to reopen it, abort the
|
161 | 162 | // process. Otherwise we wouldn't preserve the safety of
|
162 | 163 | // operations on the corresponding Rust object Stdin, Stdout, or
|
|
0 commit comments