sysmaster/backport-fix-fix-some-cargo-clippies.patch
licunlong 0c7d548f94 sync patches from upstream
(cherry picked from commit e23ebb83bd7672e4dc8da68a9a8c73fe6e016341)
2023-06-19 10:39:49 +08:00

123 lines
3.6 KiB
Diff

From 4490bcd3d40b15f22446af46500039d2cbd37bf9 Mon Sep 17 00:00:00 2001
From: licunlong <licunlong1@huawei.com>
Date: Wed, 31 May 2023 11:24:36 +0800
Subject: [PATCH 9/9] fix: fix some cargo clippies
---
coms/socket/src/unit.rs | 4 ++--
core/bin/unit/data/table.rs | 3 +--
core/bin/unit/datastore/sets.rs | 2 +-
core/bin/utils/table.rs | 6 +-----
core/lib/error.rs | 3 +++
core/lib/unit/base.rs | 2 +-
6 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/coms/socket/src/unit.rs b/coms/socket/src/unit.rs
index d96c258..9f0f6ce 100644
--- a/coms/socket/src/unit.rs
+++ b/coms/socket/src/unit.rs
@@ -22,8 +22,8 @@ use crate::{
};
use basic::logger;
use nix::sys::wait::WaitStatus;
-use std::{path::PathBuf, rc::Rc};
use std::any::Any;
+use std::{path::PathBuf, rc::Rc};
use sysmaster::error::*;
use sysmaster::exec::ExecContext;
use sysmaster::rel::{ReStation, Reliability};
@@ -115,7 +115,7 @@ impl SubUnit for SocketUnit {
Ok(())
}
- fn trigger(&self, other: &String) {
+ fn trigger(&self, other: &str) {
let um = self.comm.um();
let service_state = um.get_subunit_state(other);
if [
diff --git a/core/bin/unit/data/table.rs b/core/bin/unit/data/table.rs
index 161ac5f..256e8df 100644
--- a/core/bin/unit/data/table.rs
+++ b/core/bin/unit/data/table.rs
@@ -60,8 +60,7 @@ impl DataManager {
ud_config: UnitDepConf,
) -> Option<UnitDepConf> {
{
- let old = self.tables.0.insert(u_name, ud_config);
- old
+ self.tables.0.insert(u_name, ud_config)
}
}
diff --git a/core/bin/unit/datastore/sets.rs b/core/bin/unit/datastore/sets.rs
index 538df8f..9a94a4b 100644
--- a/core/bin/unit/datastore/sets.rs
+++ b/core/bin/unit/datastore/sets.rs
@@ -62,7 +62,7 @@ impl UnitSets {
.borrow()
.get_all()
.iter()
- .map(|ur| Rc::clone(ur))
+ .map(Rc::clone)
.collect::<Vec<_>>()
}
diff --git a/core/bin/utils/table.rs b/core/bin/utils/table.rs
index e1768d2..482d168 100644
--- a/core/bin/utils/table.rs
+++ b/core/bin/utils/table.rs
@@ -82,11 +82,7 @@ where
}
pub fn get_all(&self) -> Vec<V> {
- self.data
- .borrow()
- .values()
- .map(|v| v.clone())
- .collect::<Vec<V>>()
+ self.data.borrow().values().cloned().collect::<Vec<V>>()
}
pub fn subscribe(
diff --git a/core/lib/error.rs b/core/lib/error.rs
index 331f367..72471db 100644
--- a/core/lib/error.rs
+++ b/core/lib/error.rs
@@ -290,6 +290,7 @@ impl From<event::Error> for Error {
/// new Result
pub type Result<T, E = Error> = std::result::Result<T, E>;
+/// check if the error is disconnect
pub fn error_is_disconnect(e: &Errno) -> bool {
[
Errno::ECONNABORTED,
@@ -310,10 +311,12 @@ pub fn error_is_disconnect(e: &Errno) -> bool {
.contains(e)
}
+/// check if the error is transient
pub fn error_is_transient(e: &Errno) -> bool {
[Errno::EAGAIN, Errno::EINTR].contains(e)
}
+/// check if the error is accept or again
pub fn error_is_accept_again(e: &Errno) -> bool {
error_is_disconnect(e) || error_is_transient(e) || e == &Errno::EOPNOTSUPP
}
diff --git a/core/lib/unit/base.rs b/core/lib/unit/base.rs
index 8d76cab..2ec3e73 100644
--- a/core/lib/unit/base.rs
+++ b/core/lib/unit/base.rs
@@ -128,7 +128,7 @@ pub trait SubUnit: ReStation + UnitMngUtil {
}
///
- fn trigger(&self, _other: &String) {}
+ fn trigger(&self, _other: &str) {}
///Get the the unit state
///
--
2.30.2