We only ever use them as off_t, so do the conversion early and avoid the
need for multiple casts and DOUBLE_EQ.

Signed-off-by: Andrew Gregory <[email protected]>
---
 lib/libalpm/dload.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c
index c5186be..cae4b7c 100644
--- a/lib/libalpm/dload.c
+++ b/lib/libalpm/dload.c
@@ -94,7 +94,7 @@ static int dload_progress_cb(void *file, double dltotal, 
double dlnow,
                double UNUSED ultotal, double UNUSED ulnow)
 {
        struct dload_payload *payload = (struct dload_payload *)file;
-       off_t current_size, total_size;
+       off_t current_size, total_size, xfer = dlnow, total = dltotal;
 
        /* avoid displaying progress bar for redirects with a body */
        if(payload->respcode >= 300) {
@@ -106,7 +106,7 @@ static int dload_progress_cb(void *file, double dltotal, 
double dlnow,
                return 1;
        }
 
-       current_size = payload->initial_size + (off_t)dlnow;
+       current_size = payload->initial_size + xfer;
 
        /* is our filesize still under any set limit? */
        if(payload->max_size && current_size > payload->max_size) {
@@ -119,21 +119,21 @@ static int dload_progress_cb(void *file, double dltotal, 
double dlnow,
                return 0;
        }
 
-       total_size = payload->initial_size + (off_t)dltotal;
+       total_size = payload->initial_size + total;
 
-       if(DOUBLE_EQ(dltotal, 0.0) || payload->prevprogress == total_size) {
+       if(total == 0 || payload->prevprogress == total_size) {
                return 0;
        }
 
        /* initialize the progress bar here to avoid displaying it when
         * a repo is up to date and nothing gets downloaded */
        if(payload->prevprogress == 0) {
-               payload->handle->dlcb(payload->remote_name, 0, (off_t)dltotal);
+               payload->handle->dlcb(payload->remote_name, 0, total);
        }
 
        /* do NOT include initial_size since it wasn't part of the package's
         * download_size (nor included in the total download size callback) */
-       payload->handle->dlcb(payload->remote_name, (off_t)dlnow, 
(off_t)dltotal);
+       payload->handle->dlcb(payload->remote_name, xfer, total);
 
        payload->prevprogress = current_size;
 
-- 
2.2.1

Reply via email to