Skip to content

Commit fd19bda

Browse files
committed
refactor: cleanup unused code and simplify conditional logic
- Remove unused schema generation code from QEMU module - Fix function pointer usage in build module normalization - Simplify conditional logic in U-Boot TFTP server check - Remove unused imports and dead code - Bump version to 0.8.5
1 parent b2266f7 commit fd19bda

File tree

5 files changed

+8
-19
lines changed

5 files changed

+8
-19
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ostool/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0"
77
name = "ostool"
88
readme = "../README.md"
99
repository = "https://github.com/ZR233/ostool"
10-
version = "0.8.4"
10+
version = "0.8.5"
1111

1212
[[bin]]
1313
name = "ostool"

ostool/src/build/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,15 @@ impl AppContext {
8585
.config
8686
.build_dir
8787
.as_ref()
88-
.map(|d| normalize(d))
88+
.map(&normalize)
8989
.transpose()?;
9090

9191
let bin_dir = self
9292
.paths
9393
.config
9494
.bin_dir
9595
.as_ref()
96-
.map(|d| normalize(d))
96+
.map(normalize)
9797
.transpose()?;
9898

9999
let mut builder = CargoBuilder::run(self, config, build_config_path);

ostool/src/run/qemu.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use std::{
88
use anyhow::anyhow;
99
use colored::Colorize;
1010
use crossterm::terminal::disable_raw_mode;
11-
use jkconfig::data::app_data::default_schema_by_init;
1211
use object::Architecture;
1312
use schemars::JsonSchema;
1413
use serde::{Deserialize, Serialize};
@@ -44,15 +43,7 @@ pub async fn run_qemu(ctx: AppContext, args: RunQemuArgs) -> anyhow::Result<()>
4443
None => ctx.paths.manifest.join(".qemu.toml"),
4544
};
4645

47-
let schema_path = default_schema_by_init(&config_path);
48-
49-
let schema = schemars::schema_for!(QemuConfig);
50-
let schema_json = serde_json::to_value(&schema)?;
51-
let schema_content = serde_json::to_string_pretty(&schema_json)?;
52-
fs::write(&schema_path, schema_content).await?;
53-
54-
// 初始化AppData
55-
// let app_data = AppData::new(Some(&config_path), Some(schema_path))?;
46+
info!("Using QEMU config file: {}", config_path.display());
5647

5748
let config = if config_path.exists() {
5849
let config_content = fs::read_to_string(&config_path)

ostool/src/run/uboot.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -307,11 +307,9 @@ impl Runner {
307307
.and_then(|net| net.tftp_dir.as_ref())
308308
.is_some();
309309

310-
if !is_tftp {
311-
if let Some(ip) = ip_string.as_ref() {
312-
info!("TFTP server IP: {}", ip);
313-
tftp::run_tftp_server(&self.ctx)?;
314-
}
310+
if !is_tftp && let Some(ip) = ip_string.as_ref() {
311+
info!("TFTP server IP: {}", ip);
312+
tftp::run_tftp_server(&self.ctx)?;
315313
}
316314

317315
info!(

0 commit comments

Comments
 (0)