Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm/add.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-01-09 20:36:42 -0600
committerDan McGee <dan@archlinux.org>2011-01-10 10:49:55 -0600
commitd03b57f459fb9ab9288991a70c4e7297a7c1d150 (patch)
tree6bebc7f9ca3c5414a48dc1b5cfa323fd5c00e372 /lib/libalpm/add.c
parent281a4c0a4f2de217b5d23939fb78b3bbfccc34ca (diff)
Remove need for floating point division in backend
All of these can be done with integer division; the only slightly interesting part is ensuring we round up like before with calling the ceil() function. We can also remove the math library from requirements; now that the only ceil() calls are gone, we don't need this anymore. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/add.c')
-rw-r--r--lib/libalpm/add.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index 2f341eb0..d4c56def 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -477,8 +477,8 @@ static int extract_single_file(struct archive *archive,
return(errors);
}
-static int commit_single_pkg(pmpkg_t *newpkg, size_t pkg_current, size_t pkg_count,
- pmtrans_t *trans, pmdb_t *db)
+static int commit_single_pkg(pmpkg_t *newpkg, size_t pkg_current,
+ size_t pkg_count, pmtrans_t *trans, pmdb_t *db)
{
int i, ret = 0, errors = 0;
char scriptlet[PATH_MAX+1];
@@ -605,31 +605,31 @@ static int commit_single_pkg(pmpkg_t *newpkg, size_t pkg_current, size_t pkg_cou
}
for(i = 0; archive_read_next_header(archive, &entry) == ARCHIVE_OK; i++) {
- double percent;
+ int percent;
if(newpkg->size != 0) {
/* Using compressed size for calculations here, as newpkg->isize is not
* exact when it comes to comparing to the ACTUAL uncompressed size
* (missing metadata sizes) */
int64_t pos = archive_position_compressed(archive);
- percent = (double)pos / (double)newpkg->size;
+ percent = (pos * 100) / newpkg->size;
_alpm_log(PM_LOG_DEBUG, "decompression progress: "
- "%f%% (%"PRId64" / %jd)\n",
- percent*100.0, pos, (intmax_t)newpkg->size);
- if(percent >= 1.0) {
- percent = 1.0;
+ "%d%% (%"PRId64" / %jd)\n",
+ percent, pos, (intmax_t)newpkg->size);
+ if(percent >= 100) {
+ percent = 100;
}
} else {
- percent = 0.0;
+ percent = 0;
}
if(is_upgrade) {
PROGRESS(trans, PM_TRANS_PROGRESS_UPGRADE_START,
- alpm_pkg_get_name(newpkg), (int)(percent * 100), pkg_count,
+ alpm_pkg_get_name(newpkg), percent, pkg_count,
pkg_current);
} else {
PROGRESS(trans, PM_TRANS_PROGRESS_ADD_START,
- alpm_pkg_get_name(newpkg), (int)(percent * 100), pkg_count,
+ alpm_pkg_get_name(newpkg), percent, pkg_count,
pkg_current);
}