Skip to content

Commit bf26efb

Browse files
WhatAmISupposedToPutHereslp
authored andcommitted
Add uninlined_format_args lint and fix where relevant
I keep forgetting this syntax exists, and other maintainers seem to be fond of it. Signed-off-by: Sasha Finkelstein <[email protected]>
1 parent 00ef86e commit bf26efb

8 files changed

Lines changed: 20 additions & 20 deletions

File tree

crates/muvm/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,6 @@ path = "src/bin/muvm.rs"
3535
[[bin]]
3636
name = "muvm-guest"
3737
path = "src/guest/bin/muvm-guest.rs"
38+
39+
[lints.clippy]
40+
uninlined_format_args = "warn"

crates/muvm/src/bin/muvm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ fn main() -> Result<ExitCode> {
314314
std::fs::create_dir_all(&socket_dir)?;
315315
// Dynamic ports: Applications may listen on these sockets as neeeded.
316316
for port in DYNAMIC_PORT_RANGE {
317-
let socket_path = socket_dir.join(format!("port-{}", port));
317+
let socket_path = socket_dir.join(format!("port-{port}"));
318318
let socket_path = CString::new(
319319
socket_path
320320
.to_str()
@@ -333,7 +333,7 @@ fn main() -> Result<ExitCode> {
333333
// Forward the native X11 display into the guest as a socket
334334
if let Ok(x11_display) = env::var("DISPLAY") {
335335
if let Some(x11_display) = x11_display.strip_prefix(':') {
336-
let socket_path = Path::new("/tmp/.X11-unix/").join(format!("X{}", x11_display));
336+
let socket_path = Path::new("/tmp/.X11-unix/").join(format!("X{x11_display}"));
337337
if socket_path.exists() {
338338
let socket_path = CString::new(
339339
socket_path

crates/muvm/src/guest/hidpipe.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ pub fn start_hidpipe(user_id: u32) {
265265
dev.unwrap().ff_erase_end(&ff_ers).unwrap();
266266
}
267267
},
268-
m => panic!("Unknown message {}", m),
268+
m => panic!("Unknown message {m}"),
269269
}
270270
} else if let Some(id) = fd_to_id.get(&fd) {
271271
let uinput = inputs_by_id.get(id).unwrap();

crates/muvm/src/guest/mount.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,7 @@ pub fn mount_filesystems(merged_rootfs: bool) -> Result<()> {
316316
// Do this last so it can pick up all the submounts made above.
317317
if let Err(e) = mount_fex_rootfs(merged_rootfs) {
318318
println!(
319-
"Failed to mount FEX rootfs, carrying on without. Error: {}",
320-
e
319+
"Failed to mount FEX rootfs, carrying on without. Error: {e}"
321320
);
322321
}
323322

crates/muvm/src/guest/server.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub async fn server_main(
1616
command: PathBuf,
1717
command_args: Vec<String>,
1818
) -> Result<()> {
19-
let listener = TcpListener::bind(format!("0.0.0.0:{}", server_port)).await?;
19+
let listener = TcpListener::bind(format!("0.0.0.0:{server_port}")).await?;
2020
let (state_tx, state_rx) = watch::channel(State::new());
2121

2222
let mut worker_handle = tokio::spawn(async move {
@@ -50,8 +50,7 @@ pub async fn server_main(
5050
if !status.success() {
5151
if let Some(code) = status.code() {
5252
eprintln!(
53-
"{:?} process exited with status code: {code}",
54-
command
53+
"{command:?} process exited with status code: {code}"
5554
);
5655
} else {
5756
eprintln!(
@@ -66,8 +65,7 @@ pub async fn server_main(
6665
},
6766
Err(err) => {
6867
eprintln!(
69-
"Failed to execute {:?} as child process: {err}",
70-
command
68+
"Failed to execute {command:?} as child process: {err}"
7169
);
7270
},
7371
}

crates/muvm/src/guest/socket.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ where
2828
.to_str()
2929
.expect("socket_path should not contain invalid UTF-8")
3030
))
31-
.arg(format!("VSOCK-CONNECT:2:{}", port))
31+
.arg(format!("VSOCK-CONNECT:2:{port}"))
3232
.stdin(Stdio::null())
3333
.stdout(stdout)
3434
.stderr(stderr)

crates/muvm/src/guest/x11.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ where
2424
env::set_var("XSHMFENCE_NO_MEMFD", "1");
2525

2626
if let Ok(xauthority) = std::env::var("XAUTHORITY") {
27-
let src_path = format!("/run/muvm-host/{}", xauthority);
27+
let src_path = format!("/run/muvm-host/{xauthority}");
2828
let mut rdr = File::open(src_path)?;
2929

3030
let dst_path = run_path.as_ref().join("xauth");

crates/muvm/src/guest/x11bridge.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,7 @@ impl Client {
10861086

10871087
fn ptrace_all_threads(pid: Pid) -> Result<Vec<PtracedPid>> {
10881088
let mut tids = Vec::new();
1089-
for entry in fs::read_dir(format!("/proc/{}/task", pid))? {
1089+
for entry in fs::read_dir(format!("/proc/{pid}/task"))? {
10901090
let entry = match entry {
10911091
Err(_) => continue,
10921092
Ok(a) => a,
@@ -1104,7 +1104,7 @@ impl Client {
11041104
if tid == pid {
11051105
return Err(e.into());
11061106
}
1107-
eprintln!("ptrace::attach({}, ...) failed (continuing)", pid);
1107+
eprintln!("ptrace::attach({pid}, ...) failed (continuing)");
11081108
continue;
11091109
}
11101110
let ptid = PtracedPid(tid);
@@ -1129,7 +1129,7 @@ impl Client {
11291129
// TODO: match st_dev too to avoid false positives
11301130
let my_ino = fstat(my_fd)?.st_ino;
11311131
let mut fds_to_replace = Vec::new();
1132-
for entry in fs::read_dir(format!("/proc/{}/fd", pid))? {
1132+
for entry in fs::read_dir(format!("/proc/{pid}/fd"))? {
11331133
let entry = entry?;
11341134
if let Ok(file) = File::options().open(entry.path()) {
11351135
if fstat(file.as_raw_fd())?.st_ino == my_ino {
@@ -1138,7 +1138,7 @@ impl Client {
11381138
}
11391139
}
11401140
let mut pages_to_replace = Vec::new();
1141-
for line in read_to_string(format!("/proc/{}/maps", pid))?.lines() {
1141+
for line in read_to_string(format!("/proc/{pid}/maps"))?.lines() {
11421142
let f: Vec<&str> = line.split_whitespace().collect();
11431143
let ino: u64 = f[4].parse()?;
11441144
if ino == my_ino {
@@ -1290,7 +1290,7 @@ impl Client {
12901290
self.process_futex_signal(recv)?;
12911291
},
12921292
a => {
1293-
eprintln!("Received unknown cross-domain command {}", a);
1293+
eprintln!("Received unknown cross-domain command {a}");
12941294
},
12951295
};
12961296
self.gpu_ctx.poll_cmd()?;
@@ -1445,7 +1445,7 @@ fn find_vdso(pid: Option<Pid>) -> Result<(usize, usize), Errno> {
14451445
}
14461446

14471447
pub fn start_x11bridge(display: u32) {
1448-
let sock_path = format!("/tmp/.X11-unix/X{}", display);
1448+
let sock_path = format!("/tmp/.X11-unix/X{display}");
14491449

14501450
// Look for a syscall instruction in the vDSO. We assume all processes map
14511451
// the same vDSO (which should be true if they are running under the same
@@ -1524,7 +1524,7 @@ pub fn start_x11bridge(display: u32) {
15241524
.borrow_mut()
15251525
.process_socket(events)
15261526
.map_err(|e| {
1527-
eprintln!("Client {} disconnected with error: {:?}", fd, e);
1527+
eprintln!("Client {fd} disconnected with error: {e:?}");
15281528
e
15291529
})
15301530
.unwrap_or(ClientEvent::Close);
@@ -1569,7 +1569,7 @@ pub fn start_x11bridge(display: u32) {
15691569
.borrow_mut()
15701570
.process_vgpu()
15711571
.map_err(|e| {
1572-
eprintln!("Server {} disconnected with error: {:?}", fd, e);
1572+
eprintln!("Server {fd} disconnected with error: {e:?}");
15731573
e
15741574
})
15751575
.unwrap_or(true);

0 commit comments

Comments
 (0)