Skip to content

Commit

Permalink
Merge pull request #2177 from Bravo555/clippy-fixes
Browse files Browse the repository at this point in the history
Fix clippy lints for rust 1.73
  • Loading branch information
didier-wenzek authored Aug 21, 2023
2 parents d35823f + 49ae2a5 commit 92a505d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 21 deletions.
8 changes: 2 additions & 6 deletions crates/common/download/src/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ impl Downloader {
);

if file_len > 0 {
try_pre_allocate_space(&mut file, &tmp_target_path, file_len)?;
try_pre_allocate_space(&file, &tmp_target_path, file_len)?;
debug!("preallocated space for file {tmp_target_path:?}, len={file_len}");
}

Expand Down Expand Up @@ -447,11 +447,7 @@ enum SaveChunksError {
}

#[allow(clippy::unnecessary_cast)]
fn try_pre_allocate_space(
file: &mut File,
path: &Path,
file_len: u64,
) -> Result<(), DownloadError> {
fn try_pre_allocate_space(file: &File, path: &Path, file_len: u64) -> Result<(), DownloadError> {
if file_len == 0 {
return Ok(());
}
Expand Down
4 changes: 2 additions & 2 deletions crates/common/logged_command/src/logged_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl LoggingChild {
let mut status = CmdStatus::Successful;
tokio::select! {
outcome = self.inner_child.wait_with_output() => {
Self::update_and_log_outcome(cmd_line, outcome, logger, graceful_timeout, &mut status).await
Self::update_and_log_outcome(cmd_line, outcome, logger, graceful_timeout, &status).await
}
_ = Self::timeout_operation(&mut status, cid, graceful_timeout, forceful_timeout) => {
Err(std::io::Error::new(std::io::ErrorKind::Other,"failed to kill the process: {cmd_line}"))
Expand All @@ -59,7 +59,7 @@ impl LoggingChild {
outcome: Result<Output, std::io::Error>,
logger: &mut BufWriter<File>,
timeout: Duration,
status: &mut CmdStatus,
status: &CmdStatus,
) -> Result<Output, std::io::Error> {
let outcome = match status {
CmdStatus::Successful => outcome,
Expand Down
16 changes: 6 additions & 10 deletions crates/common/mqtt_channel/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,16 +297,12 @@ impl Connection {
}

pub(crate) fn pause_on_error(err: &ConnectionError) -> bool {
match &err {
rumqttc::ConnectionError::Io(_) => true,
rumqttc::ConnectionError::MqttState(state_error)
if matches!(state_error, StateError::Io(_)) =>
{
true
}
rumqttc::ConnectionError::MqttState(_) => true,
_ => false,
}
matches!(
err,
rumqttc::ConnectionError::Io(_)
| rumqttc::ConnectionError::MqttState(StateError::Io(_))
| rumqttc::ConnectionError::MqttState(_)
)
}

pub(crate) async fn do_pause() {
Expand Down
6 changes: 3 additions & 3 deletions crates/core/plugin_sm/src/operation_logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ impl OperationLogs {
if path.starts_with("software-list") {
log_tracker
.entry("software-list".to_string())
.or_insert_with(BinaryHeap::new)
.or_default()
.push(Reverse(path.to_string()));
} else if path.starts_with("software-update") {
log_tracker
.entry("software-update".to_string())
.or_insert_with(BinaryHeap::new)
.or_default()
.push(Reverse(path.to_string()));
} else {
let file_name = path
Expand All @@ -102,7 +102,7 @@ impl OperationLogs {
.ok_or(OperationLogsError::FileFormatError)?;
log_tracker
.entry(file_name.to_string())
.or_insert_with(BinaryHeap::new)
.or_default()
.push(Reverse(path.to_string()));
}
}
Expand Down

1 comment on commit 92a505d

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
256 1 5 257 99.61

Failed Tests

Name Message ⏱️ Duration Suite
Check PID number in lock file after restarting the services 1272 1308 != 1272 63.243 s Lock File

Please sign in to comment.