Skip to content

Commit c9ccfca

Browse files
committed
src: cleanup for new cargo versions
Format and clean code according to new specs Signed-off-by: Aditya R <arajan@redhat.com>
1 parent 5367866 commit c9ccfca

File tree

4 files changed

+14
-21
lines changed

4 files changed

+14
-21
lines changed

src/commands/teardown.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl Teardown {
4848

4949
if Path::new(&aardvark_bin).exists() {
5050
// stop dns server first before netavark clears the interface
51-
let path = Path::new(&config_dir).join("aardvark-dns".to_string());
51+
let path = Path::new(&config_dir).join("aardvark-dns");
5252
if let Ok(path_string) = path.into_os_string().into_string() {
5353
let mut aardvark_interface = Aardvark::new(path_string, rootless, aardvark_bin);
5454
if let Err(er) =

src/dns/aardvark.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,18 @@ impl Aardvark {
4545

4646
// On success retuns aardvark server's pid or returns -1;
4747
fn get_aardvark_pid(&mut self) -> i32 {
48-
let pid: i32;
49-
let path = Path::new(&self.config).join("aardvark.pid".to_string());
50-
match fs::read_to_string(&path) {
51-
Ok(content) => {
52-
pid = match content.parse::<i32>() {
53-
Ok(val) => val,
54-
Err(_) => {
55-
return -1;
56-
}
48+
let path = Path::new(&self.config).join("aardvark.pid");
49+
let pid: i32 = match fs::read_to_string(&path) {
50+
Ok(content) => match content.parse::<i32>() {
51+
Ok(val) => val,
52+
Err(_) => {
53+
return -1;
5754
}
58-
}
55+
},
5956
Err(_) => {
6057
return -1;
6158
}
62-
}
59+
};
6360

6461
pid
6562
}
@@ -161,14 +158,13 @@ impl Aardvark {
161158
}
162159

163160
pub fn commit_entry(&mut self, entry: AardvarkEntry) -> Result<()> {
164-
let data: String;
161+
let mut data: String;
165162
let path = Path::new(&self.config).join(entry.network_name);
166163
let file_exists = path.exists();
167164
let mut file = OpenOptions::new().append(true).create(true).open(&path)?;
168165
// check if this is the first container in this network
169166
if !file_exists {
170167
// write first line as gateway ip
171-
let data: String;
172168
if !entry.network_gateway_v4.is_empty() && !entry.network_gateway_v6.is_empty() {
173169
data = format!(
174170
"{},{}\n",

src/network/core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ impl Core {
535535
&container_macvlan_clone,
536536
netns_ipaddr_clone,
537537
gw_ipaddr,
538-
&"".to_string(), // do we want static mac support for macvlan ? probably later.
538+
"", // do we want static mac support for macvlan ? probably later.
539539
) {
540540
return Err(err);
541541
}

src/network/core_utils.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,9 @@ impl CoreUtils {
145145

146146
tokio::spawn(connection);
147147

148-
let master_index: u32;
149-
150148
let mut links = handle.link().get().match_name(ifname.to_string()).execute();
151-
match links.try_next().await {
152-
Ok(Some(msg)) => master_index = msg.header.index,
153-
149+
let master_index: u32 = match links.try_next().await {
150+
Ok(Some(msg)) => msg.header.index,
154151
Ok(None) => {
155152
return Err(std::io::Error::new(
156153
std::io::ErrorKind::Other,
@@ -166,7 +163,7 @@ impl CoreUtils {
166163
format!("Unable to resolve bridge interface {}: {}", ifname, err),
167164
));
168165
}
169-
}
166+
};
170167

171168
let mut links = handle
172169
.link()

0 commit comments

Comments
 (0)