core: use FOREACH_ARRAY at 3 more places
authorMike Yuan <me@yhndnzj.com>
Wed, 10 Apr 2024 15:01:47 +0000 (23:01 +0800)
committerMike Yuan <me@yhndnzj.com>
Wed, 10 Apr 2024 15:40:53 +0000 (23:40 +0800)
src/core/manager.c
src/core/target.c
src/core/transaction.c

index fe7dc19672ae899ca529a75fe7637cc6b04c8fb2..6ac97e76609d334d08a30a3c3cd9b132d656bb2f 100644 (file)
@@ -2203,8 +2203,8 @@ static int manager_dispatch_target_deps_queue(Manager *m) {
                 if (n_targets < 0)
                         return n_targets;
 
-                for (int i = 0; i < n_targets; i++) {
-                        r = unit_add_default_target_dependency(u, targets[i]);
+                FOREACH_ARRAY(i, targets, n_targets) {
+                        r = unit_add_default_target_dependency(u, *i);
                         if (r < 0)
                                 return r;
                 }
index d9362b8b16436829dcc95a6d085339836508ea0f..15866e9b1e87b3534e03a6b519dc0bb15016fef3 100644 (file)
@@ -55,8 +55,8 @@ static int target_add_default_dependencies(Target *t) {
         if (n_others < 0)
                 return n_others;
 
-        for (int i = 0; i < n_others; i++) {
-                r = unit_add_default_target_dependency(others[i], UNIT(t));
+        FOREACH_ARRAY(i, others, n_others) {
+                r = unit_add_default_target_dependency(*i, UNIT(t));
                 if (r < 0)
                         return r;
         }
index a81c40fb062a3a14dbb46502d89eb358654bc32f..b5c6348b6fcbc7bef2e7f5a6f94c05f788759174 100644 (file)
@@ -446,10 +446,10 @@ static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsi
          * the graph over 'before' edges in the actual job execution order. We traverse over both unit
          * ordering dependencies and we test with job_compare() whether it is the 'before' edge in the job
          * execution ordering. */
-        for (size_t d = 0; d < ELEMENTSOF(directions); d++) {
+        FOREACH_ARRAY(d, directions, ELEMENTSOF(directions)) {
                 Unit *u;
 
-                UNIT_FOREACH_DEPENDENCY(u, j->unit, directions[d]) {
+                UNIT_FOREACH_DEPENDENCY(u, j->unit, *d) {
                         Job *o;
 
                         /* Is there a job for this unit? */
@@ -463,7 +463,7 @@ static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsi
                         }
 
                         /* Cut traversing if the job j is not really *before* o. */
-                        if (job_compare(j, o, directions[d]) >= 0)
+                        if (job_compare(j, o, *d) >= 0)
                                 continue;
 
                         r = transaction_verify_order_one(tr, o, j, generation, e);