Merge pull request #4389 from fufesou/refact/remove_all_assert
remove all assert in non-test code
This commit is contained in:
commit
5f0f4957b9
@ -349,7 +349,9 @@ impl Encrypt {
|
|||||||
their_pk_b: &[u8],
|
their_pk_b: &[u8],
|
||||||
our_sk_b: &box_::SecretKey,
|
our_sk_b: &box_::SecretKey,
|
||||||
) -> ResultType<Key> {
|
) -> ResultType<Key> {
|
||||||
assert!(their_pk_b.len() == box_::PUBLICKEYBYTES);
|
if their_pk_b.len() != box_::PUBLICKEYBYTES {
|
||||||
|
anyhow::bail!("Handshake failed: pk length {}", their_pk_b.len());
|
||||||
|
}
|
||||||
let nonce = box_::Nonce([0u8; box_::NONCEBYTES]);
|
let nonce = box_::Nonce([0u8; box_::NONCEBYTES]);
|
||||||
let mut pk_ = [0u8; box_::PUBLICKEYBYTES];
|
let mut pk_ = [0u8; box_::PUBLICKEYBYTES];
|
||||||
pk_[..].copy_from_slice(their_pk_b);
|
pk_[..].copy_from_slice(their_pk_b);
|
||||||
|
@ -108,7 +108,7 @@ fn rust_args_to_c_args(args: Vec<String>, outlen: *mut c_int) -> *mut *mut c_cha
|
|||||||
|
|
||||||
// Make sure we're not wasting space.
|
// Make sure we're not wasting space.
|
||||||
out.shrink_to_fit();
|
out.shrink_to_fit();
|
||||||
assert!(out.len() == out.capacity());
|
debug_assert!(out.len() == out.capacity());
|
||||||
|
|
||||||
// Get the pointer to our vector.
|
// Get the pointer to our vector.
|
||||||
let len = out.len();
|
let len = out.len();
|
||||||
@ -257,7 +257,7 @@ impl FlutterHandler {
|
|||||||
/// * `event` - Fields of the event content.
|
/// * `event` - Fields of the event content.
|
||||||
pub fn push_event(&self, name: &str, event: Vec<(&str, &str)>) -> Option<bool> {
|
pub fn push_event(&self, name: &str, event: Vec<(&str, &str)>) -> Option<bool> {
|
||||||
let mut h: HashMap<&str, &str> = event.iter().cloned().collect();
|
let mut h: HashMap<&str, &str> = event.iter().cloned().collect();
|
||||||
assert!(h.get("name").is_none());
|
debug_assert!(h.get("name").is_none());
|
||||||
h.insert("name", name);
|
h.insert("name", name);
|
||||||
let out = serde_json::ser::to_string(&h).unwrap_or("".to_owned());
|
let out = serde_json::ser::to_string(&h).unwrap_or("".to_owned());
|
||||||
Some(
|
Some(
|
||||||
@ -858,7 +858,7 @@ pub mod connection_manager {
|
|||||||
impl FlutterHandler {
|
impl FlutterHandler {
|
||||||
fn push_event(&self, name: &str, event: Vec<(&str, &str)>) {
|
fn push_event(&self, name: &str, event: Vec<(&str, &str)>) {
|
||||||
let mut h: HashMap<&str, &str> = event.iter().cloned().collect();
|
let mut h: HashMap<&str, &str> = event.iter().cloned().collect();
|
||||||
assert!(h.get("name").is_none());
|
debug_assert!(h.get("name").is_none());
|
||||||
h.insert("name", name);
|
h.insert("name", name);
|
||||||
|
|
||||||
if let Some(s) = GLOBAL_EVENT_STREAM.read().unwrap().get(super::APP_TYPE_CM) {
|
if let Some(s) = GLOBAL_EVENT_STREAM.read().unwrap().get(super::APP_TYPE_CM) {
|
||||||
|
@ -80,7 +80,7 @@ impl PluginReturn {
|
|||||||
if self.is_success() {
|
if self.is_success() {
|
||||||
(self.code, "".to_owned())
|
(self.code, "".to_owned())
|
||||||
} else {
|
} else {
|
||||||
assert!(!self.msg.is_null());
|
debug_assert!(!self.msg.is_null(), "msg is null");
|
||||||
let msg = cstr_to_string(self.msg).unwrap_or_default();
|
let msg = cstr_to_string(self.msg).unwrap_or_default();
|
||||||
free_c_ptr(self.msg as _);
|
free_c_ptr(self.msg as _);
|
||||||
self.msg = null();
|
self.msg = null();
|
||||||
|
@ -109,7 +109,7 @@ impl SharedMemory {
|
|||||||
|
|
||||||
pub fn write(&self, addr: usize, data: &[u8]) {
|
pub fn write(&self, addr: usize, data: &[u8]) {
|
||||||
unsafe {
|
unsafe {
|
||||||
assert!(addr + data.len() <= self.inner.len());
|
debug_assert!(addr + data.len() <= self.inner.len());
|
||||||
let ptr = self.inner.as_ptr().add(addr);
|
let ptr = self.inner.as_ptr().add(addr);
|
||||||
let shared_mem_slice = slice::from_raw_parts_mut(ptr, data.len());
|
let shared_mem_slice = slice::from_raw_parts_mut(ptr, data.len());
|
||||||
shared_mem_slice.copy_from_slice(data);
|
shared_mem_slice.copy_from_slice(data);
|
||||||
|
@ -49,7 +49,7 @@ impl<T: Subscriber + From<ConnInner>> ServiceInner<T> {
|
|||||||
for (_, s) in self.new_subscribes.drain() {
|
for (_, s) in self.new_subscribes.drain() {
|
||||||
self.subscribes.insert(s.id(), s);
|
self.subscribes.insert(s.id(), s);
|
||||||
}
|
}
|
||||||
assert!(self.new_subscribes.is_empty());
|
debug_assert!(self.new_subscribes.is_empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user