summaryrefslogtreecommitdiff
path: root/src/commit.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2013-06-18 08:03:40 +0300
committerTimo Teräs <timo.teras@iki.fi>2013-06-18 08:03:40 +0300
commit54509e7a1a33923569848ce69c6e7f94fc6a021b (patch)
treea64133f0311c56fe1091fae3a5e293688c3caf01 /src/commit.c
parent72139b82d3e6631c839745f3c34a5aca8c5c61e4 (diff)
downloadapk-tools-54509e7a1a33923569848ce69c6e7f94fc6a021b.tar.gz
apk-tools-54509e7a1a33923569848ce69c6e7f94fc6a021b.tar.bz2
apk-tools-54509e7a1a33923569848ce69c6e7f94fc6a021b.tar.xz
apk-tools-54509e7a1a33923569848ce69c6e7f94fc6a021b.zip
all: various conversions to foreach_array_item, and simplifications of code
Diffstat (limited to 'src/commit.c')
-rw-r--r--src/commit.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/src/commit.c b/src/commit.c
index e55843e..6279e53 100644
--- a/src/commit.c
+++ b/src/commit.c
@@ -147,10 +147,9 @@ static int dump_packages(struct apk_changeset *changeset,
struct apk_change *change;
struct apk_name *name;
struct apk_indent indent = { .indent = 2 };
- int match = 0, i;
+ int match = 0;
- for (i = 0; i < changeset->changes->num; i++) {
- change = &changeset->changes->item[i];
+ foreach_array_item(change, changeset->changes) {
if (!cmp(change))
continue;
if (match == 0)
@@ -207,18 +206,16 @@ static int cmp_upgrade(struct apk_change *change)
static void run_triggers(struct apk_database *db, struct apk_changeset *changeset)
{
- int i;
+ struct apk_change *change;
+ struct apk_installed_package *ipkg;
if (apk_db_fire_triggers(db) == 0)
return;
- for (i = 0; i < changeset->changes->num; i++) {
- struct apk_package *pkg = changeset->changes->item[i].new_pkg;
- struct apk_installed_package *ipkg;
-
+ foreach_array_item(change, changeset->changes) {
+ struct apk_package *pkg = change->new_pkg;
if (pkg == NULL)
continue;
-
ipkg = pkg->ipkg;
if (ipkg->pending_triggers->num == 0)
continue;
@@ -236,7 +233,7 @@ int apk_solver_commit_changeset(struct apk_database *db,
{
struct progress prog;
struct apk_change *change;
- int i, r = 0, size_diff = 0, size_unit;
+ int r = 0, size_diff = 0, size_unit;
if (apk_db_check_world(db, world) != 0) {
apk_error("Not committing changes due to missing repository tags. Use --force to override.");
@@ -248,8 +245,7 @@ int apk_solver_commit_changeset(struct apk_database *db,
/* Count what needs to be done */
memset(&prog, 0, sizeof(prog));
- for (i = 0; i < changeset->changes->num; i++) {
- change = &changeset->changes->item[i];
+ foreach_array_item(change, changeset->changes) {
count_change(change, &prog.total);
if (change->new_pkg)
size_diff += change->new_pkg->installed_size;
@@ -291,9 +287,7 @@ int apk_solver_commit_changeset(struct apk_database *db,
/* Go through changes */
r = 0;
- for (i = 0; i < changeset->changes->num; i++) {
- change = &changeset->changes->item[i];
-
+ foreach_array_item(change, changeset->changes) {
if (print_change(db, change, prog.done.changes, prog.total.changes)) {
prog.pkg = change->new_pkg;
prog.flags = APK_PRINT_PROGRESS_FORCE;