Skip to content

Commit e844419

Browse files
committed
Avoid divide-by-zero for short transfers
Signed-off-by: Matt Johnston <matt@codeconstruct.com.au>
1 parent 943f633 commit e844419

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/pldm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ async fn pldm_run_file(
285285
.inspect_err(|e| warn!("df_read failed {e}"))?;
286286

287287
let time = start.elapsed().as_millis() as usize;
288-
let kbyte_rate = count / time;
288+
let kbyte_rate = count.checked_div(time).unwrap_or(0);
289289
let mut digest = [0u8; 32];
290290
hash.finish_blocking(hash_ctx, &mut digest);
291291
info!("Transfer complete. total {count} bytes, {time} ms, {kbyte_rate} kB/s, sha256 {}",

0 commit comments

Comments
 (0)