Fix report_progress when sent file size is less than 1KB 34/320134/1
authorSeung-Woo Kim <sw0312.kim@samsung.com>
Fri, 8 Nov 2024 06:04:17 +0000 (15:04 +0900)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Fri, 8 Nov 2024 06:04:20 +0000 (15:04 +0900)
When sent file is less than 1KB, there is a divide-by zero error.
Check size less than 1KB to fix the issue.

Change-Id: Ie73fa6e9151f635a6420153c025654462238498c
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
lthor.c

diff --git a/lthor.c b/lthor.c
index 38a80d41662cd4964bcbad397fa1e334d8f90f8e..e6b284d49eec371e3eac237d3652db4df369d111 100644 (file)
--- a/lthor.c
+++ b/lthor.c
@@ -185,7 +185,8 @@ static void report_progress(thor_device_handle *th, struct thor_data_src *data,
        char c = progress[(sent_kb/30)%4];
 
        fprintf(stderr, "\x1b[1A\x1b[16C%c sending %6uk/%6uk %3u%% block %-6d",
-               c, sent_kb, total_kb, ((sent_kb*100)/total_kb), chunk_nmb);
+               c, sent_kb, total_kb, total_kb ? ((sent_kb*100)/total_kb) : 0,
+               chunk_nmb);
 
        gettimeofday(&current_time, NULL);