mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-13 06:33:44 +01:00
rust: Replace two unwrap()
s in FFI code with unwrap_or()
s.
This commit is contained in:
parent
d9826b0a30
commit
45c59eff6c
@ -232,7 +232,7 @@ pub extern "C" fn protover_compute_for_old_tor(version: *const c_char) -> *const
|
|||||||
// we can see that the bytes we're passing into it 1) are valid UTF-8,
|
// we can see that the bytes we're passing into it 1) are valid UTF-8,
|
||||||
// 2) have no intermediate NUL bytes, and 3) are terminated with a NUL
|
// 2) have no intermediate NUL bytes, and 3) are terminated with a NUL
|
||||||
// byte.
|
// byte.
|
||||||
supported = CStr::from_bytes_with_nul(elder_protocols).unwrap();
|
supported = CStr::from_bytes_with_nul(elder_protocols).unwrap_or(empty);
|
||||||
|
|
||||||
supported.as_ptr()
|
supported.as_ptr()
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ pub fn get_supported_protocols() -> &'static str {
|
|||||||
// The `unwrap` is safe becauase we SUPPORTED_PROTOCOLS is under
|
// The `unwrap` is safe becauase we SUPPORTED_PROTOCOLS is under
|
||||||
// our control.
|
// our control.
|
||||||
str::from_utf8(&SUPPORTED_PROTOCOLS[..SUPPORTED_PROTOCOLS.len() - 1])
|
str::from_utf8(&SUPPORTED_PROTOCOLS[..SUPPORTED_PROTOCOLS.len() - 1])
|
||||||
.unwrap()
|
.unwrap_or("")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct SupportedProtocols(HashMap<Proto, Versions>);
|
pub struct SupportedProtocols(HashMap<Proto, Versions>);
|
||||||
|
Loading…
Reference in New Issue
Block a user