Skip to content

Commit

Permalink
fix: avoid panicking in find functions (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
louib committed Feb 11, 2024
1 parent 2db7294 commit 45131d9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl Yubico {
Err(e) => return Err(YubicoError::UsbError(e)),
};
for device in devices.iter() {
let descr = device.device_descriptor().unwrap();
let descr = device.device_descriptor().map_err(|e| YubicoError::UsbError(e))?;
if descr.vendor_id() != YUBICO_VENDOR_ID || !YUBIKEY_DEVICE_ID.contains(&descr.product_id()) {
continue;
}
Expand Down Expand Up @@ -127,7 +127,7 @@ impl Yubico {
Err(e) => return Err(YubicoError::UsbError(e)),
};
for device in devices.iter() {
let descr = device.device_descriptor().unwrap();
let descr = device.device_descriptor().map_err(|e| YubicoError::UsbError(e))?;
if descr.vendor_id() != YUBICO_VENDOR_ID || !YUBIKEY_DEVICE_ID.contains(&descr.product_id()) {
continue;
}
Expand Down Expand Up @@ -161,7 +161,7 @@ impl Yubico {
Err(e) => return Err(YubicoError::UsbError(e)),
};
for device in devices.iter() {
let descr = device.device_descriptor().unwrap();
let descr = device.device_descriptor().map_err(|e| YubicoError::UsbError(e))?;
if descr.vendor_id() != YUBICO_VENDOR_ID || !YUBIKEY_DEVICE_ID.contains(&descr.product_id()) {
continue;
}
Expand Down

0 comments on commit 45131d9

Please sign in to comment.