Skip to content

Commit

Permalink
解决warning
Browse files Browse the repository at this point in the history
  • Loading branch information
GnoCiYeH committed Oct 3, 2023
1 parent 4aac100 commit 0794b7f
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "DragonReach"
name = "dragon_reach"
version = "0.1.0"
edition = "2021"

Expand Down
3 changes: 3 additions & 0 deletions src/executor/dep_graph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,21 @@ use crate::{
unit::Unit,
};

#[allow(dead_code)]
pub struct DepGraphNode {
value: usize,
edges: Vec<usize>,
incoming_edges: Vec<usize>,
}

#[allow(dead_code)]
pub struct DepGraph {
nodes: Vec<DepGraphNode>,
value: Vec<usize>,
}

// 提供拓扑排序方法,在启动服务时确定先后顺序
#[allow(dead_code)]
impl DepGraph {
fn new() -> Self {
return DepGraph {
Expand Down
2 changes: 1 addition & 1 deletion src/executor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ pub mod service_executor;
use crate::{
error::runtime_error::{RuntimeError, RuntimeErrorType},
manager::UnitManager,
unit::Unit,
};

#[allow(dead_code)]
#[derive(Debug, Clone, Copy)]
pub enum ExitStatus {
Success, // 成功退出
Expand Down
2 changes: 2 additions & 0 deletions src/manager/unit_manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub struct RunningTableManager {
running_table: HashMap<usize, Child>,
}

#[allow(dead_code)]
impl RunningTableManager {
pub fn running_table(&self) -> &HashMap<usize, Child> {
&self.running_table
Expand All @@ -50,6 +51,7 @@ pub struct UnitManager;

unsafe impl Sync for UnitManager {}

#[allow(dead_code)]
impl UnitManager {
/// 插入一条path到unit_id的映射
pub fn insert_into_path_table(path: &str, unit: usize) {
Expand Down
3 changes: 1 addition & 2 deletions src/parse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@ impl UnitParser {
//下面进行属性匹配
//合并多行为一个属性的情况
//最后一个字符为\,代表换行,将多行转换为一行统一解析
let mut templine = String::new();
if lines[i].ends_with('\\') {
let mut templine = String::new();
while lines[i].ends_with('\\') {
let temp = &lines[i][..lines[i].len() - 1];
templine = format!("{} {}", templine, temp);
Expand All @@ -283,7 +283,6 @@ impl UnitParser {
templine = format!("{} {}", templine, lines[i]);
line = templine.as_str();
i += 1;
break;
}
//=号分割后第一个元素为属性,后面的均为值
let (attr_str, val_str) = match line.find('=') {
Expand Down
20 changes: 10 additions & 10 deletions src/parse/parse_util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use std::{

use super::{UnitParser, BASE_IEC, BASE_SI, SEC_UNIT_TABLE};

#[allow(dead_code)]
#[derive(PartialEq)]
pub enum SizeBase {
IEC,
Expand All @@ -21,6 +22,7 @@ pub enum SizeBase {

pub struct UnitParseUtil;

#[allow(dead_code)]
impl UnitParseUtil {
/// @brief 解析布尔值
///
Expand Down Expand Up @@ -147,14 +149,12 @@ impl UnitParseUtil {
}

let mtu: u32 = mtu as u32;

let mut min_mtu: u32 = 0;
//判断mtu是否合法
if family == AF_INET6 {
min_mtu = IPV6_MIN_MTU;
} else if family == AF_INET {
min_mtu = IPV4_MIN_MTU;
} else {
if family == AF_INET6 && mtu < IPV6_MIN_MTU {
return Err(ParseError::new(ParseErrorType::ERANGE, String::new(), 0));
} else if family == AF_INET && mtu < IPV4_MIN_MTU {
return Err(ParseError::new(ParseErrorType::ERANGE, String::new(), 0));
} else if family != AF_INET6 || family != AF_INET {
return Err(ParseError::new(ParseErrorType::EINVAL, String::new(), 0));
}

Expand Down Expand Up @@ -491,7 +491,7 @@ impl UnitParseUtil {
cmd_task.ignore = cmds[i].starts_with('-');

//获取到一个CmdTask的路径部分
let mut path = String::new();
let path: String;
if cmd_task.ignore {
path = String::from(&cmds[i][1..]);
} else {
Expand Down Expand Up @@ -579,9 +579,9 @@ impl UnitParseUtil {
/// @return 解析成功则返回Ok(u64),否则返回Err
pub fn parse_sec(s: &str) -> Result<u64, ParseError> {
//下列参数分别记录整数部分,小数部分以及单位
let mut integer: u64 = 0;
let integer: u64;
let mut frac: u64 = 0;
let mut unit: &str = "";
let unit: &str;

match s.find('.') {
Some(idx) => {
Expand Down
7 changes: 7 additions & 0 deletions src/unit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ pub trait Unit: Sync + Send + Debug {
}

//Unit状态
#[allow(dead_code)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum UnitState {
Enabled,
Expand All @@ -114,6 +115,7 @@ pub enum UnitState {
}

//Unit类型
#[allow(dead_code)]
#[derive(Clone, Copy, PartialEq, Debug)]
pub enum UnitType {
Automount,
Expand Down Expand Up @@ -153,6 +155,7 @@ impl Default for BaseUnit {
}
}

#[allow(dead_code)]
impl BaseUnit {
pub fn set_state(&mut self, state: UnitState) {
self.state = state;
Expand Down Expand Up @@ -262,6 +265,7 @@ impl Default for UnitPart {
}
}

#[allow(dead_code)]
impl UnitPart {
pub fn set_attr(&mut self, attr: &BaseUnitAttr, val: &str) -> Result<(), ParseError> {
match attr {
Expand Down Expand Up @@ -421,6 +425,7 @@ impl Default for InstallPart {
}
}

#[allow(dead_code)]
impl InstallPart {
pub fn set_attr(&mut self, attr: &InstallUnitAttr, val: &str) -> Result<(), ParseError> {
match attr {
Expand Down Expand Up @@ -475,6 +480,7 @@ impl InstallPart {
}
}
//对应Unit文件的各种属性
#[allow(dead_code)]
pub enum BaseUnitAttr {
None,

Expand All @@ -501,6 +507,7 @@ pub enum BaseUnitAttr {
Conflicts,
}

#[allow(dead_code)]
pub enum InstallUnitAttr {
None,
//Install段
Expand Down
2 changes: 2 additions & 0 deletions src/unit/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ impl Default for MountFlag {
}
}

#[allow(dead_code)]
#[derive(Default, Debug, Clone)]
pub struct ServicePart {
//生命周期相关
Expand Down Expand Up @@ -285,6 +286,7 @@ pub enum ServiceUnitAttr {
MountFlags,
}

#[allow(dead_code)]
impl ServicePart {
pub fn set_attr(&'_ mut self, attr: &ServiceUnitAttr, val: &str) -> Result<(), ParseError> {
match attr {
Expand Down

0 comments on commit 0794b7f

Please sign in to comment.