Skip to content

Commit c6874d9

Browse files
committed
cargo clippy
1 parent 4f2f830 commit c6874d9

13 files changed

Lines changed: 29 additions & 33 deletions

File tree

pixie-server/src/dnsmasq.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ async fn write_config(state: &State) -> Result<()> {
4141

4242
let dhcp_dynamic_conf = match state.config.hosts.dhcp {
4343
DhcpMode::Static(low, high) => format!("dhcp-range=tag:netboot,{low},{high}"),
44-
DhcpMode::Proxy(ip) => format!("dhcp-range=tag:netboot,{},proxy", ip),
44+
DhcpMode::Proxy(ip) => format!("dhcp-range=tag:netboot,{ip},proxy"),
4545
};
4646

4747
let storage_str = state.storage_dir.to_str().unwrap();
@@ -89,9 +89,9 @@ async fn write_hosts(state: &State, hosts: &[(MacAddr6, Ipv4Addr, Option<String>
8989

9090
for (mac, ip, hostname) in hosts {
9191
if let Some(hostname) = hostname {
92-
writeln!(file, "{},{},{}", mac, ip, hostname)?;
92+
writeln!(file, "{mac},{ip},{hostname}")?;
9393
} else {
94-
writeln!(file, "{},{}", mac, ip)?;
94+
writeln!(file, "{mac},{ip}")?;
9595
}
9696
}
9797
Ok(())

pixie-server/src/http.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ async fn image(
8080
if !state.config.images.contains(&image) {
8181
return (
8282
StatusCode::BAD_REQUEST,
83-
format!("Unknown image: {:?}\n", image),
83+
format!("Unknown image: {image:?}\n"),
8484
);
8585
}
8686

@@ -128,7 +128,7 @@ async fn rollback(
128128
) -> impl IntoResponse {
129129
match state.rollback_image(&image) {
130130
Ok(()) => (StatusCode::NO_CONTENT, String::new()),
131-
Err(e) => (StatusCode::INTERNAL_SERVER_ERROR, format!("{}\n", e)),
131+
Err(e) => (StatusCode::INTERNAL_SERVER_ERROR, format!("{e}\n")),
132132
}
133133
}
134134

pixie-server/src/ping.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub async fn main(state: Arc<State>) -> Result<()> {
2929
let peer_mac = match find_mac(peer_ip) {
3030
Ok(peer_mac) => peer_mac,
3131
Err(err) => {
32-
log::error!("Error handling ping packet: {}", err);
32+
log::error!("Error handling ping packet: {err}");
3333
continue;
3434
}
3535
};

pixie-server/src/state/images.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ impl State {
165165
}
166166
let now = chrono::Utc::now();
167167
let version = now.to_rfc3339_opts(chrono::SecondsFormat::Secs, true);
168-
let name_with_version = format!("{}@{}", name, version);
168+
let name_with_version = format!("{name}@{version}");
169169
self.write_image(name, image, images_stats, &mut chunks_stats)?;
170170
self.write_image(name_with_version, image, images_stats, &mut chunks_stats)?;
171171
Ok(())

pixie-server/src/tcp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ async fn handle_connection(
6363
let peer_mac = match find_mac(peer_ip) {
6464
Ok(peer_mac) => peer_mac,
6565
Err(err) => {
66-
log::error!("Error handling tcp connection: {}", err);
66+
log::error!("Error handling tcp connection: {err}");
6767
return Ok(());
6868
}
6969
};
@@ -94,7 +94,7 @@ pub async fn main(state: Arc<State>) -> Result<()> {
9494
let state = state.clone();
9595
tokio::spawn(async move {
9696
if let Err(e) = handle_connection(state, stream, addr).await {
97-
log::error!("Error handling tcp connection: {}", e);
97+
log::error!("Error handling tcp connection: {e}");
9898
}
9999
});
100100
}

pixie-server/src/udp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ async fn handle_requests(state: &State, socket: &UdpSocket, tx: Sender<[u8; 32]>
208208
state.set_unit_progress(UnitSelector::MacAddr(peer_mac), Some((frac, tot)));
209209
}
210210
Err(err) => {
211-
log::error!("Error handling udp packet: {}", err);
211+
log::error!("Error handling udp packet: {err}");
212212
}
213213
};
214214
}
@@ -218,7 +218,7 @@ async fn handle_requests(state: &State, socket: &UdpSocket, tx: Sender<[u8; 32]>
218218
}
219219
}
220220
Err(e) => {
221-
log::warn!("Invalid request from {}: {}", addr, e);
221+
log::warn!("Invalid request from {addr}: {e}");
222222
}
223223
}
224224
}

pixie-uefi/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ async fn run(os: UefiOS) -> Result<()> {
133133
}
134134
} else {
135135
last_was_wait = false;
136-
log::info!("Command: {:?}", command);
136+
log::info!("Command: {command:?}");
137137
match command {
138138
Action::Wait => unreachable!(),
139139
Action::Reboot => reboot_to_os(os).await,

pixie-uefi/src/os/boot_options.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@ impl BootOptions {
7676

7777
pub fn get(&self, id: u16) -> Vec<u8> {
7878
self.os
79-
.get_variable(&format!("Boot{:04X}", id), &VariableVendor::GLOBAL_VARIABLE)
79+
.get_variable(&format!("Boot{id:04X}"), &VariableVendor::GLOBAL_VARIABLE)
8080
.unwrap()
8181
.0
8282
}
8383

8484
pub fn set(&self, id: u16, data: &[u8]) {
8585
self.os
8686
.set_variable(
87-
&format!("Boot{:04X}", id),
87+
&format!("Boot{id:04X}"),
8888
&VariableVendor::GLOBAL_VARIABLE,
8989
VariableAttributes::NON_VOLATILE
9090
| VariableAttributes::BOOTSERVICE_ACCESS

pixie-uefi/src/os/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,6 @@ impl From<uefi::Error> for Error {
6969

7070
impl Display for Error {
7171
fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), core::fmt::Error> {
72-
write!(fmt, "{:?}", self)
72+
write!(fmt, "{self:?}")
7373
}
7474
}

pixie-uefi/src/os/mod.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl UefiOSImpl {
128128
let (cols, rows) = (mode.columns(), mode.rows());
129129
for (msg, fg, bg) in self.ui_buf.drain(..) {
130130
self.vga.set_color(fg, bg).unwrap();
131-
write!(self.vga, "{}", msg).unwrap();
131+
write!(self.vga, "{msg}").unwrap();
132132
}
133133
self.vga.set_color(Color::White, Color::Black).unwrap();
134134
if self.ui_pos + 1 < cols * rows {
@@ -216,7 +216,7 @@ impl UefiOS {
216216
os.spawn("init", async move {
217217
loop {
218218
if let Err(err) = f(os).await {
219-
log::error!("Error: {:?}", err);
219+
log::error!("Error: {err:?}");
220220
}
221221
}
222222
});
@@ -227,7 +227,7 @@ impl UefiOS {
227227

228228
if let Err(err) = err {
229229
if err.status() != Status::UNSUPPORTED {
230-
log::error!("Error disabling watchdog: {:?}", err);
230+
log::error!("Error disabling watchdog: {err:?}");
231231
}
232232

233233
break;
@@ -361,7 +361,7 @@ impl UefiOS {
361361
let mut name_buf = vec![0u16; name.len() * 2 + 16];
362362
let name = CStr16::from_str_with_buf(name, &mut name_buf).unwrap();
363363
let (var, attrs) = uefi::runtime::get_variable_boxed(name, vendor)
364-
.map_err(|e| Error::Generic(format!("Error getting variable: {:?}", e)))?;
364+
.map_err(|e| Error::Generic(format!("Error getting variable: {e:?}")))?;
365365
Ok((var.to_vec(), attrs))
366366
}
367367

@@ -376,7 +376,7 @@ impl UefiOS {
376376
let mut name_buf = vec![0u16; name.len() * 2 + 16];
377377
let name = CStr16::from_str_with_buf(name, &mut name_buf).unwrap();
378378
uefi::runtime::set_variable(name, vendor, attrs, data)
379-
.map_err(|e| Error::Generic(format!("Error setting variable: {:?}", e)))?;
379+
.map_err(|e| Error::Generic(format!("Error setting variable: {e:?}")))?;
380380
Ok(())
381381
}
382382

@@ -461,15 +461,11 @@ impl UefiOS {
461461
let mode = os.vga.current_mode().unwrap().unwrap();
462462
let cols = mode.columns();
463463

464-
os.write_with_color(
465-
&format!("uptime: {:10.1}s", time),
466-
Color::White,
467-
Color::Black,
468-
);
464+
os.write_with_color(&format!("uptime: {time:10.1}s"), Color::White, Color::Black);
469465
os.maybe_advance_to_col(cols / 3);
470466

471467
if let Some(ip) = ip {
472-
os.write_with_color(&format!("IP: {}", ip), Color::White, Color::Black);
468+
os.write_with_color(&format!("IP: {ip}"), Color::White, Color::Black);
473469
} else {
474470
os.write_with_color("DHCP...", Color::Yellow, Color::Black);
475471
}

0 commit comments

Comments
 (0)