summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAllan McRae <allan@archlinux.org>2010-12-08 15:13:36 +1000
committerDan McGee <dan@archlinux.org>2011-01-07 21:15:46 -0600
commitf966f3a8344cd96bd675c79a5c470c66920b890c (patch)
treec97116b7cc0ca1dca8bed3f050ab18dc28a05585 /lib
parent4bc6ed56aa48784c8caf56c3a6fb1a3c972d221c (diff)
downloadpacman-f966f3a8344cd96bd675c79a5c470c66920b890c.tar.xz
Use size_t for alpm_list sizes
There is a lot of swtiching between size_t and int for alpm_list sizes in the codebase. Start converting these to all be size_t by adjusting the return type of alpm_list_count and fixing all additional warnings given by -Wconversion that are generated by this change. Dan: a few more small changes to ensure things compile, adjusting some printf format string characters to accommodate the larger size on x86_64. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/libalpm/add.c4
-rw-r--r--lib/libalpm/alpm.h2
-rw-r--r--lib/libalpm/alpm_list.c8
-rw-r--r--lib/libalpm/alpm_list.h6
-rw-r--r--lib/libalpm/be_local.c2
-rw-r--r--lib/libalpm/be_sync.c2
-rw-r--r--lib/libalpm/conflict.c4
-rw-r--r--lib/libalpm/diskspace.c6
-rw-r--r--lib/libalpm/remove.c8
-rw-r--r--lib/libalpm/sync.c2
10 files changed, 22 insertions, 22 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index 9fc0381c..2f341eb0 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -477,7 +477,7 @@ static int extract_single_file(struct archive *archive,
return(errors);
}
-static int commit_single_pkg(pmpkg_t *newpkg, int pkg_current, int pkg_count,
+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;
@@ -715,7 +715,7 @@ cleanup:
int _alpm_upgrade_packages(pmtrans_t *trans, pmdb_t *db)
{
- int pkg_count, pkg_current;
+ size_t pkg_count, pkg_current;
int skip_ldconfig = 0, ret = 0;
alpm_list_t *targ;
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index 37210cac..32a2856c 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -405,7 +405,7 @@ typedef void (*alpm_trans_cb_conv)(pmtransconv_t, void *, void *,
void *, int *);
/* Transaction Progress callback */
-typedef void (*alpm_trans_cb_progress)(pmtransprog_t, const char *, int, int, int);
+typedef void (*alpm_trans_cb_progress)(pmtransprog_t, const char *, int, size_t, size_t);
int alpm_trans_get_flags(void);
alpm_list_t * alpm_trans_get_add(void);
diff --git a/lib/libalpm/alpm_list.c b/lib/libalpm/alpm_list.c
index b7b2a89f..3f9525e8 100644
--- a/lib/libalpm/alpm_list.c
+++ b/lib/libalpm/alpm_list.c
@@ -269,7 +269,7 @@ alpm_list_t SYMEXPORT *alpm_list_mmerge(alpm_list_t *left, alpm_list_t *right, a
*
* @return the resultant list
*/
-alpm_list_t SYMEXPORT *alpm_list_msort(alpm_list_t *list, int n, alpm_list_fn_cmp fn)
+alpm_list_t SYMEXPORT *alpm_list_msort(alpm_list_t *list, size_t n, alpm_list_fn_cmp fn)
{
if (n > 1) {
alpm_list_t *left = list;
@@ -511,7 +511,7 @@ inline alpm_list_t SYMEXPORT *alpm_list_first(const alpm_list_t *list)
*
* @return an alpm_list_t node for index `n`
*/
-alpm_list_t SYMEXPORT *alpm_list_nth(const alpm_list_t *list, int n)
+alpm_list_t SYMEXPORT *alpm_list_nth(const alpm_list_t *list, size_t n)
{
const alpm_list_t *i = list;
while(n--) {
@@ -574,9 +574,9 @@ void SYMEXPORT *alpm_list_getdata(const alpm_list_t *node)
*
* @return the number of list items
*/
-int SYMEXPORT alpm_list_count(const alpm_list_t *list)
+size_t SYMEXPORT alpm_list_count(const alpm_list_t *list)
{
- unsigned int i = 0;
+ size_t i = 0;
const alpm_list_t *lp = list;
while(lp) {
++i;
diff --git a/lib/libalpm/alpm_list.h b/lib/libalpm/alpm_list.h
index c52742c9..ee85a5dd 100644
--- a/lib/libalpm/alpm_list.h
+++ b/lib/libalpm/alpm_list.h
@@ -56,7 +56,7 @@ alpm_list_t *alpm_list_add(alpm_list_t *list, void *data);
alpm_list_t *alpm_list_add_sorted(alpm_list_t *list, void *data, alpm_list_fn_cmp fn);
alpm_list_t *alpm_list_join(alpm_list_t *first, alpm_list_t *second);
alpm_list_t *alpm_list_mmerge(alpm_list_t *left, alpm_list_t *right, alpm_list_fn_cmp fn);
-alpm_list_t *alpm_list_msort(alpm_list_t *list, int n, alpm_list_fn_cmp fn);
+alpm_list_t *alpm_list_msort(alpm_list_t *list, size_t n, alpm_list_fn_cmp fn);
alpm_list_t *alpm_list_remove(alpm_list_t *haystack, const void *needle, alpm_list_fn_cmp fn, void **data);
alpm_list_t *alpm_list_remove_str(alpm_list_t *haystack, const char *needle, char **data);
alpm_list_t *alpm_list_remove_dupes(const alpm_list_t *list);
@@ -67,13 +67,13 @@ alpm_list_t *alpm_list_reverse(alpm_list_t *list);
/* item accessors */
alpm_list_t *alpm_list_first(const alpm_list_t *list);
-alpm_list_t *alpm_list_nth(const alpm_list_t *list, int n);
+alpm_list_t *alpm_list_nth(const alpm_list_t *list, size_t n);
alpm_list_t *alpm_list_next(const alpm_list_t *list);
alpm_list_t *alpm_list_last(const alpm_list_t *list);
void *alpm_list_getdata(const alpm_list_t *entry);
/* misc */
-int alpm_list_count(const alpm_list_t *list);
+size_t alpm_list_count(const alpm_list_t *list);
void *alpm_list_find(const alpm_list_t *haystack, const void *needle, alpm_list_fn_cmp fn);
void *alpm_list_find_ptr(const alpm_list_t *haystack, const void *needle);
char *alpm_list_find_str(const alpm_list_t *haystack, const char *needle);
diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c
index 109edf49..d0662d91 100644
--- a/lib/libalpm/be_local.c
+++ b/lib/libalpm/be_local.c
@@ -443,7 +443,7 @@ static int local_db_populate(pmdb_t *db)
}
closedir(dbdir);
- db->pkgcache = alpm_list_msort(db->pkgcache, count, _alpm_pkg_cmp);
+ db->pkgcache = alpm_list_msort(db->pkgcache, (size_t)count, _alpm_pkg_cmp);
return(count);
}
diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c
index 81f3e46e..b11499c4 100644
--- a/lib/libalpm/be_sync.c
+++ b/lib/libalpm/be_sync.c
@@ -212,7 +212,7 @@ static int sync_db_populate(pmdb_t *db)
}
}
- db->pkgcache = alpm_list_msort(db->pkgcache, count, _alpm_pkg_cmp);
+ db->pkgcache = alpm_list_msort(db->pkgcache, (size_t)count, _alpm_pkg_cmp);
archive_read_finish(archive);
return(count);
diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c
index 11422272..0e4d6df2 100644
--- a/lib/libalpm/conflict.c
+++ b/lib/libalpm/conflict.c
@@ -402,8 +402,8 @@ alpm_list_t *_alpm_db_find_fileconflicts(pmdb_t *db, pmtrans_t *trans,
alpm_list_t *upgrade, alpm_list_t *remove)
{
alpm_list_t *i, *j, *conflicts = NULL;
- int numtargs = alpm_list_count(upgrade);
- int current;
+ size_t numtargs = alpm_list_count(upgrade);
+ size_t current;
ALPM_LOG_FUNC;
diff --git a/lib/libalpm/diskspace.c b/lib/libalpm/diskspace.c
index 624cd274..5c9f74e5 100644
--- a/lib/libalpm/diskspace.c
+++ b/lib/libalpm/diskspace.c
@@ -243,11 +243,11 @@ cleanup:
int _alpm_check_diskspace(pmtrans_t *trans, pmdb_t *db_local)
{
alpm_list_t *mount_points, *i;
- int replaces = 0, abort = 0;
+ size_t replaces = 0, current = 0;
+ int abort = 0;
alpm_list_t *targ;
pmpkg_t *pkg;
- int numtargs = alpm_list_count(trans->add);
- int current = 0;
+ size_t numtargs = alpm_list_count(trans->add);
mount_points = mount_point_list();
if(mount_points == NULL) {
diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c
index be349977..bcc8dc45 100644
--- a/lib/libalpm/remove.c
+++ b/lib/libalpm/remove.c
@@ -369,7 +369,7 @@ int _alpm_remove_packages(pmtrans_t *trans, pmdb_t *db)
{
pmpkg_t *info;
alpm_list_t *targ, *lp;
- int pkg_count;
+ size_t pkg_count;
ALPM_LOG_FUNC;
@@ -383,7 +383,7 @@ int _alpm_remove_packages(pmtrans_t *trans, pmdb_t *db)
char scriptlet[PATH_MAX];
info = (pmpkg_t*)targ->data;
const char *pkgname = NULL;
- int targcount = alpm_list_count(targ);
+ size_t targcount = alpm_list_count(targ);
if(handle->trans->state == STATE_INTERRUPTED) {
return(0);
@@ -414,9 +414,9 @@ int _alpm_remove_packages(pmtrans_t *trans, pmdb_t *db)
}
}
- int filenum = alpm_list_count(files);
+ size_t filenum = alpm_list_count(files);
alpm_list_t *newfiles;
- _alpm_log(PM_LOG_DEBUG, "removing %d files\n", filenum);
+ _alpm_log(PM_LOG_DEBUG, "removing %ld files\n", (unsigned long)filenum);
/* init progress bar */
PROGRESS(trans, PM_TRANS_PROGRESS_REMOVE_START, info->name, 0,
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index ef77a8ac..dce1daff 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -822,7 +822,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
{
alpm_list_t *i, *j, *files = NULL;
alpm_list_t *deltas = NULL;
- int replaces = 0;
+ size_t replaces = 0;
int errors = 0;
const char *cachedir = NULL;
int ret = -1;