Skip to content

Commit fb8ca6b

Browse files
daniel-nolandFredi-raspall
authored andcommitted
fixup: init rework
1 parent 71eba94 commit fb8ca6b

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

init/src/main.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Copyright Open Network Fabric Authors
33

44
#![doc = include_str!("../README.md")]
5-
// #![deny(clippy::pedantic, missing_docs)] // TEMP: don't merge till uncommented
5+
#![deny(clippy::pedantic)]
66

77
use std::{
88
collections::{BTreeMap, BTreeSet},
@@ -64,7 +64,7 @@ impl std::fmt::Display for DevicesNotFound {
6464
let devices_str = self
6565
.missing
6666
.iter()
67-
.map(|elem| elem.to_string())
67+
.map(std::string::ToString::to_string)
6868
.collect::<Vec<_>>()
6969
.join(", ");
7070
write!(f, "missing devices: {devices_str}")
@@ -144,6 +144,7 @@ impl DeviceSearch {
144144

145145
/// Walk the full system hardware scan and collect the list of devices which are requested but which can not be
146146
/// found in the scan at all.
147+
#[must_use]
147148
pub fn missing(&self) -> BTreeSet<NetworkDeviceDescription> {
148149
let matching: BTreeSet<_> = self.matching().keys().cloned().collect();
149150
self.requested.difference(&matching).cloned().collect()
@@ -200,6 +201,7 @@ impl DeviceSearch {
200201
}
201202

202203
/// Walk the hardware scan and find the devices which are both supported and requested.
204+
#[must_use]
203205
pub fn scheduled_for_use(&self) -> BTreeMap<NetworkDeviceDescription, &hardware::Node> {
204206
let matching: BTreeSet<_> = self.matching().keys().cloned().collect();
205207
let supportable = self.supportable();
@@ -217,6 +219,7 @@ impl DeviceSearch {
217219
.collect()
218220
}
219221

222+
#[must_use]
220223
pub fn requested_but_not_supported(&self) -> BTreeMap<String, &hardware::Node> {
221224
let matching = self.matching();
222225
let matching_keys: BTreeSet<_> = matching.keys().cloned().collect();
@@ -240,6 +243,7 @@ impl DeviceSearch {
240243
.collect()
241244
}
242245

246+
#[must_use]
243247
pub fn report(&self) -> NetworkDeviceSearchReport<'_> {
244248
NetworkDeviceSearchReport::new(self)
245249
}
@@ -252,7 +256,8 @@ pub struct NetworkDeviceSearchReport<'search> {
252256
missing: BTreeSet<NetworkDeviceDescription>,
253257
supportable: BTreeMap<String, &'search hardware::Node>,
254258
scheduled_for_use: BTreeMap<String, &'search hardware::Node>,
255-
// TODO: I don't understand why this needs to be a string. The requested_but_not_supported method crashes otherwise
259+
// TODO: I don't understand why this key needs to be a string.
260+
// The requested_but_not_supported method crashes otherwise when serializing.
256261
requested_but_not_supported: BTreeMap<String, &'search hardware::Node>,
257262
}
258263

@@ -381,7 +386,7 @@ fn main() {
381386
error!("dataplane failed to initialize");
382387
panic!("dataplane failed to initialize");
383388
}
384-
};
389+
}
385390
search
386391
.scheduled_for_use()
387392
.iter()
@@ -423,19 +428,19 @@ fn main() {
423428
},
424429
},
425430
Err(_) => unreachable!(), // TODO: restructure to remove this branch
426-
};
431+
}
427432
});
428433
}
429434
args::DriverConfigSection::Kernel(_kernel_section) => todo!(),
430-
};
435+
}
431436

432437
let mut launch_config = launch_config.finalize();
433438
let integrity_check = launch_config.integrity_check().finalize().to_owned_fd();
434439

435440
let launch_config = launch_config.to_owned_fd();
436441

437442
let io_err = std::process::Command::new(
438-
"/home/dnoland/code/githedgehog/dataplane/target/x86_64-unknown-linux-gnu/debug/dataplane",
443+
"/bin/dataplane",
439444
)
440445
.fd_mappings(vec![
441446
FdMapping {

0 commit comments

Comments
 (0)