Use C99 for loop initializers.

That means that a C99 compiler is now mandatory.
This commit is contained in:
Juan RP
2013-09-15 10:06:49 +02:00
parent 9a9c816552
commit 4057e4961c
32 changed files with 105 additions and 138 deletions

View File

@@ -94,9 +94,7 @@ config_inject_repos(struct xbps_handle *xh)
static int
cb_validate_virtual(cfg_t *cfg, cfg_opt_t *opt)
{
unsigned int i;
for (i = 0; i < cfg_size(cfg, "virtual-package"); i++) {
for (unsigned int i = 0; i < cfg_size(cfg, "virtual-package"); i++) {
cfg_t *sec = cfg_opt_getnsec(opt, i);
if (cfg_getstr(sec, "targets") == 0) {
cfg_error(cfg, "targets must be set for "

View File

@@ -39,7 +39,6 @@ xbps_entry_is_a_conf_file(xbps_dictionary_t propsd,
{
xbps_array_t array;
const char *cffile;
unsigned int i;
assert(xbps_object_type(propsd) == XBPS_TYPE_DICTIONARY);
assert(entry_pname != NULL);
@@ -48,7 +47,7 @@ xbps_entry_is_a_conf_file(xbps_dictionary_t propsd,
if (xbps_array_count(array) == 0)
return false;
for (i = 0; i < xbps_array_count(array); i++) {
for (unsigned int i = 0; i < xbps_array_count(array); i++) {
xbps_array_get_cstring_nocopy(array, i, &cffile);
if (strcmp(cffile, entry_pname) == 0)
return true;

View File

@@ -78,7 +78,6 @@ xbps_find_pkg_obsoletes(struct xbps_handle *xhp,
xbps_array_t instfiles, newfiles, obsoletes;
xbps_object_t obj, obj2;
xbps_string_t oldstr, newstr;
unsigned int i, x;
const char *oldhash;
char *file;
int rv = 0;
@@ -101,7 +100,7 @@ xbps_find_pkg_obsoletes(struct xbps_handle *xhp,
/*
* Iterate over files list from installed package.
*/
for (i = 0; i < xbps_array_count(instfiles); i++) {
for (unsigned int i = 0; i < xbps_array_count(instfiles); i++) {
found = false;
obj = xbps_array_get(instfiles, i);
if (xbps_object_type(obj) != XBPS_TYPE_DICTIONARY) {
@@ -132,7 +131,7 @@ xbps_find_pkg_obsoletes(struct xbps_handle *xhp,
/*
* Check if current file is available in new pkg filelist.
*/
for (x = 0; x < xbps_array_count(newfiles); x++) {
for (unsigned int x = 0; x < xbps_array_count(newfiles); x++) {
obj2 = xbps_array_get(newfiles, x);
newstr = xbps_dictionary_get(obj2, "file");
assert(newstr);

View File

@@ -68,7 +68,7 @@ xbps_find_pkg_orphans(struct xbps_handle *xhp, xbps_array_t orphans_user _unused
xbps_object_iterator_t iter;
const char *curpkgver, *deppkgver, *reqbydep;
bool automatic = false;
unsigned int i, x, j, cnt, reqbycnt;
unsigned int cnt, reqbycnt;
if (xbps_pkgdb_init(xhp) != 0)
return NULL;
@@ -78,7 +78,7 @@ xbps_find_pkg_orphans(struct xbps_handle *xhp, xbps_array_t orphans_user _unused
/*
* Add all packages specified by the client.
*/
for (i = 0; i < xbps_array_count(orphans_user); i++) {
for (unsigned int i = 0; i < xbps_array_count(orphans_user); i++) {
xbps_array_get_cstring_nocopy(orphans_user, i, &curpkgver);
pkgd = xbps_pkgdb_get_pkg(xhp, curpkgver);
if (pkgd == NULL)
@@ -116,17 +116,17 @@ xbps_find_pkg_orphans(struct xbps_handle *xhp, xbps_array_t orphans_user _unused
xbps_object_iterator_release(iter);
find_orphans:
for (i = 0; i < xbps_array_count(array); i++) {
for (unsigned int i = 0; i < xbps_array_count(array); i++) {
pkgd = xbps_array_get(array, i);
rdeps = xbps_dictionary_get(pkgd, "run_depends");
for (x = 0; x < xbps_array_count(rdeps); x++) {
for (unsigned int x = 0; x < xbps_array_count(rdeps); x++) {
cnt = 0;
xbps_array_get_cstring_nocopy(rdeps, x, &deppkgver);
reqby = xbps_pkgdb_get_pkg_revdeps(xhp, deppkgver);
if (reqby == NULL)
continue;
reqbycnt = xbps_array_count(reqby);
for (j = 0; j < reqbycnt; j++) {
for (unsigned int j = 0; j < reqbycnt; j++) {
xbps_array_get_cstring_nocopy(reqby, j, &reqbydep);
if (xbps_find_pkg_in_array(array, reqbydep)) {
cnt++;

View File

@@ -57,14 +57,13 @@ find_pkg_symlink_target(xbps_dictionary_t d, const char *file)
{
xbps_array_t links;
xbps_object_t obj;
unsigned int i;
const char *pkgfile, *tgt = NULL;
char *rfile;
assert(d);
links = xbps_dictionary_get(d, "links");
for (i = 0; i < xbps_array_count(links); i++) {
for (unsigned int i = 0; i < xbps_array_count(links); i++) {
rfile = strchr(file, '.') + 1;
obj = xbps_array_get(links, i);
xbps_dictionary_get_cstring_nocopy(obj, "file", &pkgfile);
@@ -164,8 +163,9 @@ unpack_archive(struct xbps_handle *xhp,
struct stat st;
struct xbps_unpack_cb_data xucd;
struct archive_entry *entry;
size_t i, entry_idx = 0, instbufsiz = 0, rembufsiz = 0;
size_t instbufsiz = 0, rembufsiz = 0;
ssize_t entry_size;
unsigned int entry_idx = 0;
const char *file, *entry_pname, *transact, *tgtlnk;
char *pkgname, *dname, *buf, *buf2, *p, *p2;
int ar_rv, rv, entry_type, flags;
@@ -588,7 +588,7 @@ unpack_archive(struct xbps_handle *xhp,
goto out;
obsoletes = xbps_find_pkg_obsoletes(xhp, old_filesd, filesd);
for (i = 0; i < xbps_array_count(obsoletes); i++) {
for (unsigned int i = 0; i < xbps_array_count(obsoletes); i++) {
obj = xbps_array_get(obsoletes, i);
file = xbps_string_cstring_nocopy(obj);
if (remove(file) == -1) {

View File

@@ -216,7 +216,6 @@ generate_full_revdeps_tree(struct xbps_handle *xhp)
xbps_object_iterator_t iter;
const char *pkgver, *pkgdep, *vpkgname;
char *curpkgname;
unsigned int i;
bool alloc;
if (xhp->pkgdb_revdeps)
@@ -233,7 +232,7 @@ generate_full_revdeps_tree(struct xbps_handle *xhp)
if (!xbps_array_count(rundeps))
continue;
for (i = 0; i < xbps_array_count(rundeps); i++) {
for (unsigned int i = 0; i < xbps_array_count(rundeps); i++) {
alloc = false;
xbps_array_get_cstring_nocopy(rundeps, i, &pkgdep);
curpkgname = xbps_pkgpattern_name(pkgdep);

View File

@@ -58,12 +58,11 @@ array_foreach_thread(void *arg)
xbps_object_t obj, pkgd;
struct thread_data *thd = arg;
const char *key;
unsigned int i;
int rv;
bool loop_done = false;
/* process pkgs from start until end */
for (i = thd->start; i < thd->end; i++) {
for (unsigned int i = thd->start; i < thd->end; i++) {
if (thd->mtx)
pthread_mutex_lock(thd->mtx);
@@ -95,7 +94,7 @@ xbps_array_foreach_cb(struct xbps_handle *xhp,
struct thread_data *thd;
pthread_mutex_t mtx;
unsigned int arraycount, slicecount, pkgcount;
int rv = 0, maxthreads, i;
int rv = 0, maxthreads;
assert(fn != NULL);
@@ -114,7 +113,7 @@ xbps_array_foreach_cb(struct xbps_handle *xhp,
pkgcount = 0;
pthread_mutex_init(&mtx, NULL);
for (i = 0; i < maxthreads; i++) {
for (int i = 0; i < maxthreads; i++) {
thd[i].mtx = &mtx;
thd[i].array = array;
thd[i].dict = dict;
@@ -131,7 +130,7 @@ xbps_array_foreach_cb(struct xbps_handle *xhp,
pkgcount += slicecount;
}
/* wait for all threads */
for (i = 0; i < maxthreads; i++)
for (int i = 0; i < maxthreads; i++)
pthread_join(thd[i].thread, NULL);
pthread_mutex_destroy(&mtx);
@@ -178,7 +177,6 @@ array_replace_dict(xbps_array_t array,
bool bypattern)
{
xbps_object_t obj;
unsigned int i;
const char *curpkgver;
char *curpkgname;
@@ -186,7 +184,7 @@ array_replace_dict(xbps_array_t array,
assert(xbps_object_type(dict) == XBPS_TYPE_DICTIONARY);
assert(str != NULL);
for (i = 0; i < xbps_array_count(array); i++) {
for (unsigned int i = 0; i < xbps_array_count(array); i++) {
obj = xbps_array_get(array, i);
if (obj == NULL)
continue;

View File

@@ -238,7 +238,7 @@ vpkg_user_conf(struct xbps_handle *xhp,
{
const char *vpkgver, *pkg = NULL;
char *vpkgname = NULL, *tmp;
unsigned int i, j, cnt;
unsigned int cnt;
if (xhp->cfg == NULL)
return NULL;
@@ -254,9 +254,9 @@ vpkg_user_conf(struct xbps_handle *xhp,
return NULL;
}
for (i = 0; i < cnt; i++) {
for (unsigned int i = 0; i < cnt; i++) {
cfg_t *sec = cfg_getnsec(xhp->cfg, "virtual-package", i);
for (j = 0; j < cfg_size(sec, "targets"); j++) {
for (unsigned int j = 0; j < cfg_size(sec, "targets"); j++) {
tmp = NULL;
vpkgver = cfg_getnstr(sec, "targets", j);
if (strchr(vpkgver, '_') == NULL) {

View File

@@ -239,7 +239,6 @@ revdeps_match(struct xbps_repo *repo, xbps_dictionary_t tpkgd, const char *str)
xbps_object_t obj;
const char *pkgver, *tpkgver, *arch, *vpkg;
char *buf;
unsigned int i;
iter = xbps_dictionary_iterator(repo->idx);
assert(iter);
@@ -278,7 +277,7 @@ revdeps_match(struct xbps_repo *repo, xbps_dictionary_t tpkgd, const char *str)
* Try to match any virtual package.
*/
provides = xbps_dictionary_get(tpkgd, "provides");
for (i = 0; i < xbps_array_count(provides); i++) {
for (unsigned int i = 0; i < xbps_array_count(provides); i++) {
xbps_array_get_cstring_nocopy(provides, i, &vpkg);
if (strchr(vpkg, '_') == NULL)
buf = xbps_xasprintf("%s_1", vpkg);
@@ -335,7 +334,6 @@ xbps_repo_get_pkg_revdeps(struct xbps_repo *repo, const char *pkg)
xbps_dictionary_t pkgd;
const char *vpkg;
char *buf = NULL;
unsigned int i;
bool match = false;
if (((pkgd = xbps_rpool_get_pkg(repo->xhp, pkg)) == NULL) &&
@@ -347,7 +345,7 @@ xbps_repo_get_pkg_revdeps(struct xbps_repo *repo, const char *pkg)
* If pkg is a virtual pkg let's match it instead of the real pkgver.
*/
if ((vdeps = xbps_dictionary_get(pkgd, "provides"))) {
for (i = 0; i < xbps_array_count(vdeps); i++) {
for (unsigned int i = 0; i < xbps_array_count(vdeps); i++) {
char *vpkgn;
xbps_array_get_cstring_nocopy(vdeps, i, &vpkg);

View File

@@ -160,7 +160,6 @@ find_repo_deps(struct xbps_handle *xhp,
xbps_object_iterator_t iter;
xbps_array_t curpkgrdeps;
pkg_state_t state;
unsigned int x;
const char *reqpkg, *pkgver_q, *reason = NULL;
char *pkgname, *reqpkgname;
int rv = 0;
@@ -179,7 +178,7 @@ find_repo_deps(struct xbps_handle *xhp,
reqpkg = xbps_string_cstring_nocopy(obj);
if (xhp->flags & XBPS_FLAG_DEBUG) {
xbps_dbg_printf(xhp, "");
for (x = 0; x < *depth; x++)
for (unsigned short x = 0; x < *depth; x++)
xbps_dbg_printf_append(xhp, " ");
xbps_dbg_printf_append(xhp, "%s: requires dependency '%s': ",
curpkg != NULL ? curpkg : " ", reqpkg);
@@ -367,7 +366,7 @@ find_repo_deps(struct xbps_handle *xhp,
if (xhp->flags & XBPS_FLAG_DEBUG) {
xbps_dbg_printf(xhp, "");
for (x = 0; x < *depth; x++)
for (unsigned short x = 0; x < *depth; x++)
xbps_dbg_printf_append(xhp, " ");
xbps_dbg_printf_append(xhp,

View File

@@ -52,7 +52,6 @@ xbps_rpool_init(struct xbps_handle *xhp)
{
struct rpool *rp;
const char *repouri;
unsigned int i;
bool foundrepo = false;
int rv = 0;
@@ -63,7 +62,7 @@ xbps_rpool_init(struct xbps_handle *xhp)
else if (xhp->cfg == NULL)
return ENOTSUP;
for (i = 0; i < cfg_size(xhp->cfg, "repositories"); i++) {
for (unsigned int i = 0; i < cfg_size(xhp->cfg, "repositories"); i++) {
rp = malloc(sizeof(struct rpool));
assert(rp);
repouri = cfg_getnstr(xhp->cfg, "repositories", i);
@@ -114,12 +113,11 @@ int
xbps_rpool_sync(struct xbps_handle *xhp, const char *uri)
{
const char *repouri;
unsigned int i;
if (xhp->cfg == NULL)
return ENOTSUP;
for (i = 0; i < cfg_size(xhp->cfg, "repositories"); i++) {
for (unsigned int i = 0; i < cfg_size(xhp->cfg, "repositories"); i++) {
repouri = cfg_getnstr(xhp->cfg, "repositories", i);
/* If argument was set just process that repository */
if (uri && strcmp(repouri, uri))

View File

@@ -80,14 +80,13 @@ find_pkg_revdeps_cb(struct xbps_repo *repo, void *arg, bool *done _unused)
struct rpool_fpkg *rpf = arg;
xbps_array_t revdeps = NULL;
const char *pkgver;
unsigned int i;
revdeps = xbps_repo_get_pkg_revdeps(repo, rpf->pattern);
if (xbps_array_count(revdeps)) {
/* found */
if (rpf->revdeps == NULL)
rpf->revdeps = xbps_array_create();
for (i = 0; i < xbps_array_count(revdeps); i++) {
for (unsigned int i = 0; i < xbps_array_count(revdeps); i++) {
xbps_array_get_cstring_nocopy(revdeps, i, &pkgver);
xbps_array_add_cstring_nocopy(rpf->revdeps, pkgver);
}

View File

@@ -43,11 +43,10 @@ xbps_transaction_package_replace(struct xbps_handle *xhp)
const char *pattern, *pkgver, *curpkgver;
char *buf, *pkgname, *curpkgname;
bool instd_auto, sr;
unsigned int i;
unsorted = xbps_dictionary_get(xhp->transd, "unsorted_deps");
for (i = 0; i < xbps_array_count(unsorted); i++) {
for (unsigned int i = 0; i < xbps_array_count(unsorted); i++) {
obj = xbps_array_get(unsorted, i);
replaces = xbps_dictionary_get(obj, "replaces");
if (replaces == NULL || xbps_array_count(replaces) == 0)

View File

@@ -48,12 +48,11 @@ check_virtual_pkgs(struct xbps_handle *xhp,
xbps_array_t unsorted, provides, rundeps, mdeps;
const char *pkgver, *revpkgver, *pkgpattern;
char *pkgname, *pkgdepname, *vpkgname, *vpkgver, *str;
unsigned int i, x;
bool matched = false;
unsorted = xbps_dictionary_get(xhp->transd, "unsorted_deps");
provides = xbps_dictionary_get(trans_pkgd, "provides");
for (i = 0; i < xbps_array_count(provides); i++) {
for (unsigned int i = 0; i < xbps_array_count(provides); i++) {
char *tmp = NULL;
xbps_array_get_cstring(provides, i, &vpkgver);
@@ -64,7 +63,7 @@ check_virtual_pkgs(struct xbps_handle *xhp,
vpkgname = xbps_pkg_name(vpkgver);
assert(vpkgname);
rundeps = xbps_dictionary_get(rev_pkgd, "run_depends");
for (x = 0; x < xbps_array_count(rundeps); x++) {
for (unsigned int x = 0; x < xbps_array_count(rundeps); x++) {
xbps_array_get_cstring_nocopy(rundeps, x, &pkgpattern);
if (((pkgname = xbps_pkgpattern_name(pkgpattern)) == NULL) &&
((pkgname = xbps_pkg_name(pkgpattern)) == NULL))
@@ -117,11 +116,10 @@ xbps_transaction_revdeps(struct xbps_handle *xhp)
xbps_object_t obj;
const char *pkgver, *curdep, *revpkgver, *curpkgver, *tract;
char *pkgname, *curdepname, *curpkgname, *str;
unsigned int i, j, x;
unsorted = xbps_dictionary_get(xhp->transd, "unsorted_deps");
for (i = 0; i < xbps_array_count(unsorted); i++) {
for (unsigned int i = 0; i < xbps_array_count(unsorted); i++) {
obj = xbps_array_get(unsorted, i);
/*
* Only check packages in transaction being updated.
@@ -153,7 +151,7 @@ xbps_transaction_revdeps(struct xbps_handle *xhp)
/*
* Time to validate revdeps for current pkg.
*/
for (x = 0; x < xbps_array_count(pkgrdeps); x++) {
for (unsigned int x = 0; x < xbps_array_count(pkgrdeps); x++) {
bool found = false;
xbps_array_get_cstring_nocopy(pkgrdeps, x, &curpkgver);
@@ -173,7 +171,7 @@ xbps_transaction_revdeps(struct xbps_handle *xhp)
curpkgname = xbps_pkg_name(pkgver);
assert(curpkgname);
for (j = 0; j < xbps_array_count(rundeps); j++) {
for (unsigned int j = 0; j < xbps_array_count(rundeps); j++) {
xbps_array_get_cstring_nocopy(rundeps, j, &curdep);
if (((curdepname = xbps_pkg_name(curdep)) == NULL) &&
((curdepname = xbps_pkgpattern_name(curdep)) == NULL))

View File

@@ -258,7 +258,7 @@ xbps_transaction_sort(struct xbps_handle *xhp)
xbps_array_t provides, sorted, unsorted, rundeps;
xbps_object_t obj;
struct pkgdep *pd;
unsigned int i, j, ndeps = 0, cnt = 0;
unsigned int ndeps = 0, cnt = 0;
const char *pkgname, *pkgver, *tract, *vpkgdep;
int rv = 0;
bool vpkg_found;
@@ -290,7 +290,7 @@ xbps_transaction_sort(struct xbps_handle *xhp)
* Iterate over the unsorted package dictionaries and sort all
* its package dependencies.
*/
for (i = 0; i < ndeps; i++) {
for (unsigned int i = 0; i < ndeps; i++) {
vpkg_found = false;
obj = xbps_array_get(unsorted, i);
xbps_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname);
@@ -305,7 +305,7 @@ xbps_transaction_sort(struct xbps_handle *xhp)
* if any of them was previously added. If true, don't
* add it into the list again, just order its deps.
*/
for (j = 0; j < xbps_array_count(provides); j++) {
for (unsigned int j = 0; j < xbps_array_count(provides); j++) {
xbps_array_get_cstring_nocopy(provides,
j, &vpkgdep);
pd = pkgdep_find(vpkgdep);