mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-24 05:33:27 +00:00
25 lines
951 B
Text
25 lines
951 B
Text
error: using `libc::strlen` on a `CString` or `CStr` value
|
|
--> $DIR/strlen_on_c_strings.rs:11:24
|
|
|
|
|
LL | let len = unsafe { libc::strlen(cstring.as_ptr()) };
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
= note: `-D clippy::strlen-on-c-strings` implied by `-D warnings`
|
|
help: try this (you might also need to get rid of `unsafe` block in some cases):
|
|
|
|
|
LL | let len = unsafe { cstring.as_bytes().len() };
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
error: using `libc::strlen` on a `CString` or `CStr` value
|
|
--> $DIR/strlen_on_c_strings.rs:15:24
|
|
|
|
|
LL | let len = unsafe { libc::strlen(cstr.as_ptr()) };
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
help: try this (you might also need to get rid of `unsafe` block in some cases):
|
|
|
|
|
LL | let len = unsafe { cstr.to_bytes().len() };
|
|
| ^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
error: aborting due to 2 previous errors
|
|
|