xtask: avoid variables named `cmd` and `child`

reviewable/pr1359/r11
Tamir Duberstein 1 week ago
parent ffa65efb36
commit d16711b2be
No known key found for this signature in database

@ -94,18 +94,18 @@ where
F: FnOnce(&mut Command) -> &mut Command, F: FnOnce(&mut Command) -> &mut Command,
{ {
// Always use rust-lld in case we're cross-compiling. // Always use rust-lld in case we're cross-compiling.
let mut cmd = Command::new("cargo"); let mut cargo = Command::new("cargo");
cmd.args(["build", "--message-format=json"]); cargo.args(["build", "--message-format=json"]);
if let Some(target) = target { if let Some(target) = target {
cmd.args(["--target", target]); cargo.args(["--target", target]);
} }
f(&mut cmd); f(&mut cargo);
let mut child = cmd let mut cargo_child = cargo
.stdout(Stdio::piped()) .stdout(Stdio::piped())
.spawn() .spawn()
.with_context(|| format!("failed to spawn {cmd:?}"))?; .with_context(|| format!("failed to spawn {cargo:?}"))?;
let Child { stdout, .. } = &mut child; let Child { stdout, .. } = &mut cargo_child;
let stdout = stdout.take().unwrap(); let stdout = stdout.take().unwrap();
let stdout = BufReader::new(stdout); let stdout = BufReader::new(stdout);
@ -134,11 +134,11 @@ where
} }
} }
let status = child let status = cargo_child
.wait() .wait()
.with_context(|| format!("failed to wait for {cmd:?}"))?; .with_context(|| format!("failed to wait for {cargo:?}"))?;
if status.code() != Some(0) { if status.code() != Some(0) {
bail!("{cmd:?} failed: {status:?}") bail!("{cargo:?} failed: {status:?}")
} }
Ok(executables) Ok(executables)
} }
@ -323,15 +323,15 @@ pub(crate) fn run(opts: Options) -> Result<()> {
let mut errors = Vec::new(); let mut errors = Vec::new();
for (kernel_image, modules_dir) in image_and_modules { for (kernel_image, modules_dir) in image_and_modules {
// Guess the guest architecture. // Guess the guest architecture.
let mut cmd = Command::new("file"); let mut file = Command::new("file");
let output = cmd let output = file
.arg("--brief") .arg("--brief")
.arg(&kernel_image) .arg(&kernel_image)
.output() .output()
.with_context(|| format!("failed to run {cmd:?}"))?; .with_context(|| format!("failed to run {file:?}"))?;
let Output { status, .. } = &output; let Output { status, .. } = &output;
if status.code() != Some(0) { if status.code() != Some(0) {
bail!("{cmd:?} failed: {output:?}") bail!("{file:?} failed: {output:?}")
} }
let Output { stdout, .. } = output; let Output { stdout, .. } = output;
@ -342,13 +342,13 @@ pub(crate) fn run(opts: Options) -> Result<()> {
// - Linux kernel x86 boot executable bzImage, version 6.1.0-10-cloud-amd64 [..] // - Linux kernel x86 boot executable bzImage, version 6.1.0-10-cloud-amd64 [..]
let stdout = String::from_utf8(stdout) let stdout = String::from_utf8(stdout)
.with_context(|| format!("invalid UTF-8 in {cmd:?} stdout"))?; .with_context(|| format!("invalid UTF-8 in {file:?} stdout"))?;
let (_, stdout) = stdout let (_, stdout) = stdout
.split_once("Linux kernel") .split_once("Linux kernel")
.ok_or_else(|| anyhow!("failed to parse {cmd:?} stdout: {stdout}"))?; .ok_or_else(|| anyhow!("failed to parse {file:?} stdout: {stdout}"))?;
let (guest_arch, _) = stdout let (guest_arch, _) = stdout
.split_once("boot executable") .split_once("boot executable")
.ok_or_else(|| anyhow!("failed to parse {cmd:?} stdout: {stdout}"))?; .ok_or_else(|| anyhow!("failed to parse {file:?} stdout: {stdout}"))?;
let guest_arch = guest_arch.trim(); let guest_arch = guest_arch.trim();
let (guest_arch, machine, cpu, console) = match guest_arch { let (guest_arch, machine, cpu, console) = match guest_arch {

Loading…
Cancel
Save