Skip to content

Commit 69d52f7

Browse files
committed
adc: hardware: replace .unwraps() around setup done queue with .expect()
While .expect() still means panicking it is considerd a better kind of panicking than .unwrap(). Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
1 parent 7c2be15 commit 69d52f7

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/adc/iio/hardware.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,9 @@ impl IioThread {
362362
Err(e) => {
363363
// Can not fail in practice as the queue is known to be empty
364364
// at this point.
365-
thread_res_tx.try_send(Err(e)).unwrap();
365+
thread_res_tx
366+
.try_send(Err(e))
367+
.expect("Failed to signal ADC setup error due to full queue");
366368
return Ok(());
367369
}
368370
};
@@ -385,7 +387,8 @@ impl IioThread {
385387
if let Some((_, tx)) = signal_ready.take() {
386388
// Can not fail in practice as the queue is only .take()n
387389
// once and thus known to be empty.
388-
tx.try_send(Err(Error::new(e))).unwrap();
390+
tx.try_send(Err(Error::new(e)))
391+
.expect("Failed to signal ADC setup error due to full queue");
389392
}
390393

391394
break;
@@ -415,7 +418,8 @@ impl IioThread {
415418
if let Some((content, tx)) = signal_ready.take() {
416419
// Can not fail in practice as the queue is only .take()n
417420
// once and thus known to be empty.
418-
tx.try_send(Ok(content)).unwrap();
421+
tx.try_send(Ok(content))
422+
.expect("Failed to signal ADC setup completion due to full queue");
419423
}
420424
}
421425

0 commit comments

Comments
 (0)