From c9895ab3af9e4a647f74f0a266ea03a87d2b3af4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E7=9D=BF?= Date: Wed, 15 Apr 2026 10:04:11 +0800 Subject: [PATCH 1/2] fix: remove unnecessary reference in cargo_run calls --- ostool-server/src/api/router.rs | 2 +- ostool/src/main.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ostool-server/src/api/router.rs b/ostool-server/src/api/router.rs index 32109db..bc18a84 100644 --- a/ostool-server/src/api/router.rs +++ b/ostool-server/src/api/router.rs @@ -303,7 +303,7 @@ async fn create_dtb( request: Request, ) -> Result<(StatusCode, axum::Json), ApiError> { let headers = request.headers(); - let dtb_name = dtb_name_header(&headers, "X-Dtb-Name")?; + let dtb_name = dtb_name_header(headers, "X-Dtb-Name")?; let body = read_limited_body(request, DTB_UPLOAD_MAX_MIB, "DTB").await?; if body.is_empty() { return Err(ApiError::bad_request("DTB upload body must not be empty")); diff --git a/ostool/src/main.rs b/ostool/src/main.rs index 48108be..e3a2477 100644 --- a/ostool/src/main.rs +++ b/ostool/src/main.rs @@ -224,7 +224,7 @@ async fn try_main() -> Result<()> { dtb_dump, show_output: true, }); - tool.cargo_run(&config, &kind).await?; + tool.cargo_run(config, &kind).await?; } build::config::BuildSystem::Custom(custom_cfg) => { tool.build_with_config(&build_config).await?; @@ -266,7 +266,7 @@ async fn try_main() -> Result<()> { uboot: uboot_config, show_output: true, }); - tool.cargo_run(&config, &kind).await?; + tool.cargo_run(config, &kind).await?; } build::config::BuildSystem::Custom(custom_cfg) => { tool.build_with_config(&build_config).await?; From 435268ab72e4472d67cc6392735672eb081ec243 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E7=9D=BF?= Date: Wed, 15 Apr 2026 10:14:07 +0800 Subject: [PATCH 2/2] refactor: use Box for CargoRunnerKind variants and add constructor methods --- ostool/src/build/mod.rs | 14 ++++++++++++-- ostool/src/main.rs | 4 ++-- ostool/tests/ui/pass_tool_configs.rs | 4 ++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/ostool/src/build/mod.rs b/ostool/src/build/mod.rs index f4aef37..8224878 100644 --- a/ostool/src/build/mod.rs +++ b/ostool/src/build/mod.rs @@ -68,9 +68,19 @@ pub struct CargoUbootRunnerArgs { /// either through QEMU emulation or via U-Boot on real hardware. pub enum CargoRunnerKind { /// Run the built artifact in QEMU emulator. - Qemu(CargoQemuRunnerArgs), + Qemu(Box), /// Run the built artifact on real hardware via U-Boot. - Uboot(CargoUbootRunnerArgs), + Uboot(Box), +} + +impl CargoRunnerKind { + pub fn new_qemu(args: CargoQemuRunnerArgs) -> Self { + Self::Qemu(Box::new(args)) + } + + pub fn new_uboot(args: CargoUbootRunnerArgs) -> Self { + Self::Uboot(Box::new(args)) + } } impl Tool { diff --git a/ostool/src/main.rs b/ostool/src/main.rs index e3a2477..9504e29 100644 --- a/ostool/src/main.rs +++ b/ostool/src/main.rs @@ -218,7 +218,7 @@ async fn try_main() -> Result<()> { ), None => None, }; - let kind = CargoRunnerKind::Qemu(CargoQemuRunnerArgs { + let kind = CargoRunnerKind::new_qemu(CargoQemuRunnerArgs { qemu: qemu_config, debug, dtb_dump, @@ -262,7 +262,7 @@ async fn try_main() -> Result<()> { ), None => None, }; - let kind = CargoRunnerKind::Uboot(CargoUbootRunnerArgs { + let kind = CargoRunnerKind::new_uboot(CargoUbootRunnerArgs { uboot: uboot_config, show_output: true, }); diff --git a/ostool/tests/ui/pass_tool_configs.rs b/ostool/tests/ui/pass_tool_configs.rs index f6973c5..fbe98c0 100644 --- a/ostool/tests/ui/pass_tool_configs.rs +++ b/ostool/tests/ui/pass_tool_configs.rs @@ -18,13 +18,13 @@ fn main() { let _ = RunQemuOptions::default(); let _ = RunUbootOptions::default(); let _ = board::RunBoardOptions::default(); - let _ = build::CargoRunnerKind::Qemu(build::CargoQemuRunnerArgs { + let _ = build::CargoRunnerKind::new_qemu(build::CargoQemuRunnerArgs { qemu: Some(qemu), debug: false, dtb_dump: false, show_output: true, }); - let _ = build::CargoRunnerKind::Uboot(build::CargoUbootRunnerArgs { + let _ = build::CargoRunnerKind::new_uboot(build::CargoUbootRunnerArgs { uboot: Some(uboot), show_output: true, });