From: Seung-Woo Kim Date: Mon, 10 Apr 2017 07:38:43 +0000 (+0900) Subject: Fix progress report for larger than 2GB file X-Git-Tag: submit/trunk/20190927.044709~17 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e522496ddfc70b16e05fe1c609eba47c81b6c990;p=tools%2Flthor.git Fix progress report for larger than 2GB file Currently, progress report function has 32bit signed value for its send and left parameters, so it causes negative value progress. This fixes the parameters as unsigned 32bit type to report properly. Change-Id: I1d291c1507170c57b025d4fbd91098b48a97cdd0 Signed-off-by: Seung-Woo Kim --- diff --git a/libthor/thor.h b/libthor/thor.h index 130f505..213a8b2 100644 --- a/libthor/thor.h +++ b/libthor/thor.h @@ -58,8 +58,8 @@ enum thor_data_src_format { typedef void (*thor_progress_cb)(thor_device_handle *th, struct thor_data_src *data, - int sent, int left, int chunk_nmb, - void *user_data); + unsigned int sent, unsigned int left, + int chunk_nmb, void *user_data); typedef void (*thor_next_entry_cb)(thor_device_handle *th, struct thor_data_src *data, diff --git a/lthor.c b/lthor.c index db42902..268e807 100644 --- a/lthor.c +++ b/lthor.c @@ -174,19 +174,20 @@ static double timediff(struct timeval *atv, struct timeval *btv) } static void report_progress(thor_device_handle *th, struct thor_data_src *data, - int sent, int left, int chunk_nmb, void *user_data) + unsigned int sent, unsigned int left, int chunk_nmb, + void *user_data) { struct time_data *tdata = user_data; struct timeval *start_time = &tdata->start_time; struct timeval *last_time = &tdata->last_time; struct timeval current_time; double diff; - int sent_kb = sent/KB; - int total_kb = (sent + left)/KB; + unsigned int sent_kb = sent/KB; + unsigned int total_kb = (sent + left)/KB; char progress [4] = { '-', '\\', '|', '/' }; char c = progress[(sent_kb/30)%4]; - fprintf(stderr, "\x1b[1A\x1b[16C%c sending %6dk/%6dk %3d%% block %-6d", + 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); gettimeofday(¤t_time, NULL);