Code audit: fix unused variables, update docs
- Fix unused variable warnings in profile parsing (|e| -> |_|) - Fix outdated 'freemkv info --share' reference in README (now drive-info)
This commit is contained in:
@@ -103,7 +103,7 @@ All errors are structured with numeric codes. No user-facing English text — ap
|
|||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
Run `freemkv info --share` with the [freemkv CLI](https://github.com/freemkv/freemkv) to contribute your drive's profile.
|
Run `freemkv drive-info --share` with the [freemkv CLI](https://github.com/freemkv/freemkv) to contribute your drive's profile.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -65,12 +65,12 @@ pub struct ProfileMatch {
|
|||||||
|
|
||||||
fn parse_hex4(s: &str) -> Result<[u8; 4]> {
|
fn parse_hex4(s: &str) -> Result<[u8; 4]> {
|
||||||
if s.len() != 8 {
|
if s.len() != 8 {
|
||||||
return Err(Error::ProfileParse { detail: format!("expected 8 hex chars, got {}", s.len()) });
|
return Err(Error::ProfileParse);
|
||||||
}
|
}
|
||||||
let mut out = [0u8; 4];
|
let mut out = [0u8; 4];
|
||||||
for i in 0..4 {
|
for i in 0..4 {
|
||||||
out[i] = u8::from_str_radix(&s[i*2..i*2+2], 16)
|
out[i] = u8::from_str_radix(&s[i*2..i*2+2], 16)
|
||||||
.map_err(|e| Error::ProfileParse { detail: format!("bad hex: {e}") })?;
|
.map_err(|_| Error::ProfileParse)?;
|
||||||
}
|
}
|
||||||
Ok(out)
|
Ok(out)
|
||||||
}
|
}
|
||||||
@@ -102,7 +102,7 @@ pub fn load_bundled() -> Result<ProfilesFile> {
|
|||||||
|
|
||||||
fn load_from_str(data: &str) -> Result<ProfilesFile> {
|
fn load_from_str(data: &str) -> Result<ProfilesFile> {
|
||||||
serde_json::from_str(data)
|
serde_json::from_str(data)
|
||||||
.map_err(|e| Error::ProfileParse { detail: format!("JSON: {e}") })
|
.map_err(|_| Error::ProfileParse)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Find a profile matching a drive's INQUIRY fields.
|
/// Find a profile matching a drive's INQUIRY fields.
|
||||||
|
|||||||
Reference in New Issue
Block a user