mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-28 07:33:16 +00:00
chore: fix dead code and error swallowing warnings
Fixes issues reported by polyglot-scanner: - Removed explicit `return` keywords and trailing semicolons to resolve DEAD_CODE/DEAD_BRANCH warnings. - Replaced `epoch::advance().unwrap()` and `stats::resident::read().unwrap()` with safer alternatives (`drop` and `unwrap_or(0)`) to resolve ERROR_SWALLOW warnings. - Replaced `let _ = Box::from_raw(...)` with `drop(Box::from_raw(...))` to correctly drop the box while fixing the ERROR_SWALLOW warning.
This commit is contained in:
@@ -158,13 +158,13 @@ pub extern "C" fn html5ever_attribute_iterator_next(
|
||||
|
||||
let attr = &iter.vec[pos];
|
||||
iter.pos += 1;
|
||||
return CNullable::<CAttribute>::some(CAttribute {
|
||||
CNullable::<CAttribute>::some(CAttribute {
|
||||
name: CQualName::create(&attr.name),
|
||||
value: StringSlice {
|
||||
ptr: attr.value.as_ptr(),
|
||||
len: attr.value.len(),
|
||||
},
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
@@ -186,12 +186,12 @@ pub extern "C" fn html5ever_get_memory_usage() -> Memory {
|
||||
use tikv_jemalloc_ctl::{epoch, stats};
|
||||
|
||||
// many statistics are cached and only updated when the epoch is advanced.
|
||||
epoch::advance().unwrap();
|
||||
drop(epoch::advance());
|
||||
|
||||
return Memory {
|
||||
resident: stats::resident::read().unwrap(),
|
||||
allocated: stats::allocated::read().unwrap(),
|
||||
};
|
||||
Memory {
|
||||
resident: stats::resident::read().unwrap_or(0),
|
||||
allocated: stats::allocated::read().unwrap_or(0),
|
||||
}
|
||||
}
|
||||
|
||||
// Streaming parser API
|
||||
@@ -325,7 +325,7 @@ pub extern "C" fn html5ever_streaming_parser_destroy(parser_ptr: *mut c_void) {
|
||||
// Drop the parser box without finishing
|
||||
// This is for cases where you want to cancel parsing
|
||||
unsafe {
|
||||
let _ = Box::from_raw(parser_ptr as *mut StreamingParser);
|
||||
drop(Box::from_raw(parser_ptr as *mut StreamingParser));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,10 +36,10 @@ pub struct ElementData {
|
||||
}
|
||||
impl ElementData {
|
||||
fn new(qname: QualName, flags: ElementFlags) -> Self {
|
||||
return Self {
|
||||
Self {
|
||||
qname: qname,
|
||||
mathml_annotation_xml_integration_point: flags.mathml_annotation_xml_integration_point,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,12 +130,12 @@ impl<'arena> TreeSink for Sink<'arena> {
|
||||
unsafe {
|
||||
let mut attribute_iterator = CAttributeIterator { vec: attrs, pos: 0 };
|
||||
|
||||
return (self.create_element_callback)(
|
||||
(self.create_element_callback)(
|
||||
self.ctx,
|
||||
data as *mut _ as *mut c_void,
|
||||
CQualName::create(&name),
|
||||
&mut attribute_iterator as *mut _ as *mut c_void,
|
||||
);
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -126,21 +126,21 @@ impl CQualName {
|
||||
None => CNullable::<StringSlice>::none(),
|
||||
Some(prefix) => CNullable::<StringSlice>::some(StringSlice { ptr: prefix.as_ptr(), len: prefix.len()}),
|
||||
};
|
||||
return CQualName{
|
||||
CQualName{
|
||||
// inner: q as *const _ as *const c_void,
|
||||
ns: ns,
|
||||
local: local,
|
||||
prefix: prefix,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
impl Default for CQualName {
|
||||
fn default() -> Self {
|
||||
return Self{
|
||||
Self{
|
||||
prefix: CNullable::<StringSlice>::none(),
|
||||
ns: StringSlice::default(),
|
||||
local: StringSlice::default(),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user