rust/tor_util: drop unsafe block in cstr!

This is unnecessary just to get an empty string, there's Default::default().

Fix on 8fff331bb0.
This commit is contained in:
cypherpunks 2018-10-17 00:16:21 +00:00
parent e97adaf8dc
commit 2f0744b3e6
2 changed files with 4 additions and 5 deletions

3
changes/ticket28077 Normal file
View file

@ -0,0 +1,3 @@
o Code simplification and refactoring:
- Remove unnecessarily unsafe code from the rust macro cstr!. Closes
ticket 28077.

View file

@ -105,11 +105,7 @@ macro_rules! cstr {
($($bytes:expr),*) => (
::std::ffi::CStr::from_bytes_with_nul(
concat!($($bytes),*, "\0").as_bytes()
).unwrap_or(
unsafe{
::std::ffi::CStr::from_bytes_with_nul_unchecked(b"\0")
}
)
).unwrap_or_default()
)
}