Skip to content

Commit

Permalink
Merge pull request #32 from h7x4/handle-rusb-device-descriptor-errors
Browse files Browse the repository at this point in the history
Handle rusb device descriptor errors without panic
  • Loading branch information
jiegec authored Oct 29, 2023
2 parents f567e8d + f5ee550 commit a2701a7
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,32 @@ impl UsbIpServer {
let open_device = match dev.open() {
Ok(dev) => dev,
Err(err) => {
warn!("Impossible to share {:?}: {}", dev, err);
warn!("Impossible to share {:?}: {}, ignoring device", dev, err);
continue;
}
};
let desc = match dev.device_descriptor() {
Ok(desc) => desc,
Err(err) => {
warn!(
"Impossible to get device descriptor for {:?}: {}, ignoring device",
dev, err
);
continue;
}
};
let cfg = match dev.active_config_descriptor() {
Ok(desc) => desc,
Err(err) => {
warn!(
"Impossible to get config descriptor for {:?}: {}, ignoring device",
dev, err
);
continue;
}
};

let handle = Arc::new(Mutex::new(open_device));
let desc = dev.device_descriptor().unwrap();
let cfg = dev.active_config_descriptor().unwrap();
let mut interfaces = vec![];
handle
.lock()
Expand Down

0 comments on commit a2701a7

Please sign in to comment.