|
| 1 | +error: giving a pointer to a Rust `str` to an `extern "C" fn` can cause undefined behavior |
| 2 | + --> tests/ui/str_ptr_in_c_abi.rs:7:21 |
| 3 | + | |
| 4 | +LL | unsafe { printf("Hello".as_ptr() as *const _) }; |
| 5 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 6 | + | |
| 7 | + = help: if the foreign function calls for a null-terminated string in this position, first convert this value to a `std::ffi::CString` and take the pointer from that |
| 8 | + = note: `-D clippy::str-ptr-in-c-abi` implied by `-D warnings` |
| 9 | + = help: to override `-D warnings` add `#[allow(clippy::str_ptr_in_c_abi)]` |
| 10 | + |
| 11 | +error: giving a pointer to a Rust `str` to an `extern "C" fn` can cause undefined behavior |
| 12 | + --> tests/ui/str_ptr_in_c_abi.rs:17:21 |
| 13 | + | |
| 14 | +LL | unsafe { strcpy(buffer.as_mut_ptr() as *mut _, cstring.as_ptr()) }; |
| 15 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 16 | + | |
| 17 | + = help: if the foreign function calls for a null-terminated string in this position, first convert this value to a `std::ffi::CString` and take the pointer from that |
| 18 | + |
| 19 | +error: giving a pointer to a Rust `str` to an `extern "C" fn` can cause undefined behavior |
| 20 | + --> tests/ui/str_ptr_in_c_abi.rs:24:21 |
| 21 | + | |
| 22 | +LL | unsafe { strcpy(buffer.as_mut_ptr() as *mut _, "Hello".as_ptr() as *const _) }; |
| 23 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 24 | + | |
| 25 | + = help: if the foreign function calls for a null-terminated string in this position, first convert this value to a `std::ffi::CString` and take the pointer from that |
| 26 | + |
| 27 | +error: giving a pointer to a Rust `str` to an `extern "C" fn` can cause undefined behavior |
| 28 | + --> tests/ui/str_ptr_in_c_abi.rs:31:21 |
| 29 | + | |
| 30 | +LL | unsafe { printf(hello_string.as_ptr() as *const _) }; |
| 31 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 32 | + | |
| 33 | + = help: if the foreign function calls for a null-terminated string in this position, first convert this value to a `std::ffi::CString` and take the pointer from that |
| 34 | + |
| 35 | +error: giving a pointer to a Rust `str` to an `extern "C" fn` can cause undefined behavior |
| 36 | + --> tests/ui/str_ptr_in_c_abi.rs:33:21 |
| 37 | + | |
| 38 | +LL | unsafe { printf(hello_box.as_ptr() as *const _) }; |
| 39 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 40 | + | |
| 41 | + = help: if the foreign function calls for a null-terminated string in this position, first convert this value to a `std::ffi::CString` and take the pointer from that |
| 42 | + |
| 43 | +error: giving a pointer to a Rust `str` to an `extern "C" fn` can cause undefined behavior |
| 44 | + --> tests/ui/str_ptr_in_c_abi.rs:35:21 |
| 45 | + | |
| 46 | +LL | unsafe { printf(hello_rc.as_ptr() as *const _) }; |
| 47 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 48 | + | |
| 49 | + = help: if the foreign function calls for a null-terminated string in this position, first convert this value to a `std::ffi::CString` and take the pointer from that |
| 50 | + |
| 51 | +error: giving a pointer to a Rust `str` to an `extern "C" fn` can cause undefined behavior |
| 52 | + --> tests/ui/str_ptr_in_c_abi.rs:40:35 |
| 53 | + | |
| 54 | +LL | unsafe { printf(fmt.as_ptr(), "I'm (incorrectly) printf-ing a str!".as_ptr() as *const _) }; |
| 55 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 56 | + | |
| 57 | + = help: if the foreign function calls for a null-terminated string in this position, first convert this value to a `std::ffi::CString` and take the pointer from that |
| 58 | + |
| 59 | +error: giving a pointer to a Rust `str` to an `extern "C" fn` can cause undefined behavior |
| 60 | + --> tests/ui/str_ptr_in_c_abi.rs:44:35 |
| 61 | + | |
| 62 | +LL | unsafe { printf(fmt.as_ptr(), "hello".as_ptr()) }; |
| 63 | + | ^^^^^^^^^^^^^^^^ |
| 64 | + | |
| 65 | + = help: if the foreign function calls for a null-terminated string in this position, first convert this value to a `std::ffi::CString` and take the pointer from that |
| 66 | + |
| 67 | +error: giving a pointer to a Rust `str` to an `extern "C" fn` can cause undefined behavior |
| 68 | + --> tests/ui/str_ptr_in_c_abi.rs:48:21 |
| 69 | + | |
| 70 | +LL | unsafe { printf("hello".as_ptr() as *const _ as *const _) }; |
| 71 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 72 | + | |
| 73 | + = help: if the foreign function calls for a null-terminated string in this position, first convert this value to a `std::ffi::CString` and take the pointer from that |
| 74 | + |
| 75 | +error: giving a pointer to a Rust `str` to an `extern "C" fn` can cause undefined behavior |
| 76 | + --> tests/ui/str_ptr_in_c_abi.rs:50:21 |
| 77 | + | |
| 78 | +LL | unsafe { printf("hello".as_ptr() as *const _ as *const _ as *const _) }; |
| 79 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 80 | + | |
| 81 | + = help: if the foreign function calls for a null-terminated string in this position, first convert this value to a `std::ffi::CString` and take the pointer from that |
| 82 | + |
| 83 | +error: giving a pointer to a Rust `str` to an `extern "C" fn` can cause undefined behavior |
| 84 | + --> tests/ui/str_ptr_in_c_abi.rs:56:25 |
| 85 | + | |
| 86 | +LL | unsafe { printf_box("hello".as_ptr() as *const _) }; |
| 87 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 88 | + | |
| 89 | + = help: if the foreign function calls for a null-terminated string in this position, first convert this value to a `std::ffi::CString` and take the pointer from that |
| 90 | + |
| 91 | +error: giving a pointer to a Rust `str` to an `extern "C" fn` can cause undefined behavior |
| 92 | + --> tests/ui/str_ptr_in_c_abi.rs:58:24 |
| 93 | + | |
| 94 | +LL | unsafe { printf_rc("hello".as_ptr() as *const _) }; |
| 95 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 96 | + | |
| 97 | + = help: if the foreign function calls for a null-terminated string in this position, first convert this value to a `std::ffi::CString` and take the pointer from that |
| 98 | + |
| 99 | +error: giving a pointer to a Rust `str` to an `extern "C" fn` can cause undefined behavior |
| 100 | + --> tests/ui/str_ptr_in_c_abi.rs:62:19 |
| 101 | + | |
| 102 | +LL | (&printf)("hello".as_ptr() as *const _) |
| 103 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 104 | + | |
| 105 | + = help: if the foreign function calls for a null-terminated string in this position, first convert this value to a `std::ffi::CString` and take the pointer from that |
| 106 | + |
| 107 | +error: aborting due to 13 previous errors |
| 108 | + |
0 commit comments