mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2026-02-04 05:44:53 +00:00
fix(rust): resolve clippy unnecessary_unwrap warnings for Rust 1.93
Use if-let patterns instead of is_some() + unwrap() to satisfy the stricter clippy::unnecessary_unwrap lint in Rust 1.93. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -212,11 +212,9 @@ pub unsafe fn copy_from_rust(ccx_s_options: *mut ccx_s_options, options: Options
|
||||
replace_rust_c_string((*ccx_s_options).udpaddr, &options.udpaddr.clone().unwrap());
|
||||
}
|
||||
(*ccx_s_options).udpport = options.udpport as _;
|
||||
if options.tcpport.is_some() {
|
||||
(*ccx_s_options).tcpport = replace_rust_c_string(
|
||||
(*ccx_s_options).tcpport,
|
||||
&options.tcpport.unwrap().to_string(),
|
||||
);
|
||||
if let Some(tcpport) = options.tcpport {
|
||||
(*ccx_s_options).tcpport =
|
||||
replace_rust_c_string((*ccx_s_options).tcpport, &tcpport.to_string());
|
||||
}
|
||||
if options.tcp_password.is_some() {
|
||||
(*ccx_s_options).tcp_password = replace_rust_c_string(
|
||||
@@ -236,11 +234,9 @@ pub unsafe fn copy_from_rust(ccx_s_options: *mut ccx_s_options, options: Options
|
||||
&options.srv_addr.clone().unwrap(),
|
||||
);
|
||||
}
|
||||
if options.srv_port.is_some() {
|
||||
(*ccx_s_options).srv_port = replace_rust_c_string(
|
||||
(*ccx_s_options).srv_port,
|
||||
&options.srv_port.unwrap().to_string(),
|
||||
);
|
||||
if let Some(srv_port) = options.srv_port {
|
||||
(*ccx_s_options).srv_port =
|
||||
replace_rust_c_string((*ccx_s_options).srv_port, &srv_port.to_string());
|
||||
}
|
||||
(*ccx_s_options).noautotimeref = options.noautotimeref as _;
|
||||
(*ccx_s_options).input_source = options.input_source as _;
|
||||
@@ -254,15 +250,12 @@ pub unsafe fn copy_from_rust(ccx_s_options: *mut ccx_s_options, options: Options
|
||||
// Subsequent calls from ccxr_demuxer_open/close should NOT modify inputfile because
|
||||
// C code holds references to those strings throughout processing.
|
||||
// Freeing them would cause use-after-free and double-free errors.
|
||||
if options.inputfile.is_some() && (*ccx_s_options).inputfile.is_null() {
|
||||
(*ccx_s_options).inputfile = string_to_c_chars(options.inputfile.clone().unwrap());
|
||||
(*ccx_s_options).num_input_files = options
|
||||
.inputfile
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.iter()
|
||||
.filter(|s| !s.is_empty())
|
||||
.count() as _;
|
||||
if let Some(ref inputfile) = options.inputfile {
|
||||
if (*ccx_s_options).inputfile.is_null() {
|
||||
(*ccx_s_options).inputfile = string_to_c_chars(inputfile.clone());
|
||||
(*ccx_s_options).num_input_files =
|
||||
inputfile.iter().filter(|s| !s.is_empty()).count() as _;
|
||||
}
|
||||
}
|
||||
(*ccx_s_options).demux_cfg = options.demux_cfg.to_ctype();
|
||||
// Only set enc_cfg on the first call (when output_filename is null).
|
||||
|
||||
@@ -129,10 +129,14 @@ pub fn sleepandchecktimeout(start: u64, ccx_options: &mut Options) {
|
||||
.expect("System time went backwards")
|
||||
.as_secs();
|
||||
|
||||
if ccx_options.live_stream.is_some() && ccx_options.live_stream.unwrap().seconds() != 0 {
|
||||
if current_time > start + ccx_options.live_stream.unwrap().millis() as u64 {
|
||||
// Timeout elapsed
|
||||
ccx_options.live_stream = Option::from(Timestamp::from_millis(0));
|
||||
if let Some(live_stream) = ccx_options.live_stream {
|
||||
if live_stream.seconds() != 0 {
|
||||
if current_time > start + live_stream.millis() as u64 {
|
||||
// Timeout elapsed
|
||||
ccx_options.live_stream = Option::from(Timestamp::from_millis(0));
|
||||
} else {
|
||||
sleep_secs(1);
|
||||
}
|
||||
} else {
|
||||
sleep_secs(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user