summaryrefslogtreecommitdiffstats
path: root/lib/libalpm
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-01-07 21:06:06 -0600
committerDan McGee <dan@archlinux.org>2011-01-07 21:15:47 -0600
commit62f5da377920c4e7823c4f8b8fb3673c9c2739e9 (patch)
tree3496e43e7161e765680daac4f0f56efe1dae754b /lib/libalpm
parentf966f3a8344cd96bd675c79a5c470c66920b890c (diff)
downloadpacman-62f5da377920c4e7823c4f8b8fb3673c9c2739e9.tar.xz
Fix some more simple conversion "errors"
None of these warn at the normal "-Wall -Werror" level, but casts do occur that we are fine with. Make them explicit to silence some warnings when using "-Wconversion". Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/conflict.c4
-rw-r--r--lib/libalpm/db.c2
-rw-r--r--lib/libalpm/deps.c5
-rw-r--r--lib/libalpm/diskspace.c20
-rw-r--r--lib/libalpm/dload.c2
-rw-r--r--lib/libalpm/remove.c2
-rw-r--r--lib/libalpm/util.c9
7 files changed, 23 insertions, 21 deletions
diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c
index 0e4d6df2..0eaf4373 100644
--- a/lib/libalpm/conflict.c
+++ b/lib/libalpm/conflict.c
@@ -425,8 +425,8 @@ alpm_list_t *_alpm_db_find_fileconflicts(pmdb_t *db, pmtrans_t *trans,
continue;
}
- double percent = (double)current / numtargs;
- PROGRESS(trans, PM_TRANS_PROGRESS_CONFLICTS_START, "", (percent * 100),
+ double percent = (double)current / (double)numtargs;
+ PROGRESS(trans, PM_TRANS_PROGRESS_CONFLICTS_START, "", (int)(percent * 100),
numtargs, current);
/* CHECK 1: check every target against every target */
_alpm_log(PM_LOG_DEBUG, "searching for file conflicts: %s\n",
diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c
index c1be7ec7..bf9a70d4 100644
--- a/lib/libalpm/db.c
+++ b/lib/libalpm/db.c
@@ -172,7 +172,7 @@ int SYMEXPORT alpm_db_setserver(pmdb_t *db, const char *url)
alpm_list_t *i;
int found = 0;
char *newurl;
- int len = 0;
+ size_t len = 0;
ALPM_LOG_FUNC;
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index 1bf2e87f..3d4b1df4 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -350,8 +350,9 @@ int _alpm_depcmp(pmpkg_t *pkg, pmdepend_t *dep)
/* This is a bit tricker than the old code for performance reasons. To
* prevent the need to copy and duplicate strings, strncmp only the name
* portion if they are the same length, since there is a version and
- * operator in play here. */
- size_t namelen = provver - provision;
+ * operator in play here. Cast is to silence sign conversion warning;
+ * we know provver >= provision if we are here. */
+ size_t namelen = (size_t)(provver - provision);
provver += 1;
satisfy = (strlen(dep->name) == namelen
&& strncmp(provision, dep->name, namelen) == 0
diff --git a/lib/libalpm/diskspace.c b/lib/libalpm/diskspace.c
index 5c9f74e5..87dca84f 100644
--- a/lib/libalpm/diskspace.c
+++ b/lib/libalpm/diskspace.c
@@ -178,7 +178,7 @@ static int calculate_removed_size(const alpm_list_t *mount_points,
}
data = mp->data;
- data->blocks_needed -= ceil((double)(st.st_size) /
+ data->blocks_needed -= (long)ceil((double)(st.st_size) /
(double)(data->fsp.f_bsize));
data->used = 1;
}
@@ -229,7 +229,7 @@ static int calculate_installed_size(const alpm_list_t *mount_points,
}
data = mp->data;
- data->blocks_needed += ceil((double)(archive_entry_size(entry)) /
+ data->blocks_needed += (long)ceil((double)(archive_entry_size(entry)) /
(double)(data->fsp.f_bsize));
data->used = 1;
}
@@ -243,12 +243,12 @@ cleanup:
int _alpm_check_diskspace(pmtrans_t *trans, pmdb_t *db_local)
{
alpm_list_t *mount_points, *i;
- size_t replaces = 0, current = 0;
+ size_t replaces = 0, current = 0, numtargs;
int abort = 0;
alpm_list_t *targ;
pmpkg_t *pkg;
- size_t numtargs = alpm_list_count(trans->add);
+ numtargs = alpm_list_count(trans->add);
mount_points = mount_point_list();
if(mount_points == NULL) {
_alpm_log(PM_LOG_ERROR, _("could not determine filesystem mount points"));
@@ -259,8 +259,8 @@ int _alpm_check_diskspace(pmtrans_t *trans, pmdb_t *db_local)
if(replaces) {
numtargs += replaces;
for(targ = trans->remove; targ; targ = targ->next, current++) {
- double percent = (double)current / numtargs;
- PROGRESS(trans, PM_TRANS_PROGRESS_DISKSPACE_START, "", (percent * 100),
+ double percent = (double)current / (double)numtargs;
+ PROGRESS(trans, PM_TRANS_PROGRESS_DISKSPACE_START, "", (int)(percent * 100),
numtargs, current);
pkg = targ->data;
@@ -269,8 +269,8 @@ int _alpm_check_diskspace(pmtrans_t *trans, pmdb_t *db_local)
}
for(targ = trans->add; targ; targ = targ->next, current++) {
- double percent = (double)current / numtargs;
- PROGRESS(trans, PM_TRANS_PROGRESS_DISKSPACE_START, "", (percent * 100),
+ double percent = (double)current / (double)numtargs;
+ PROGRESS(trans, PM_TRANS_PROGRESS_DISKSPACE_START, "", (int)(percent * 100),
numtargs, current);
pkg = targ->data;
@@ -295,8 +295,8 @@ int _alpm_check_diskspace(pmtrans_t *trans, pmdb_t *db_local)
alpm_mountpoint_t *data = i->data;
if(data->used == 1) {
/* cushion is roughly min(5% capacity, 20MiB) */
- long fivepc = (data->fsp.f_blocks / 20) + 1;
- long twentymb = (20 * 1024 * 1024 / data->fsp.f_bsize) + 1;
+ long fivepc = ((long)data->fsp.f_blocks / 20) + 1;
+ long twentymb = (20 * 1024 * 1024 / (long)data->fsp.f_bsize) + 1;
long cushion = fivepc < twentymb ? fivepc : twentymb;
_alpm_log(PM_LOG_DEBUG, "partition %s, needed %ld, cushion %ld, free %ld\n",
diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c
index e4b946d3..cb6d000c 100644
--- a/lib/libalpm/dload.c
+++ b/lib/libalpm/dload.c
@@ -247,7 +247,7 @@ static int download_internal(const char *url, const char *localpath,
while((nread = fetchIO_read(dlf, buffer, PM_DLBUF_LEN)) > 0) {
check_stop();
size_t nwritten = 0;
- nwritten = fwrite(buffer, 1, nread, localf);
+ nwritten = fwrite(buffer, 1, (size_t)nread, localf);
if((nwritten != (size_t)nread) || ferror(localf)) {
pm_errno = PM_ERR_RETRIEVE;
_alpm_log(PM_LOG_ERROR, _("error writing to file '%s': %s\n"),
diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c
index bcc8dc45..e1249fd6 100644
--- a/lib/libalpm/remove.c
+++ b/lib/libalpm/remove.c
@@ -431,7 +431,7 @@ int _alpm_remove_packages(pmtrans_t *trans, pmdb_t *db)
/* update progress bar after each file */
percent = (double)position / (double)filenum;
PROGRESS(trans, PM_TRANS_PROGRESS_REMOVE_START, info->name,
- (double)(percent * 100), pkg_count,
+ (int)(percent * 100), pkg_count,
(pkg_count - targcount + 1));
position++;
}
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index 5f7512fb..2eee5e4a 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -668,7 +668,7 @@ int _alpm_lstat(const char *path, struct stat *buf)
{
int ret;
char *newpath = strdup(path);
- int len = strlen(newpath);
+ size_t len = strlen(newpath);
/* strip the trailing slash if one exists */
if(len != 0 && newpath[len - 1] == '/') {
@@ -815,7 +815,8 @@ int _alpm_archive_fgets(struct archive *a, struct archive_read_buffer *b)
b->line_size = b->block_size + 1;
b->line_offset = b->line;
} else {
- size_t needed = (b->line_offset - b->line) + (i - b->block_offset) + 1;
+ size_t needed = (size_t)((b->line_offset - b->line)
+ + (i - b->block_offset) + 1);
if(needed > b->max_line_size) {
RET_ERR(PM_ERR_MEMORY, -1);
}
@@ -832,7 +833,7 @@ int _alpm_archive_fgets(struct archive *a, struct archive_read_buffer *b)
}
if(done) {
- size_t len = i - b->block_offset;
+ size_t len = (size_t)(i - b->block_offset);
memcpy(b->line_offset, b->block_offset, len);
b->line_offset[len] = '\0';
b->block_offset = ++i;
@@ -840,7 +841,7 @@ int _alpm_archive_fgets(struct archive *a, struct archive_read_buffer *b)
return(ARCHIVE_OK);
} else {
/* we've looked through the whole block but no newline, copy it */
- size_t len = b->block + b->block_size - b->block_offset;
+ size_t len = (size_t)(b->block + b->block_size - b->block_offset);
memcpy(b->line_offset, b->block_offset, len);
b->line_offset += len;
b->block_offset = i;