From 86b136bb592bf576a3da950fee153f6d4f5b9d15 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Thu, 18 Jan 2007 16:52:57 +0000 Subject: Dan McGee * Removed some unnecessary headers and library links * Made things static if possible * Cleaned up makefiles a bit * Fixed some old comments in the code * Fixed some errors the static code checker splint pointed out * Backwards arguments in a memset call in _alpm_db_read (could have been worse) * Other various small fixes Other: * Default to 80 columns when getcols cannot determine display width * Removal of ._install as a valid install file in packages --- src/pacman/downloadprog.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'src/pacman/downloadprog.c') diff --git a/src/pacman/downloadprog.c b/src/pacman/downloadprog.c index 16cfd6c9..29a98124 100644 --- a/src/pacman/downloadprog.c +++ b/src/pacman/downloadprog.c @@ -39,10 +39,10 @@ #include "conf.h" /* progress bar */ -float rate_last; -int xfered_last; -struct timeval last_time; -struct timeval initial_time; +static float rate_last; +static int xfered_last; +static struct timeval last_time; +static struct timeval initial_time; /* pacman options */ extern config_t *config; @@ -52,13 +52,13 @@ extern config_t *config; void log_progress(const char *filename, int xfered, int total) { - static int lasthash = 0, mouth = 0; - int i, hash; - long chomp = 0; + static unsigned int lasthash = 0, mouth = 0; + unsigned int i, hash; + unsigned int chomp = 0; char *fname, *p; unsigned int maxcols = getcols(); unsigned int progresslen = maxcols - 57; - int percent = ((float)xfered) / ((float)total) * 100; + int percent = (int)((float)xfered) / ((float)total) * 100; struct timeval current_time; float rate = 0.0; unsigned int eta_h = 0, eta_m = 0, eta_s = 0; @@ -87,17 +87,17 @@ void log_progress(const char *filename, int xfered, int total) if(xfered == total) { /* compute final values */ - rate = total / (total_timediff * 1024); - eta_s = (int)total_timediff; + rate = (float)total / (total_timediff * 1024); + eta_s = (unsigned int)total_timediff; set_output_padding(0); /* shut off padding */ } else if(timediff < UPDATE_SPEED_SEC) { /* we avoid computing the ETA on too small periods of time, so that results are more significant */ return; } else { - rate = (xfered - xfered_last) / (timediff * 1024); - rate = (rate + 2*rate_last) / 3; - eta_s = (total - xfered) / (rate * 1024); + rate = (float)(xfered - xfered_last) / (timediff * 1024); + rate = (float)(rate + 2*rate_last) / 3; + eta_s = (unsigned int)(total - xfered) / (rate * 1024); } rate_last = rate; @@ -130,11 +130,12 @@ void log_progress(const char *filename, int xfered, int total) rate = 9999.9; } - printf(" %-*s %6dK %#6.1fK/s %02d:%02d:%02d [", FILENAME_TRIM_LEN, fname, xfered/1024, rate, eta_h, eta_m, eta_s); + printf(" %-*s %6dK %#6.1fK/s %02u:%02u:%02u [", FILENAME_TRIM_LEN, fname, + xfered/1024, rate, eta_h, eta_m, eta_s); free(fname); - hash = percent*progresslen/100; + hash = (unsigned int)percent*progresslen/100; for(i = progresslen; i > 0; --i) { if(chomp) { if(i > progresslen - hash) { -- cgit v1.2.3-70-g09d2