Skip to content

Commit 199802d

Browse files
authored
Fix new lints (#914)
* Fix `clippy::uninlined_format_args` lints Thanks, Clippy, for causing a whole bunch of needless churn for basically no good reason! * Fix `dangerous_implicit_autorefs` warning in `dladm` This [warning] warns about the creation of implicit references to the dereference of a raw pointer. I've fixed this by using `ptr::addr_of!` and `slice::from_raw_parts` to construct the slice into `ma_addr`, avoiding the creation of temporary references through the raw pointer. In this case, the suggestions from the lint of just adding an additional explicit `&` reference as a way of saying "this is okay, because I know the pointer is non-null and well-aligned" would *probably* have been fine, but this felt less sketchy. [warning]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/autorefs/static.DANGEROUS_IMPLICIT_AUTOREFS.html
1 parent 0e06506 commit 199802d

32 files changed

Lines changed: 84 additions & 99 deletions

File tree

bin/mock-server/src/lib/lib.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,7 @@ async fn instance_state_put(
356356
instance.set_target_state(&rqctx.log, requested_state).await.map_err(
357357
|err| {
358358
HttpError::for_internal_error(format!(
359-
"Failed to transition: {}",
360-
err
359+
"Failed to transition: {err}"
361360
))
362361
},
363362
)?;
@@ -758,8 +757,7 @@ mod serial {
758757
let mut entropy = hasher.finish();
759758
buf.extend(
760759
format!(
761-
"This is simulated serial console output for {}.\r\n",
762-
name
760+
"This is simulated serial console output for {name}.\r\n"
763761
)
764762
.as_bytes(),
765763
);
@@ -780,8 +778,7 @@ mod serial {
780778
}
781779
buf.extend(
782780
format!(
783-
"\x1b[2J\x1b[HOS/478 ({name}) (ttyl)\r\n\r\n{name} login: ",
784-
name = name
781+
"\x1b[2J\x1b[HOS/478 ({name}) (ttyl)\r\n\r\n{name} login: "
785782
)
786783
.as_bytes(),
787784
);

bin/propolis-cli/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ async fn serial(
679679
stdout.flush().await?;
680680
}
681681
Ok(Message::Close(Some(CloseFrame {code, reason}))) => {
682-
eprint!("\r\nConnection closed: {:?}\r\n", code);
682+
eprint!("\r\nConnection closed: {code:?}\r\n");
683683
match code {
684684
CloseCode::Abnormal
685685
| CloseCode::Error
@@ -826,7 +826,7 @@ async fn migrate_instance(
826826
}
827827

828828
let state = migration.state;
829-
println!("{}({}) migration state={:?}", role, id, state);
829+
println!("{role}({id}) migration state={state:?}");
830830
if state == MigrationState::Finish {
831831
return Ok::<_, anyhow::Error>(());
832832
} else if state == MigrationState::Error {

bin/propolis-server/src/lib/initializer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ impl MachineInitializer<'_> {
224224
}
225225

226226
let (romfp, rom_len) = open_bootrom(path)
227-
.unwrap_or_else(|e| panic!("Cannot open bootrom: {}", e));
227+
.unwrap_or_else(|e| panic!("Cannot open bootrom: {e}"));
228228

229229
let mem = self.machine.acc_mem.access().unwrap();
230230
let mapping = mem
@@ -649,7 +649,7 @@ impl MachineInitializer<'_> {
649649

650650
// Limit data transfers to 1MiB (2^8 * 4k) in size
651651
let mdts = Some(8);
652-
let component = format!("nvme-{}", device_id);
652+
let component = format!("nvme-{device_id}");
653653
let nvme = nvme::PciNvme::create(
654654
&nvme_spec.serial_number,
655655
mdts,

bin/propolis-server/src/lib/migrate/destination.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -552,8 +552,7 @@ impl<T: MigrateConn> RonV0<T> {
552552
let time_data_src: vmm::time::VmTimeData = ron::from_str(&raw)
553553
.map_err(|e| {
554554
MigrateError::TimeData(format!(
555-
"VMM Time Data deserialization error: {}",
556-
e
555+
"VMM Time Data deserialization error: {e}"
557556
))
558557
})?;
559558
probes::migrate_time_data_before!(|| {
@@ -571,17 +570,13 @@ impl<T: MigrateConn> RonV0<T> {
571570

572571
let (dst_hrt, dst_wc) = vmm::time::host_time_snapshot(vmm_hdl)
573572
.map_err(|e| {
574-
MigrateError::TimeData(format!(
575-
"could not read host time: {}",
576-
e
577-
))
573+
MigrateError::TimeData(format!("could not read host time: {e}"))
578574
})?;
579575
let (time_data_dst, adjust) =
580576
vmm::time::adjust_time_data(time_data_src, dst_hrt, dst_wc)
581577
.map_err(|e| {
582578
MigrateError::TimeData(format!(
583-
"could not adjust VMM Time Data: {}",
584-
e
579+
"could not adjust VMM Time Data: {e}"
585580
))
586581
})?;
587582

@@ -635,7 +630,7 @@ impl<T: MigrateConn> RonV0<T> {
635630

636631
// Import the adjusted time data
637632
vmm::time::import_time_data(vmm_hdl, time_data_dst).map_err(|e| {
638-
MigrateError::TimeData(format!("VMM Time Data import error: {}", e))
633+
MigrateError::TimeData(format!("VMM Time Data import error: {e}"))
639634
})?;
640635

641636
self.send_msg(codec::Message::Okay).await

bin/propolis-server/src/lib/migrate/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl std::fmt::Display for MigratePhase {
6161
MigratePhase::Finish => "Finish",
6262
};
6363

64-
write!(f, "{}", s)
64+
write!(f, "{s}")
6565
}
6666
}
6767

@@ -173,7 +173,7 @@ impl From<MigrateStateError> for MigrateError {
173173

174174
impl From<MigrateError> for HttpError {
175175
fn from(err: MigrateError) -> Self {
176-
let msg = format!("migration failed: {}", err);
176+
let msg = format!("migration failed: {err}");
177177
match &err {
178178
MigrateError::Websocket(_)
179179
| MigrateError::Initiate

bin/propolis-server/src/lib/migrate/source.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -748,8 +748,7 @@ impl<T: MigrateConn> RonV0Runner<'_, T> {
748748
let vm_time_data =
749749
vmm::time::export_time_data(vmm_hdl).map_err(|e| {
750750
MigrateError::TimeData(format!(
751-
"VMM Time Data export error: {}",
752-
e
751+
"VMM Time Data export error: {e}"
753752
))
754753
})?;
755754
info!(self.log(), "VMM Time Data: {:#?}", vm_time_data);

bin/propolis-server/src/lib/server.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ impl LazyNexusClient {
150150
let address = self.get_ip().await?;
151151

152152
Ok(NexusClient::new(
153-
&format!("http://{}", address),
153+
&format!("http://{address}"),
154154
self.inner.log.clone(),
155155
))
156156
}
@@ -336,8 +336,7 @@ async fn instance_state_monitor(
336336
Some(api::ErrorCode::NoInstance.to_string()),
337337
ClientErrorStatusCode::GONE,
338338
format!(
339-
"No instance present; will never reach generation {}",
340-
gen
339+
"No instance present; will never reach generation {gen}",
341340
),
342341
)
343342
})?;
@@ -366,8 +365,7 @@ async fn instance_state_put(
366365
VmError::ForbiddenStateChange(reason) => {
367366
HttpError::for_client_error_with_status(
368367
Some(format!(
369-
"instance state change not allowed: {}",
370-
reason
368+
"instance state change not allowed: {reason}"
371369
)),
372370
ClientErrorStatusCode::FORBIDDEN,
373371
)
@@ -469,7 +467,7 @@ async fn instance_serial(
469467
.websocks_ch
470468
.send(ws_stream)
471469
.await
472-
.map_err(|e| format!("Serial socket hand-off failed: {}", e).into())
470+
.map_err(|e| format!("Serial socket hand-off failed: {e}").into())
473471
}
474472

475473
#[channel {
@@ -624,7 +622,7 @@ async fn instance_issue_crucible_vcr_request(
624622
.map_err(|e| match e {
625623
VmError::ForbiddenStateChange(reason) => {
626624
HttpError::for_client_error_with_status(
627-
Some(format!("instance state change not allowed: {}", reason)),
625+
Some(format!("instance state change not allowed: {reason}")),
628626
ClientErrorStatusCode::FORBIDDEN,
629627
)
630628
}

bin/propolis-server/src/lib/stats/virtual_machine.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -495,10 +495,9 @@ mod test {
495495
)
496496
.unwrap_or_else(|| {
497497
panic!(
498-
"kstat state '{}' did not map to an oximeter state, \
499-
which it should have done. Did that state get \
500-
mapped to a new oximeter-level state?",
501-
kstat_state
498+
"kstat state '{kstat_state}' did not map to an \
499+
oximeter state, which it should have done. Did that \
500+
state get mapped to a new oximeter-level state?"
502501
)
503502
});
504503
*observed_states.entry(oximeter_state).or_default() += count;

bin/propolis-server/src/lib/vm/state_driver.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,11 +321,11 @@ impl guest_event::VcpuEventHandler for InputQueue {
321321
vcpu_id: i32,
322322
exit: propolis::exits::VmExitKind,
323323
) {
324-
panic!("vCPU {}: Unhandled VM exit: {:?}", vcpu_id, exit);
324+
panic!("vCPU {vcpu_id}: Unhandled VM exit: {exit:?}");
325325
}
326326

327327
fn io_error_event(&self, vcpu_id: i32, error: std::io::Error) {
328-
panic!("vCPU {}: Unhandled vCPU error: {}", vcpu_id, error);
328+
panic!("vCPU {vcpu_id}: Unhandled vCPU error: {error}");
329329
}
330330
}
331331

bin/propolis-standalone/src/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ pub fn block_backend(
168168
) -> (Arc<dyn block::Backend>, String) {
169169
let backend_name = dev.options.get("block_dev").unwrap().as_str().unwrap();
170170
let Some(be) = config.block_devs.get(backend_name) else {
171-
panic!("No configured block device named \"{}\"", backend_name);
171+
panic!("No configured block device named \"{backend_name}\"");
172172
};
173173
let opts = block::BackendOpts {
174174
block_size: be.block_opts.block_size,
@@ -184,8 +184,8 @@ pub fn block_backend(
184184
let meta = std::fs::metadata(&parsed.path)
185185
.with_context(|| {
186186
format!(
187-
"opening {} for block device \"{}\"",
188-
parsed.path, backend_name
187+
"opening {} for block device \"{backend_name}\"",
188+
parsed.path,
189189
)
190190
})
191191
.expect("file device path is valid");

0 commit comments

Comments
 (0)