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

2
NEWS
View File

@ -1,5 +1,7 @@
xbps-0.26 (???): xbps-0.26 (???):
* A C99 compiler is now required due to the use of for loop initializers.
* Fixed #14 from github: "Removing recursively does not respect manual installation * Fixed #14 from github: "Removing recursively does not respect manual installation
mode for dependencies". See https://github.com/xtraeme/xbps/issues/14 mode for dependencies". See https://github.com/xtraeme/xbps/issues/14
for more information. for more information.

View File

@ -163,7 +163,6 @@ entry_is_conf_file(const char *file)
{ {
xbps_array_t a; xbps_array_t a;
const char *curfile; const char *curfile;
unsigned int i;
assert(file); assert(file);
@ -171,7 +170,7 @@ entry_is_conf_file(const char *file)
if (a == NULL || xbps_array_count(a) == 0) if (a == NULL || xbps_array_count(a) == 0)
return false; return false;
for (i = 0; i < xbps_array_count(a); i++) { for (unsigned int i = 0; i < xbps_array_count(a); i++) {
xbps_array_get_cstring_nocopy(a, i, &curfile); xbps_array_get_cstring_nocopy(a, i, &curfile);
if (strcmp(file, curfile) == 0) if (strcmp(file, curfile) == 0)
return true; return true;

View File

@ -144,7 +144,6 @@ generate_conf_file(void)
{ {
xbps_dictionary_t d, d2; xbps_dictionary_t d, d2;
struct defprops *dfp; struct defprops *dfp;
size_t i;
const char *outfile = "xbps-dgraph.conf"; const char *outfile = "xbps-dgraph.conf";
d = xbps_dictionary_create(); d = xbps_dictionary_create();
@ -165,7 +164,7 @@ generate_conf_file(void)
xbps_dictionary_set(d, "node-sub", d2); xbps_dictionary_set(d, "node-sub", d2);
xbps_object_release(d2); xbps_object_release(d2);
for (i = 0; i < __arraycount(dfprops); i++) { for (unsigned int i = 0; i < __arraycount(dfprops); i++) {
dfp = &dfprops[i]; dfp = &dfprops[i];
d2 = xbps_dictionary_get(d, dfp->sect); d2 = xbps_dictionary_get(d, dfp->sect);
xbps_dictionary_set_cstring_nocopy(d2, dfp->prop, dfp->val); xbps_dictionary_set_cstring_nocopy(d2, dfp->prop, dfp->val);
@ -187,14 +186,13 @@ write_conf_property_on_stream(FILE *f,
xbps_array_t allkeys, allkeys2; xbps_array_t allkeys, allkeys2;
xbps_dictionary_keysym_t dksym, dksym2; xbps_dictionary_keysym_t dksym, dksym2;
xbps_object_t keyobj, keyobj2; xbps_object_t keyobj, keyobj2;
size_t i, x;
const char *cf_val, *keyname, *keyname2; const char *cf_val, *keyname, *keyname2;
/* /*
* Iterate over the main dictionary. * Iterate over the main dictionary.
*/ */
allkeys = xbps_dictionary_all_keys(confd); allkeys = xbps_dictionary_all_keys(confd);
for (i = 0; i < xbps_array_count(allkeys); i++) { for (unsigned int i = 0; i < xbps_array_count(allkeys); i++) {
dksym = xbps_array_get(allkeys, i); dksym = xbps_array_get(allkeys, i);
keyname = xbps_dictionary_keysym_cstring_nocopy(dksym); keyname = xbps_dictionary_keysym_cstring_nocopy(dksym);
keyobj = xbps_dictionary_get_keysym(confd, dksym); keyobj = xbps_dictionary_get_keysym(confd, dksym);
@ -205,7 +203,7 @@ write_conf_property_on_stream(FILE *f,
* Iterate over the dictionary sections [edge/graph/node]. * Iterate over the dictionary sections [edge/graph/node].
*/ */
allkeys2 = xbps_dictionary_all_keys(keyobj); allkeys2 = xbps_dictionary_all_keys(keyobj);
for (x = 0; x < xbps_array_count(allkeys2); x++) { for (unsigned int x = 0; x < xbps_array_count(allkeys2); x++) {
dksym2 = xbps_array_get(allkeys2, x); dksym2 = xbps_array_get(allkeys2, x);
keyname2 = xbps_dictionary_keysym_cstring_nocopy(dksym2); keyname2 = xbps_dictionary_keysym_cstring_nocopy(dksym2);
keyobj2 = xbps_dictionary_get_keysym(keyobj, dksym2); keyobj2 = xbps_dictionary_get_keysym(keyobj, dksym2);
@ -244,11 +242,10 @@ parse_array_in_pkg_dictionary(FILE *f, xbps_dictionary_t plistd,
{ {
xbps_dictionary_keysym_t dksym; xbps_dictionary_keysym_t dksym;
xbps_object_t keyobj, sub_keyobj; xbps_object_t keyobj, sub_keyobj;
unsigned int i, x;
const char *tmpkeyname, *cfprop, *optnodetmp; const char *tmpkeyname, *cfprop, *optnodetmp;
char *optnode, *keyname; char *optnode, *keyname;
for (i = 0; i < xbps_array_count(allkeys); i++) { for (unsigned int i = 0; i < xbps_array_count(allkeys); i++) {
dksym = xbps_array_get(allkeys, i); dksym = xbps_array_get(allkeys, i);
tmpkeyname = xbps_dictionary_keysym_cstring_nocopy(dksym); tmpkeyname = xbps_dictionary_keysym_cstring_nocopy(dksym);
/* Ignore these objects */ /* Ignore these objects */
@ -268,7 +265,7 @@ parse_array_in_pkg_dictionary(FILE *f, xbps_dictionary_t plistd,
xbps_dictionary_get_cstring_nocopy(sub_confd, "opt-style", &cfprop); xbps_dictionary_get_cstring_nocopy(sub_confd, "opt-style", &cfprop);
/* Check if object is optional and fill it in */ /* Check if object is optional and fill it in */
for (x = 0; x < __arraycount(optional_objs); x++) { for (unsigned int x = 0; x < __arraycount(optional_objs); x++) {
if (strcmp(keyname, optional_objs[x]) == 0) { if (strcmp(keyname, optional_objs[x]) == 0) {
optnode = xbps_xasprintf("[style=\"%s\"", optnode = xbps_xasprintf("[style=\"%s\"",
cfprop); cfprop);
@ -286,7 +283,7 @@ parse_array_in_pkg_dictionary(FILE *f, xbps_dictionary_t plistd,
fprintf(f, " %s %s];\n", keyname, fprintf(f, " %s %s];\n", keyname,
optnodetmp); optnodetmp);
for (x = 0; x < xbps_array_count(keyobj); x++) { for (unsigned int x = 0; x < xbps_array_count(keyobj); x++) {
sub_keyobj = xbps_array_get(keyobj, x); sub_keyobj = xbps_array_get(keyobj, x);
if (xbps_object_type(sub_keyobj) == XBPS_TYPE_STRING) { if (xbps_object_type(sub_keyobj) == XBPS_TYPE_STRING) {
/* /*

View File

@ -48,10 +48,9 @@ struct transaction {
static void static void
show_missing_deps(xbps_array_t a) show_missing_deps(xbps_array_t a)
{ {
unsigned int i;
const char *str; const char *str;
for (i = 0; i < xbps_array_count(a); i++) { for (unsigned int i = 0; i < xbps_array_count(a); i++) {
xbps_array_get_cstring_nocopy(a, i, &str); xbps_array_get_cstring_nocopy(a, i, &str);
fprintf(stderr, "%s\n", str); fprintf(stderr, "%s\n", str);
} }
@ -60,10 +59,9 @@ show_missing_deps(xbps_array_t a)
static void static void
show_conflicts(xbps_array_t a) show_conflicts(xbps_array_t a)
{ {
unsigned int i;
const char *str; const char *str;
for (i = 0; i < xbps_array_count(a); i++) { for (unsigned int i = 0; i < xbps_array_count(a); i++) {
xbps_array_get_cstring_nocopy(a, i, &str); xbps_array_get_cstring_nocopy(a, i, &str);
fprintf(stderr, "%s\n", str); fprintf(stderr, "%s\n", str);
} }

View File

@ -49,7 +49,6 @@ check_pkg_rundeps(struct xbps_handle *xhp, const char *pkgname, void *arg)
{ {
xbps_dictionary_t pkg_propsd = arg; xbps_dictionary_t pkg_propsd = arg;
xbps_array_t array; xbps_array_t array;
unsigned int i;
const char *reqpkg; const char *reqpkg;
bool test_broken = false; bool test_broken = false;
@ -57,7 +56,7 @@ check_pkg_rundeps(struct xbps_handle *xhp, const char *pkgname, void *arg)
return 0; return 0;
array = xbps_dictionary_get(pkg_propsd, "run_depends"); array = xbps_dictionary_get(pkg_propsd, "run_depends");
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, &reqpkg); xbps_array_get_cstring_nocopy(array, i, &reqpkg);
if (xbps_pkg_is_installed(xhp, reqpkg) <= 0) { if (xbps_pkg_is_installed(xhp, reqpkg) <= 0) {
xbps_error_printf("%s: dependency not satisfied: %s\n", xbps_error_printf("%s: dependency not satisfied: %s\n",

View File

@ -77,7 +77,6 @@ check_pkg_symlinks(struct xbps_handle *xhp, const char *pkgname, void *arg)
xbps_array_t array; xbps_array_t array;
xbps_object_t obj; xbps_object_t obj;
xbps_dictionary_t filesd = arg; xbps_dictionary_t filesd = arg;
unsigned int i;
const char *file, *tgt = NULL; const char *file, *tgt = NULL;
char *path, *p, *buf, *buf2, *lnk, *dname, *tgt_path; char *path, *p, *buf, *buf2, *lnk, *dname, *tgt_path;
int rv; int rv;
@ -87,7 +86,7 @@ check_pkg_symlinks(struct xbps_handle *xhp, const char *pkgname, void *arg)
if (array == NULL) if (array == NULL)
return false; return false;
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); obj = xbps_array_get(array, i);
if (!xbps_dictionary_get_cstring_nocopy(obj, "target", &tgt)) { if (!xbps_dictionary_get_cstring_nocopy(obj, "target", &tgt)) {
xbps_warn_printf("%s: `%s' symlink with " xbps_warn_printf("%s: `%s' symlink with "

View File

@ -46,7 +46,6 @@ pkgdb_format_021(struct xbps_handle *xhp, const char *plist_new)
{ {
xbps_array_t array, rdeps; xbps_array_t array, rdeps;
xbps_dictionary_t pkgdb, pkgd; xbps_dictionary_t pkgdb, pkgd;
unsigned int i;
char *pkgname, *plist; char *pkgname, *plist;
plist = xbps_xasprintf("%s/pkgdb.plist", xhp->metadir); plist = xbps_xasprintf("%s/pkgdb.plist", xhp->metadir);
@ -71,7 +70,7 @@ pkgdb_format_021(struct xbps_handle *xhp, const char *plist_new)
pkgdb = xbps_dictionary_create(); pkgdb = xbps_dictionary_create();
assert(pkgdb); assert(pkgdb);
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); pkgd = xbps_array_get(array, i);
xbps_dictionary_get_cstring(pkgd, "pkgname", &pkgname); xbps_dictionary_get_cstring(pkgd, "pkgname", &pkgname);
rdeps = xbps_dictionary_get(pkgd, "run_depends"); rdeps = xbps_dictionary_get(pkgd, "run_depends");

View File

@ -128,13 +128,12 @@ list_orphans(struct xbps_handle *xhp)
{ {
xbps_array_t orphans; xbps_array_t orphans;
const char *pkgver; const char *pkgver;
unsigned int i;
orphans = xbps_find_pkg_orphans(xhp, NULL); orphans = xbps_find_pkg_orphans(xhp, NULL);
if (orphans == NULL) if (orphans == NULL)
return EINVAL; return EINVAL;
for (i = 0; i < xbps_array_count(orphans); i++) { for (unsigned int i = 0; i < xbps_array_count(orphans); i++) {
xbps_dictionary_get_cstring_nocopy(xbps_array_get(orphans, i), xbps_dictionary_get_cstring_nocopy(xbps_array_get(orphans, i),
"pkgver", &pkgver); "pkgver", &pkgver);
printf("%s\n", pkgver); printf("%s\n", pkgver);

View File

@ -54,7 +54,6 @@ match_files_by_pattern(xbps_dictionary_t pkg_filesd,
xbps_array_t array; xbps_array_t array;
xbps_object_t obj; xbps_object_t obj;
const char *keyname, *filestr, *typestr; const char *keyname, *filestr, *typestr;
unsigned int i;
int x; int x;
keyname = xbps_dictionary_keysym_cstring_nocopy(key); keyname = xbps_dictionary_keysym_cstring_nocopy(key);
@ -71,7 +70,7 @@ match_files_by_pattern(xbps_dictionary_t pkg_filesd,
return; return;
array = xbps_dictionary_get_keysym(pkg_filesd, key); array = xbps_dictionary_get_keysym(pkg_filesd, key);
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); obj = xbps_array_get(array, i);
filestr = NULL; filestr = NULL;
xbps_dictionary_get_cstring_nocopy(obj, "file", &filestr); xbps_dictionary_get_cstring_nocopy(obj, "file", &filestr);
@ -96,7 +95,6 @@ ownedby_pkgdb_cb(struct xbps_handle *xhp,
xbps_dictionary_t pkgmetad; xbps_dictionary_t pkgmetad;
xbps_array_t files_keys; xbps_array_t files_keys;
struct ffdata *ffd = arg; struct ffdata *ffd = arg;
unsigned int i;
const char *pkgver; const char *pkgver;
(void)obj_key; (void)obj_key;
@ -110,7 +108,7 @@ ownedby_pkgdb_cb(struct xbps_handle *xhp,
assert(pkgmetad); assert(pkgmetad);
files_keys = xbps_dictionary_all_keys(pkgmetad); files_keys = xbps_dictionary_all_keys(pkgmetad);
for (i = 0; i < xbps_array_count(files_keys); i++) { for (unsigned int i = 0; i < xbps_array_count(files_keys); i++) {
match_files_by_pattern(pkgmetad, match_files_by_pattern(pkgmetad,
xbps_array_get(files_keys, i), ffd, pkgver); xbps_array_get(files_keys, i), ffd, pkgver);
} }
@ -127,13 +125,12 @@ ownedby(struct xbps_handle *xhp, int npatterns, char **patterns)
{ {
struct ffdata ffd; struct ffdata ffd;
char *rfile; char *rfile;
int i;
ffd.npatterns = npatterns; ffd.npatterns = npatterns;
ffd.patterns = patterns; ffd.patterns = patterns;
pthread_mutex_init(&ffd.mtx, NULL); pthread_mutex_init(&ffd.mtx, NULL);
for (i = 0; i < npatterns; i++) { for (int i = 0; i < npatterns; i++) {
rfile = realpath(patterns[i], NULL); rfile = realpath(patterns[i], NULL);
if (rfile) if (rfile)
patterns[i] = rfile; patterns[i] = rfile;
@ -150,12 +147,10 @@ repo_match_cb(struct xbps_handle *xhp _unused,
{ {
struct ffdata *ffd = arg; struct ffdata *ffd = arg;
const char *filestr; const char *filestr;
unsigned int i;
int x;
for (i = 0; i < xbps_array_count(obj); i++) { for (unsigned int i = 0; i < xbps_array_count(obj); i++) {
xbps_array_get_cstring_nocopy(obj, i, &filestr); xbps_array_get_cstring_nocopy(obj, i, &filestr);
for (x = 0; x < ffd->npatterns; x++) { for (int x = 0; x < ffd->npatterns; x++) {
if ((fnmatch(ffd->patterns[x], filestr, FNM_PERIOD)) == 0) { if ((fnmatch(ffd->patterns[x], filestr, FNM_PERIOD)) == 0) {
printf("%s: %s (%s)\n", printf("%s: %s (%s)\n",
key, filestr, ffd->repouri); key, filestr, ffd->repouri);
@ -192,13 +187,13 @@ repo_ownedby(struct xbps_handle *xhp, int npatterns, char **patterns)
{ {
struct ffdata ffd; struct ffdata ffd;
char *rfile; char *rfile;
int i, rv; int rv;
pthread_mutex_init(&ffd.mtx, NULL); pthread_mutex_init(&ffd.mtx, NULL);
ffd.npatterns = npatterns; ffd.npatterns = npatterns;
ffd.patterns = patterns; ffd.patterns = patterns;
for (i = 0; i < npatterns; i++) { for (int i = 0; i < npatterns; i++) {
rfile = realpath(patterns[i], NULL); rfile = realpath(patterns[i], NULL);
if (rfile) if (rfile)
patterns[i] = rfile; patterns[i] = rfile;

View File

@ -58,17 +58,17 @@ print_results(struct xbps_handle *xhp, struct search_data *sd)
{ {
const char *pkgver, *desc, *inststr; const char *pkgver, *desc, *inststr;
char tmp[256], *out; char tmp[256], *out;
unsigned int i, j, tlen = 0, len = 0; unsigned int j, tlen = 0, len = 0;
/* Iterate over results array and find out largest pkgver string */ /* Iterate over results array and find out largest pkgver string */
for (i = 0; i < xbps_array_count(sd->results); i++) { for (unsigned int i = 0; i < xbps_array_count(sd->results); i++) {
xbps_array_get_cstring_nocopy(sd->results, i, &pkgver); xbps_array_get_cstring_nocopy(sd->results, i, &pkgver);
len = strlen(pkgver); len = strlen(pkgver);
if (tlen == 0 || len > tlen) if (tlen == 0 || len > tlen)
tlen = len; tlen = len;
i++; i++;
} }
for (i = 0; i < xbps_array_count(sd->results); i++) { for (unsigned int i = 0; i < xbps_array_count(sd->results); i++) {
xbps_array_get_cstring_nocopy(sd->results, i, &pkgver); xbps_array_get_cstring_nocopy(sd->results, i, &pkgver);
xbps_array_get_cstring_nocopy(sd->results, i+1, &desc); xbps_array_get_cstring_nocopy(sd->results, i+1, &desc);
strncpy(tmp, pkgver, sizeof(tmp)); strncpy(tmp, pkgver, sizeof(tmp));
@ -106,12 +106,11 @@ search_array_cb(struct xbps_handle *xhp _unused,
{ {
struct search_data *sd = arg; struct search_data *sd = arg;
const char *pkgver, *desc; const char *pkgver, *desc;
int x;
xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
xbps_dictionary_get_cstring_nocopy(obj, "short_desc", &desc); xbps_dictionary_get_cstring_nocopy(obj, "short_desc", &desc);
for (x = 0; x < sd->npatterns; x++) { for (int x = 0; x < sd->npatterns; x++) {
bool vpkgfound = false; bool vpkgfound = false;
if (xbps_match_virtual_pkg_in_dict(obj, sd->patterns[x], false)) if (xbps_match_virtual_pkg_in_dict(obj, sd->patterns[x], false))

View File

@ -40,16 +40,14 @@ print_rdeps(struct xbps_handle *xhp, xbps_array_t rdeps,
xbps_array_t currdeps; xbps_array_t currdeps;
xbps_dictionary_t pkgd; xbps_dictionary_t pkgd;
const char *pkgdep; const char *pkgdep;
unsigned int i;
int j;
if (!origin) if (!origin)
(*indent)++; (*indent)++;
for (i = 0; i < xbps_array_count(rdeps); i++) { for (unsigned int i = 0; i < xbps_array_count(rdeps); i++) {
xbps_array_get_cstring_nocopy(rdeps, i, &pkgdep); xbps_array_get_cstring_nocopy(rdeps, i, &pkgdep);
if (!origin || !full) if (!origin || !full)
for (j = 0; j < *indent; j++) for (int j = 0; j < *indent; j++)
putchar(' '); putchar(' ');
printf("%s\n", pkgdep); printf("%s\n", pkgdep);
@ -98,10 +96,9 @@ show_pkg_revdeps(struct xbps_handle *xhp, const char *pkg)
{ {
xbps_array_t reqby; xbps_array_t reqby;
const char *pkgdep; const char *pkgdep;
unsigned int i;
if ((reqby = xbps_pkgdb_get_pkg_revdeps(xhp, pkg)) != NULL) { if ((reqby = xbps_pkgdb_get_pkg_revdeps(xhp, pkg)) != NULL) {
for (i = 0; i < xbps_array_count(reqby); i++) { for (unsigned int i = 0; i < xbps_array_count(reqby); i++) {
xbps_array_get_cstring_nocopy(reqby, i, &pkgdep); xbps_array_get_cstring_nocopy(reqby, i, &pkgdep);
printf("%s\n", pkgdep); printf("%s\n", pkgdep);
} }
@ -132,13 +129,12 @@ repo_show_pkg_revdeps(struct xbps_handle *xhp, const char *pkg)
{ {
xbps_array_t revdeps; xbps_array_t revdeps;
const char *pkgver; const char *pkgver;
unsigned int i;
int rv; int rv;
revdeps = xbps_rpool_get_pkg_revdeps(xhp, pkg); revdeps = xbps_rpool_get_pkg_revdeps(xhp, pkg);
rv = errno; rv = errno;
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_get_cstring_nocopy(revdeps, i, &pkgver);
printf("%s\n", pkgver); printf("%s\n", pkgver);
} }

View File

@ -43,7 +43,6 @@ print_value_obj(const char *keyname, xbps_object_t obj,
xbps_array_t allkeys; xbps_array_t allkeys;
xbps_object_t obj2, keysym; xbps_object_t obj2, keysym;
const char *ksymname, *value; const char *ksymname, *value;
unsigned int i;
char size[8]; char size[8];
if (indent == NULL) if (indent == NULL)
@ -73,7 +72,7 @@ print_value_obj(const char *keyname, xbps_object_t obj,
case XBPS_TYPE_ARRAY: case XBPS_TYPE_ARRAY:
if (!raw) if (!raw)
printf("%s%s:\n", indent, keyname); printf("%s%s:\n", indent, keyname);
for (i = 0; i < xbps_array_count(obj); i++) { for (unsigned int i = 0; i < xbps_array_count(obj); i++) {
obj2 = xbps_array_get(obj, i); obj2 = xbps_array_get(obj, i);
if (xbps_object_type(obj2) == XBPS_TYPE_STRING) { if (xbps_object_type(obj2) == XBPS_TYPE_STRING) {
value = xbps_string_cstring_nocopy(obj2); value = xbps_string_cstring_nocopy(obj2);
@ -86,7 +85,7 @@ print_value_obj(const char *keyname, xbps_object_t obj,
break; break;
case XBPS_TYPE_DICTIONARY: case XBPS_TYPE_DICTIONARY:
allkeys = xbps_dictionary_all_keys(obj); allkeys = xbps_dictionary_all_keys(obj);
for (i = 0; i < xbps_array_count(allkeys); i++) { for (unsigned int i = 0; i < xbps_array_count(allkeys); i++) {
keysym = xbps_array_get(allkeys, i); keysym = xbps_array_get(allkeys, i);
ksymname = xbps_dictionary_keysym_cstring_nocopy(keysym); ksymname = xbps_dictionary_keysym_cstring_nocopy(keysym);
obj2 = xbps_dictionary_get_keysym(obj, keysym); obj2 = xbps_dictionary_get_keysym(obj, keysym);
@ -151,11 +150,10 @@ static void
print_srcrevs(const char *keyname, xbps_string_t obj) print_srcrevs(const char *keyname, xbps_string_t obj)
{ {
const char *str = xbps_string_cstring_nocopy(obj); const char *str = xbps_string_cstring_nocopy(obj);
unsigned int i;
/* parse string appending a \t after EOL */ /* parse string appending a \t after EOL */
printf("%s:\n ", keyname); printf("%s:\n ", keyname);
for (i = 0; i < strlen(str); i++) { for (unsigned int i = 0; i < strlen(str); i++) {
if (str[i] == '\n') if (str[i] == '\n')
printf("\n "); printf("\n ");
else else
@ -170,10 +168,9 @@ show_pkg_info(xbps_dictionary_t dict)
xbps_array_t all_keys; xbps_array_t all_keys;
xbps_object_t obj, keysym; xbps_object_t obj, keysym;
const char *keyname; const char *keyname;
unsigned int i;
all_keys = xbps_dictionary_all_keys(dict); all_keys = xbps_dictionary_all_keys(dict);
for (i = 0; i < xbps_array_count(all_keys); i++) { for (unsigned int i = 0; i < xbps_array_count(all_keys); i++) {
keysym = xbps_array_get(all_keys, i); keysym = xbps_array_get(all_keys, i);
keyname = xbps_dictionary_keysym_cstring_nocopy(keysym); keyname = xbps_dictionary_keysym_cstring_nocopy(keysym);
obj = xbps_dictionary_get_keysym(dict, keysym); obj = xbps_dictionary_get_keysym(dict, keysym);
@ -201,13 +198,12 @@ show_pkg_files(xbps_dictionary_t filesd)
xbps_object_t obj; xbps_object_t obj;
xbps_dictionary_keysym_t ksym; xbps_dictionary_keysym_t ksym;
const char *keyname, *file; const char *keyname, *file;
unsigned int i, x;
if (xbps_object_type(filesd) != XBPS_TYPE_DICTIONARY) if (xbps_object_type(filesd) != XBPS_TYPE_DICTIONARY)
return EINVAL; return EINVAL;
allkeys = xbps_dictionary_all_keys(filesd); allkeys = xbps_dictionary_all_keys(filesd);
for (i = 0; i < xbps_array_count(allkeys); i++) { for (unsigned int i = 0; i < xbps_array_count(allkeys); i++) {
ksym = xbps_array_get(allkeys, i); ksym = xbps_array_get(allkeys, i);
keyname = xbps_dictionary_keysym_cstring_nocopy(ksym); keyname = xbps_dictionary_keysym_cstring_nocopy(ksym);
if ((strcmp(keyname, "files") && if ((strcmp(keyname, "files") &&
@ -219,7 +215,7 @@ show_pkg_files(xbps_dictionary_t filesd)
if (array == NULL || xbps_array_count(array) == 0) if (array == NULL || xbps_array_count(array) == 0)
continue; continue;
for (x = 0; x < xbps_array_count(array); x++) { for (unsigned int x = 0; x < xbps_array_count(array); x++) {
obj = xbps_array_get(array, x); obj = xbps_array_get(array, x);
if (xbps_object_type(obj) != XBPS_TYPE_DICTIONARY) if (xbps_object_type(obj) != XBPS_TYPE_DICTIONARY)
continue; continue;

View File

@ -186,7 +186,6 @@ remove_pkg(struct xbps_handle *xhp, const char *pkgname, int cols,
{ {
xbps_array_t reqby; xbps_array_t reqby;
const char *pkgver; const char *pkgver;
unsigned int x;
int rv; int rv;
rv = xbps_transaction_remove_pkg(xhp, pkgname, recursive); rv = xbps_transaction_remove_pkg(xhp, pkgname, recursive);
@ -196,7 +195,7 @@ remove_pkg(struct xbps_handle *xhp, const char *pkgname, int cols,
printf("WARNING: %s IS REQUIRED BY %u PACKAGE%s:\n\n", printf("WARNING: %s IS REQUIRED BY %u PACKAGE%s:\n\n",
pkgname, xbps_array_count(reqby), pkgname, xbps_array_count(reqby),
xbps_array_count(reqby) > 1 ? "S" : ""); xbps_array_count(reqby) > 1 ? "S" : "");
for (x = 0; x < xbps_array_count(reqby); x++) { for (unsigned int x = 0; x < xbps_array_count(reqby); x++) {
xbps_array_get_cstring_nocopy(reqby, x, &pkgver); xbps_array_get_cstring_nocopy(reqby, x, &pkgver);
print_package_line(pkgver, cols, false); print_package_line(pkgver, cols, false);
} }
@ -238,7 +237,7 @@ main(int argc, char **argv)
}; };
struct xbps_handle xh; struct xbps_handle xh;
const char *rootdir, *cachedir, *conffile; const char *rootdir, *cachedir, *conffile;
int i, c, flags, rv; int c, flags, rv;
bool yes, drun, recursive, ignore_revdeps, clean_cache; bool yes, drun, recursive, ignore_revdeps, clean_cache;
bool orphans, reqby_force; bool orphans, reqby_force;
int maxcols; int maxcols;
@ -350,7 +349,7 @@ main(int argc, char **argv)
} }
} }
for (i = optind; i < argc; i++) { for (int i = optind; i < argc; i++) {
rv = remove_pkg(&xh, argv[i], maxcols, recursive); rv = remove_pkg(&xh, argv[i], maxcols, recursive);
if (rv == 0) if (rv == 0)
continue; continue;

View File

@ -52,8 +52,7 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
const char *oldpkgver, *arch, *oldarch; const char *oldpkgver, *arch, *oldarch;
char *pkgver, *pkgname, *sha256, *repodir, *buf; char *pkgver, *pkgname, *sha256, *repodir, *buf;
char *tmprepodir; char *tmprepodir;
unsigned int x; int rv, ret = 0;
int i, rv, ret = 0;
bool flush = false, found = false; bool flush = false, found = false;
idx = idxfiles = newpkgd = newpkgfilesd = curpkgd = NULL; idx = idxfiles = newpkgd = newpkgfilesd = curpkgd = NULL;
@ -81,7 +80,7 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
/* /*
* Process all packages specified in argv. * Process all packages specified in argv.
*/ */
for (i = 0; i < argc; i++) { for (int i = 0; i < argc; i++) {
/* /*
* Read metadata props plist dictionary from binary package. * Read metadata props plist dictionary from binary package.
*/ */
@ -241,7 +240,7 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
/* add conf_files in pkg files array */ /* add conf_files in pkg files array */
if (pkg_cffiles != NULL) { if (pkg_cffiles != NULL) {
for (x = 0; x < xbps_array_count(pkg_cffiles); x++) { for (unsigned int x = 0; x < xbps_array_count(pkg_cffiles); x++) {
obj = xbps_array_get(pkg_cffiles, x); obj = xbps_array_get(pkg_cffiles, x);
fileobj = xbps_dictionary_get(obj, "file"); fileobj = xbps_dictionary_get(obj, "file");
xbps_array_add(filespkgar, fileobj); xbps_array_add(filespkgar, fileobj);
@ -249,7 +248,7 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
} }
/* add files array in pkg array */ /* add files array in pkg array */
if (pkg_files != NULL) { if (pkg_files != NULL) {
for (x = 0; x < xbps_array_count(pkg_files); x++) { for (unsigned int x = 0; x < xbps_array_count(pkg_files); x++) {
obj = xbps_array_get(pkg_files, x); obj = xbps_array_get(pkg_files, x);
fileobj = xbps_dictionary_get(obj, "file"); fileobj = xbps_dictionary_get(obj, "file");
xbps_array_add(filespkgar, fileobj); xbps_array_add(filespkgar, fileobj);
@ -257,7 +256,7 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
} }
/* add links array in pkgd */ /* add links array in pkgd */
if (pkg_links != NULL) { if (pkg_links != NULL) {
for (x = 0; x < xbps_array_count(pkg_links); x++) { for (unsigned int x = 0; x < xbps_array_count(pkg_links); x++) {
obj = xbps_array_get(pkg_links, x); obj = xbps_array_get(pkg_links, x);
fileobj = xbps_dictionary_get(obj, "file"); fileobj = xbps_dictionary_get(obj, "file");
xbps_array_add(filespkgar, fileobj); xbps_array_add(filespkgar, fileobj);

View File

@ -59,12 +59,11 @@ cleaner_thread(void *arg)
struct thread_data *thd = arg; struct thread_data *thd = arg;
char *filen; char *filen;
const char *pkgver, *arch, *sha256; const char *pkgver, *arch, *sha256;
unsigned int i;
/* process pkgs from start until end */ /* process pkgs from start until end */
array = xbps_dictionary_all_keys(thd->idx); array = xbps_dictionary_all_keys(thd->idx);
for (i = thd->start; i < thd->end; i++) { for (unsigned int i = thd->start; i < thd->end; i++) {
obj = xbps_array_get(array, i); obj = xbps_array_get(array, i);
pkgd = xbps_dictionary_get_keysym(thd->idx, obj); pkgd = xbps_dictionary_get_keysym(thd->idx, obj);
xbps_dictionary_get_cstring_nocopy(pkgd, "architecture", &arch); xbps_dictionary_get_cstring_nocopy(pkgd, "architecture", &arch);
@ -104,12 +103,11 @@ cleaner_files_thread(void *arg)
struct thread_data *thd = arg; struct thread_data *thd = arg;
const char *pkgver, *ipkgver; const char *pkgver, *ipkgver;
char *pkgname; char *pkgname;
unsigned int i;
/* process pkgs from start until end */ /* process pkgs from start until end */
array = xbps_dictionary_all_keys(thd->idxfiles); array = xbps_dictionary_all_keys(thd->idxfiles);
for (i = thd->start; i < thd->end; i++) { for (unsigned int i = thd->start; i < thd->end; i++) {
obj = xbps_array_get(array, i); obj = xbps_array_get(array, i);
pkgver = xbps_dictionary_keysym_cstring_nocopy(obj); pkgver = xbps_dictionary_keysym_cstring_nocopy(obj);
pkgname = xbps_pkg_name(pkgver); pkgname = xbps_pkg_name(pkgver);
@ -143,8 +141,8 @@ index_clean(struct xbps_handle *xhp, const char *repodir)
xbps_dictionary_t idx, idxfiles; xbps_dictionary_t idx, idxfiles;
const char *keyname; const char *keyname;
char *pkgname; char *pkgname;
unsigned int x, pkgcount, slicecount; unsigned int pkgcount, slicecount;
int i, maxthreads, rv = 0; int maxthreads, rv = 0;
bool flush = false; bool flush = false;
repo = xbps_repo_open(xhp, repodir); repo = xbps_repo_open(xhp, repodir);
@ -175,7 +173,7 @@ index_clean(struct xbps_handle *xhp, const char *repodir)
pkgcount = 0; pkgcount = 0;
/* Setup threads to cleanup index and index-files */ /* Setup threads to cleanup index and index-files */
for (i = 0; i < maxthreads; i++) { for (int i = 0; i < maxthreads; i++) {
thd[i].thread_num = i; thd[i].thread_num = i;
thd[i].idx = idx; thd[i].idx = idx;
thd[i].result = xbps_array_create(); thd[i].result = xbps_array_create();
@ -189,14 +187,14 @@ index_clean(struct xbps_handle *xhp, const char *repodir)
pkgcount += slicecount; pkgcount += slicecount;
} }
/* wait for all threads */ /* wait for all threads */
for (i = 0; i < maxthreads; i++) for (int i = 0; i < maxthreads; i++)
pthread_join(thd[i].thread, NULL); pthread_join(thd[i].thread, NULL);
/* Setup threads to cleanup index-files */ /* Setup threads to cleanup index-files */
slicecount = xbps_dictionary_count(idxfiles) / maxthreads; slicecount = xbps_dictionary_count(idxfiles) / maxthreads;
pkgcount = 0; pkgcount = 0;
for (i = 0; i < maxthreads; i++) { for (int i = 0; i < maxthreads; i++) {
thd[i].thread_num = i; thd[i].thread_num = i;
thd[i].idx = idx; thd[i].idx = idx;
thd[i].idxfiles = idxfiles; thd[i].idxfiles = idxfiles;
@ -211,11 +209,11 @@ index_clean(struct xbps_handle *xhp, const char *repodir)
pkgcount += slicecount; pkgcount += slicecount;
} }
/* wait for all threads */ /* wait for all threads */
for (i = 0; i < maxthreads; i++) for (int i = 0; i < maxthreads; i++)
pthread_join(thd[i].thread, NULL); pthread_join(thd[i].thread, NULL);
for (i = 0; i < maxthreads; i++) { for (int i = 0; i < maxthreads; i++) {
for (x = 0; x < xbps_array_count(thd[i].result); x++) { for (unsigned int x = 0; x < xbps_array_count(thd[i].result); x++) {
xbps_array_get_cstring_nocopy(thd[i].result, xbps_array_get_cstring_nocopy(thd[i].result,
x, &keyname); x, &keyname);
printf("index: removed entry %s\n", keyname); printf("index: removed entry %s\n", keyname);
@ -225,7 +223,7 @@ index_clean(struct xbps_handle *xhp, const char *repodir)
free(pkgname); free(pkgname);
flush = true; flush = true;
} }
for (x = 0; x < xbps_array_count(thd[i].result_files); x++) { for (unsigned int x = 0; x < xbps_array_count(thd[i].result_files); x++) {
xbps_array_get_cstring_nocopy(thd[i].result_files, xbps_array_get_cstring_nocopy(thd[i].result_files,
x, &keyname); x, &keyname);
printf("index-files: removed entry %s\n", keyname); printf("index-files: removed entry %s\n", keyname);

View File

@ -102,7 +102,7 @@ main(int argc, char **argv)
struct xferstat xfer; struct xferstat xfer;
const char *version, *rootdir = NULL, *confdir = NULL; const char *version, *rootdir = NULL, *confdir = NULL;
char *pkgname, *hash; char *pkgname, *hash;
int flags = 0, i, c, rv = 0; int flags = 0, c, rv = 0;
while ((c = getopt(argc, argv, "C:dr:V")) != -1) { while ((c = getopt(argc, argv, "C:dr:V")) != -1) {
switch (c) { switch (c) {
@ -247,7 +247,7 @@ main(int argc, char **argv)
if (argc < 2) if (argc < 2)
usage(); usage();
for (i = 1; i < argc; i++) { for (int i = 1; i < argc; i++) {
hash = xbps_file_hash(argv[i]); hash = xbps_file_hash(argv[i]);
if (hash == NULL) { if (hash == NULL) {
fprintf(stderr, fprintf(stderr,
@ -263,7 +263,7 @@ main(int argc, char **argv)
if (argc != 2) if (argc != 2)
usage(); usage();
for (i = 1; i < argc; i++) { for (int i = 1; i < argc; i++) {
rv = xbps_fetch_file(&xh, argv[i], "v"); rv = xbps_fetch_file(&xh, argv[i], "v");
if (rv == -1) { if (rv == -1) {
printf("%s: %s\n", argv[1], printf("%s: %s\n", argv[1],

9
configure vendored
View File

@ -310,6 +310,15 @@ else
BUILD_PIE_VALUE=no BUILD_PIE_VALUE=no
fi fi
#
# A C99 compiler is required to build xbps.
#
check_compiler_flag "std=c99" "" CFLAGS
if [ $? -ne 0 ]; then
echo "ERRROR: A compatible C99 compiler is required, exiting..."
exit 1
fi
# libfetch # libfetch
echo "CPPFLAGS += -I\$(TOPDIR)/lib/fetch" >>$CONFIG_MK echo "CPPFLAGS += -I\$(TOPDIR)/lib/fetch" >>$CONFIG_MK
echo "LDFLAGS += -lssl" >>$CONFIG_MK echo "LDFLAGS += -lssl" >>$CONFIG_MK

View File

@ -94,9 +94,7 @@ config_inject_repos(struct xbps_handle *xh)
static int static int
cb_validate_virtual(cfg_t *cfg, cfg_opt_t *opt) cb_validate_virtual(cfg_t *cfg, cfg_opt_t *opt)
{ {
unsigned int i; for (unsigned int i = 0; i < cfg_size(cfg, "virtual-package"); i++) {
for (i = 0; i < cfg_size(cfg, "virtual-package"); i++) {
cfg_t *sec = cfg_opt_getnsec(opt, i); cfg_t *sec = cfg_opt_getnsec(opt, i);
if (cfg_getstr(sec, "targets") == 0) { if (cfg_getstr(sec, "targets") == 0) {
cfg_error(cfg, "targets must be set for " 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; xbps_array_t array;
const char *cffile; const char *cffile;
unsigned int i;
assert(xbps_object_type(propsd) == XBPS_TYPE_DICTIONARY); assert(xbps_object_type(propsd) == XBPS_TYPE_DICTIONARY);
assert(entry_pname != NULL); assert(entry_pname != NULL);
@ -48,7 +47,7 @@ xbps_entry_is_a_conf_file(xbps_dictionary_t propsd,
if (xbps_array_count(array) == 0) if (xbps_array_count(array) == 0)
return false; 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); xbps_array_get_cstring_nocopy(array, i, &cffile);
if (strcmp(cffile, entry_pname) == 0) if (strcmp(cffile, entry_pname) == 0)
return true; return true;

View File

@ -78,7 +78,6 @@ xbps_find_pkg_obsoletes(struct xbps_handle *xhp,
xbps_array_t instfiles, newfiles, obsoletes; xbps_array_t instfiles, newfiles, obsoletes;
xbps_object_t obj, obj2; xbps_object_t obj, obj2;
xbps_string_t oldstr, newstr; xbps_string_t oldstr, newstr;
unsigned int i, x;
const char *oldhash; const char *oldhash;
char *file; char *file;
int rv = 0; int rv = 0;
@ -101,7 +100,7 @@ xbps_find_pkg_obsoletes(struct xbps_handle *xhp,
/* /*
* Iterate over files list from installed package. * 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; found = false;
obj = xbps_array_get(instfiles, i); obj = xbps_array_get(instfiles, i);
if (xbps_object_type(obj) != XBPS_TYPE_DICTIONARY) { 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. * 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); obj2 = xbps_array_get(newfiles, x);
newstr = xbps_dictionary_get(obj2, "file"); newstr = xbps_dictionary_get(obj2, "file");
assert(newstr); 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; xbps_object_iterator_t iter;
const char *curpkgver, *deppkgver, *reqbydep; const char *curpkgver, *deppkgver, *reqbydep;
bool automatic = false; bool automatic = false;
unsigned int i, x, j, cnt, reqbycnt; unsigned int cnt, reqbycnt;
if (xbps_pkgdb_init(xhp) != 0) if (xbps_pkgdb_init(xhp) != 0)
return NULL; 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. * 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); xbps_array_get_cstring_nocopy(orphans_user, i, &curpkgver);
pkgd = xbps_pkgdb_get_pkg(xhp, curpkgver); pkgd = xbps_pkgdb_get_pkg(xhp, curpkgver);
if (pkgd == NULL) 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); xbps_object_iterator_release(iter);
find_orphans: 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); pkgd = xbps_array_get(array, i);
rdeps = xbps_dictionary_get(pkgd, "run_depends"); 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; cnt = 0;
xbps_array_get_cstring_nocopy(rdeps, x, &deppkgver); xbps_array_get_cstring_nocopy(rdeps, x, &deppkgver);
reqby = xbps_pkgdb_get_pkg_revdeps(xhp, deppkgver); reqby = xbps_pkgdb_get_pkg_revdeps(xhp, deppkgver);
if (reqby == NULL) if (reqby == NULL)
continue; continue;
reqbycnt = xbps_array_count(reqby); 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); xbps_array_get_cstring_nocopy(reqby, j, &reqbydep);
if (xbps_find_pkg_in_array(array, reqbydep)) { if (xbps_find_pkg_in_array(array, reqbydep)) {
cnt++; cnt++;

View File

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

View File

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

View File

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

View File

@ -238,7 +238,7 @@ vpkg_user_conf(struct xbps_handle *xhp,
{ {
const char *vpkgver, *pkg = NULL; const char *vpkgver, *pkg = NULL;
char *vpkgname = NULL, *tmp; char *vpkgname = NULL, *tmp;
unsigned int i, j, cnt; unsigned int cnt;
if (xhp->cfg == NULL) if (xhp->cfg == NULL)
return NULL; return NULL;
@ -254,9 +254,9 @@ vpkg_user_conf(struct xbps_handle *xhp,
return NULL; 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); 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; tmp = NULL;
vpkgver = cfg_getnstr(sec, "targets", j); vpkgver = cfg_getnstr(sec, "targets", j);
if (strchr(vpkgver, '_') == NULL) { 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; xbps_object_t obj;
const char *pkgver, *tpkgver, *arch, *vpkg; const char *pkgver, *tpkgver, *arch, *vpkg;
char *buf; char *buf;
unsigned int i;
iter = xbps_dictionary_iterator(repo->idx); iter = xbps_dictionary_iterator(repo->idx);
assert(iter); 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. * Try to match any virtual package.
*/ */
provides = xbps_dictionary_get(tpkgd, "provides"); 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); xbps_array_get_cstring_nocopy(provides, i, &vpkg);
if (strchr(vpkg, '_') == NULL) if (strchr(vpkg, '_') == NULL)
buf = xbps_xasprintf("%s_1", vpkg); 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; xbps_dictionary_t pkgd;
const char *vpkg; const char *vpkg;
char *buf = NULL; char *buf = NULL;
unsigned int i;
bool match = false; bool match = false;
if (((pkgd = xbps_rpool_get_pkg(repo->xhp, pkg)) == NULL) && 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 pkg is a virtual pkg let's match it instead of the real pkgver.
*/ */
if ((vdeps = xbps_dictionary_get(pkgd, "provides"))) { 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; char *vpkgn;
xbps_array_get_cstring_nocopy(vdeps, i, &vpkg); 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_object_iterator_t iter;
xbps_array_t curpkgrdeps; xbps_array_t curpkgrdeps;
pkg_state_t state; pkg_state_t state;
unsigned int x;
const char *reqpkg, *pkgver_q, *reason = NULL; const char *reqpkg, *pkgver_q, *reason = NULL;
char *pkgname, *reqpkgname; char *pkgname, *reqpkgname;
int rv = 0; int rv = 0;
@ -179,7 +178,7 @@ find_repo_deps(struct xbps_handle *xhp,
reqpkg = xbps_string_cstring_nocopy(obj); reqpkg = xbps_string_cstring_nocopy(obj);
if (xhp->flags & XBPS_FLAG_DEBUG) { if (xhp->flags & XBPS_FLAG_DEBUG) {
xbps_dbg_printf(xhp, ""); 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, " ");
xbps_dbg_printf_append(xhp, "%s: requires dependency '%s': ", xbps_dbg_printf_append(xhp, "%s: requires dependency '%s': ",
curpkg != NULL ? curpkg : " ", reqpkg); curpkg != NULL ? curpkg : " ", reqpkg);
@ -367,7 +366,7 @@ find_repo_deps(struct xbps_handle *xhp,
if (xhp->flags & XBPS_FLAG_DEBUG) { if (xhp->flags & XBPS_FLAG_DEBUG) {
xbps_dbg_printf(xhp, ""); 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, " ");
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; struct rpool *rp;
const char *repouri; const char *repouri;
unsigned int i;
bool foundrepo = false; bool foundrepo = false;
int rv = 0; int rv = 0;
@ -63,7 +62,7 @@ xbps_rpool_init(struct xbps_handle *xhp)
else if (xhp->cfg == NULL) else if (xhp->cfg == NULL)
return ENOTSUP; 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)); rp = malloc(sizeof(struct rpool));
assert(rp); assert(rp);
repouri = cfg_getnstr(xhp->cfg, "repositories", i); repouri = cfg_getnstr(xhp->cfg, "repositories", i);
@ -114,12 +113,11 @@ int
xbps_rpool_sync(struct xbps_handle *xhp, const char *uri) xbps_rpool_sync(struct xbps_handle *xhp, const char *uri)
{ {
const char *repouri; const char *repouri;
unsigned int i;
if (xhp->cfg == NULL) if (xhp->cfg == NULL)
return ENOTSUP; 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); repouri = cfg_getnstr(xhp->cfg, "repositories", i);
/* If argument was set just process that repository */ /* If argument was set just process that repository */
if (uri && strcmp(repouri, uri)) 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; struct rpool_fpkg *rpf = arg;
xbps_array_t revdeps = NULL; xbps_array_t revdeps = NULL;
const char *pkgver; const char *pkgver;
unsigned int i;
revdeps = xbps_repo_get_pkg_revdeps(repo, rpf->pattern); revdeps = xbps_repo_get_pkg_revdeps(repo, rpf->pattern);
if (xbps_array_count(revdeps)) { if (xbps_array_count(revdeps)) {
/* found */ /* found */
if (rpf->revdeps == NULL) if (rpf->revdeps == NULL)
rpf->revdeps = xbps_array_create(); 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_get_cstring_nocopy(revdeps, i, &pkgver);
xbps_array_add_cstring_nocopy(rpf->revdeps, 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; const char *pattern, *pkgver, *curpkgver;
char *buf, *pkgname, *curpkgname; char *buf, *pkgname, *curpkgname;
bool instd_auto, sr; bool instd_auto, sr;
unsigned int i;
unsorted = xbps_dictionary_get(xhp->transd, "unsorted_deps"); 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); obj = xbps_array_get(unsorted, i);
replaces = xbps_dictionary_get(obj, "replaces"); replaces = xbps_dictionary_get(obj, "replaces");
if (replaces == NULL || xbps_array_count(replaces) == 0) 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; xbps_array_t unsorted, provides, rundeps, mdeps;
const char *pkgver, *revpkgver, *pkgpattern; const char *pkgver, *revpkgver, *pkgpattern;
char *pkgname, *pkgdepname, *vpkgname, *vpkgver, *str; char *pkgname, *pkgdepname, *vpkgname, *vpkgver, *str;
unsigned int i, x;
bool matched = false; bool matched = false;
unsorted = xbps_dictionary_get(xhp->transd, "unsorted_deps"); unsorted = xbps_dictionary_get(xhp->transd, "unsorted_deps");
provides = xbps_dictionary_get(trans_pkgd, "provides"); 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; char *tmp = NULL;
xbps_array_get_cstring(provides, i, &vpkgver); xbps_array_get_cstring(provides, i, &vpkgver);
@ -64,7 +63,7 @@ check_virtual_pkgs(struct xbps_handle *xhp,
vpkgname = xbps_pkg_name(vpkgver); vpkgname = xbps_pkg_name(vpkgver);
assert(vpkgname); assert(vpkgname);
rundeps = xbps_dictionary_get(rev_pkgd, "run_depends"); 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); xbps_array_get_cstring_nocopy(rundeps, x, &pkgpattern);
if (((pkgname = xbps_pkgpattern_name(pkgpattern)) == NULL) && if (((pkgname = xbps_pkgpattern_name(pkgpattern)) == NULL) &&
((pkgname = xbps_pkg_name(pkgpattern)) == NULL)) ((pkgname = xbps_pkg_name(pkgpattern)) == NULL))
@ -117,11 +116,10 @@ xbps_transaction_revdeps(struct xbps_handle *xhp)
xbps_object_t obj; xbps_object_t obj;
const char *pkgver, *curdep, *revpkgver, *curpkgver, *tract; const char *pkgver, *curdep, *revpkgver, *curpkgver, *tract;
char *pkgname, *curdepname, *curpkgname, *str; char *pkgname, *curdepname, *curpkgname, *str;
unsigned int i, j, x;
unsorted = xbps_dictionary_get(xhp->transd, "unsorted_deps"); 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); obj = xbps_array_get(unsorted, i);
/* /*
* Only check packages in transaction being updated. * 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. * 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; bool found = false;
xbps_array_get_cstring_nocopy(pkgrdeps, x, &curpkgver); xbps_array_get_cstring_nocopy(pkgrdeps, x, &curpkgver);
@ -173,7 +171,7 @@ xbps_transaction_revdeps(struct xbps_handle *xhp)
curpkgname = xbps_pkg_name(pkgver); curpkgname = xbps_pkg_name(pkgver);
assert(curpkgname); 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); xbps_array_get_cstring_nocopy(rundeps, j, &curdep);
if (((curdepname = xbps_pkg_name(curdep)) == NULL) && if (((curdepname = xbps_pkg_name(curdep)) == NULL) &&
((curdepname = xbps_pkgpattern_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_array_t provides, sorted, unsorted, rundeps;
xbps_object_t obj; xbps_object_t obj;
struct pkgdep *pd; struct pkgdep *pd;
unsigned int i, j, ndeps = 0, cnt = 0; unsigned int ndeps = 0, cnt = 0;
const char *pkgname, *pkgver, *tract, *vpkgdep; const char *pkgname, *pkgver, *tract, *vpkgdep;
int rv = 0; int rv = 0;
bool vpkg_found; bool vpkg_found;
@ -290,7 +290,7 @@ xbps_transaction_sort(struct xbps_handle *xhp)
* Iterate over the unsorted package dictionaries and sort all * Iterate over the unsorted package dictionaries and sort all
* its package dependencies. * its package dependencies.
*/ */
for (i = 0; i < ndeps; i++) { for (unsigned int i = 0; i < ndeps; i++) {
vpkg_found = false; vpkg_found = false;
obj = xbps_array_get(unsorted, i); obj = xbps_array_get(unsorted, i);
xbps_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname); 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 * if any of them was previously added. If true, don't
* add it into the list again, just order its deps. * 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, xbps_array_get_cstring_nocopy(provides,
j, &vpkgdep); j, &vpkgdep);
pd = pkgdep_find(vpkgdep); pd = pkgdep_find(vpkgdep);