]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/delta/delta.c
tree-wide: define iterator inside of the macro
[thirdparty/systemd.git] / src / delta / delta.c
index 08d8867431d6ffacf0b00f58e2ffeef4175295d1..acb6020715ec5c573208637045a031c31f617ce7 100644 (file)
@@ -2,7 +2,6 @@
 
 #include <errno.h>
 #include <getopt.h>
-#include <string.h>
 #include <sys/prctl.h>
 #include <unistd.h>
 
@@ -73,11 +72,11 @@ static int equivalent(const char *a, const char *b) {
         _cleanup_free_ char *x = NULL, *y = NULL;
         int r;
 
-        r = chase_symlinks(a, NULL, CHASE_TRAIL_SLASH, &x);
+        r = chase_symlinks(a, NULL, CHASE_TRAIL_SLASH, &x, NULL);
         if (r < 0)
                 return r;
 
-        r = chase_symlinks(b, NULL, CHASE_TRAIL_SLASH, &y);
+        r = chase_symlinks(b, NULL, CHASE_TRAIL_SLASH, &y, NULL);
         if (r < 0)
                 return r;
 
@@ -200,7 +199,7 @@ static int enumerate_dir_d(
 
         assert(!endswith(drop, "/"));
 
-        path = strjoin(toppath, "/", drop);
+        path = path_join(toppath, drop);
         if (!path)
                 return -ENOMEM;
 
@@ -230,7 +229,7 @@ static int enumerate_dir_d(
                 if (!endswith(*file, ".conf"))
                         continue;
 
-                p = strjoin(path, "/", *file);
+                p = path_join(path, *file);
                 if (!p)
                         return -ENOMEM;
                 d = p + strlen(toppath) + 1;
@@ -347,7 +346,7 @@ static int enumerate_dir(
         STRV_FOREACH(t, files) {
                 _cleanup_free_ char *p = NULL;
 
-                p = strjoin(path, "/", *t);
+                p = path_join(path, *t);
                 if (!p)
                         return -ENOMEM;
 
@@ -374,12 +373,11 @@ static int enumerate_dir(
 static int should_skip_path(const char *prefix, const char *suffix) {
 #if HAVE_SPLIT_USR
         _cleanup_free_ char *target = NULL;
-        const char *p;
-        char *dirname;
+        const char *dirname, *p;
 
-        dirname = strjoina(prefix, "/", suffix);
+        dirname = prefix_roota(prefix, suffix);
 
-        if (chase_symlinks(dirname, NULL, 0, &target) < 0)
+        if (chase_symlinks(dirname, NULL, 0, &target, NULL) < 0)
                 return false;
 
         NULSTR_FOREACH(p, prefixes) {
@@ -403,13 +401,9 @@ static int should_skip_path(const char *prefix, const char *suffix) {
 
 static int process_suffix(const char *suffix, const char *onlyprefix) {
         const char *p;
-        char *f;
-        OrderedHashmap *top, *bottom, *drops;
-        OrderedHashmap *h;
-        char *key;
-        int r = 0, k;
-        Iterator i, j;
-        int n_found = 0;
+        char *f, *key;
+        OrderedHashmap *top, *bottom, *drops, *h;
+        int r = 0, k, n_found = 0;
         bool dropins;
 
         assert(suffix);
@@ -432,7 +426,7 @@ static int process_suffix(const char *suffix, const char *onlyprefix) {
                 if (should_skip_path(p, suffix) > 0)
                         continue;
 
-                t = strjoin(p, "/", suffix);
+                t = path_join(p, suffix);
                 if (!t) {
                         r = -ENOMEM;
                         goto finish;
@@ -443,7 +437,7 @@ static int process_suffix(const char *suffix, const char *onlyprefix) {
                         r = k;
         }
 
-        ORDERED_HASHMAP_FOREACH_KEY(f, key, top, i) {
+        ORDERED_HASHMAP_FOREACH_KEY(f, key, top) {
                 char *o;
 
                 o = ordered_hashmap_get(bottom, key);
@@ -463,7 +457,7 @@ static int process_suffix(const char *suffix, const char *onlyprefix) {
 
                 h = ordered_hashmap_get(drops, key);
                 if (h)
-                        ORDERED_HASHMAP_FOREACH(o, h, j)
+                        ORDERED_HASHMAP_FOREACH(o, h)
                                 if (!onlyprefix || startswith(o, onlyprefix))
                                         n_found += notify_override_extended(f, o);
         }
@@ -472,7 +466,7 @@ finish:
         ordered_hashmap_free_free(top);
         ordered_hashmap_free_free(bottom);
 
-        ORDERED_HASHMAP_FOREACH_KEY(h, key, drops, i) {
+        ORDERED_HASHMAP_FOREACH_KEY(h, key, drops) {
                 ordered_hashmap_free_free(ordered_hashmap_remove(drops, key));
                 ordered_hashmap_remove(drops, key);
                 free(key);
@@ -645,9 +639,7 @@ static int parse_argv(int argc, char *argv[]) {
 static int run(int argc, char *argv[]) {
         int r, k, n_found = 0;
 
-        log_show_color(true);
-        log_parse_environment();
-        log_open();
+        log_setup_cli();
 
         r = parse_argv(argc, argv);
         if (r <= 0)