Actually fix things

This commit is contained in:
Electric 2023-12-19 17:32:58 +00:00
parent 24306dd9cd
commit e968c27be5
2 changed files with 2 additions and 10 deletions

View file

@ -240,11 +240,10 @@ async fn handler<T: AsyncReadExt + AsyncWriteExt + Unpin>(
let _status = socket.read_u32().await?;
let mut bus_id = [0u8; 32];
socket.read_exact(&mut bus_id).await?;
let bus_id_compare = &bus_id[..bus_id.iter().position(|&x| x == 0).unwrap_or(bus_id.len())];
current_import_device = None;
for device in &server.devices {
let mut expected = device.bus_id.as_bytes().to_vec();
expected.resize(32, 0);
if str_eq(&expected, &bus_id) {
if bus_id_compare == device.bus_id.as_bytes() {
current_import_device = Some(device);
info!("Found device {:?}", device.path);
break;

View file

@ -20,13 +20,6 @@ pub fn verify_descriptor(desc: &[u8]) {
assert_eq!(offset, desc.len());
}
pub fn str_eq(a: &[u8], b: &[u8]) -> bool {
let a_idx = a.iter().position(|&x| x == 0).unwrap_or(a.len());
let b_idx = b.iter().position(|&x| x == 0).unwrap_or(b.len());
a[..a_idx] == b[..b_idx]
}
#[cfg(test)]
pub(crate) mod tests {
use std::{