]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-path: rename the two functions
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 23 Mar 2020 18:50:59 +0000 (19:50 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 27 Mar 2020 19:12:44 +0000 (20:12 +0100)
I think the two names were both pretty bad. They did not give a proper hint
what the difference between the two functions is, and sd_path_home sounds like
it is somehow related to /home or home directories or whatever, when in fact
both functions return the same set of paths as either a colon-delimited string
or a strv. "_strv" suffix is used by various functions in sd-bus, so let's
reuse that.

Those functions are not public yet, so let's rename.

src/core/manager.c
src/environment-d-generator/environment-d-generator.c
src/libsystemd/sd-path/sd-path.c
src/path/path.c
src/systemd/sd-path.h
src/test/test-sd-path.c
src/tmpfiles/tmpfiles.c

index 38f7ba1eb87c0f42a8b98cda44453b58179d78e9..4c59addfc8e63b048c30f4291ebbdd599f394ffa 100644 (file)
@@ -689,7 +689,7 @@ static int manager_setup_prefix(Manager *m) {
                 p = paths_user;
 
         for (i = 0; i < _EXEC_DIRECTORY_TYPE_MAX; i++) {
-                r = sd_path_home(p[i].type, p[i].suffix, &m->prefix[i]);
+                r = sd_path_lookup(p[i].type, p[i].suffix, &m->prefix[i]);
                 if (r < 0)
                         return r;
         }
index 5fe51359f60d50a79ed7ae5ae24522640e011dbf..4a14c23f11499dceb7555459033da17eb30172b3 100644 (file)
@@ -20,7 +20,7 @@ static int environment_dirs(char ***ret) {
                 return -ENOMEM;
 
         /* ~/.config/systemd/environment.d */
-        r = sd_path_home(SD_PATH_USER_CONFIGURATION, "environment.d", &c);
+        r = sd_path_lookup(SD_PATH_USER_CONFIGURATION, "environment.d", &c);
         if (r < 0)
                 return r;
 
index 95d6551e5cf5064b3ba47c023bd5232c54e72e8a..5797f55c75a92d7c6dea24ea27f3851aaa447145 100644 (file)
@@ -323,7 +323,7 @@ static int get_path(uint64_t type, char **buffer, const char **ret) {
         return -EOPNOTSUPP;
 }
 
-_public_ int sd_path_home(uint64_t type, const char *suffix, char **path) {
+_public_ int sd_path_lookup(uint64_t type, const char *suffix, char **path) {
         _cleanup_free_ char *buffer = NULL;
         const char *ret;
         char *cc;
@@ -343,7 +343,7 @@ _public_ int sd_path_home(uint64_t type, const char *suffix, char **path) {
 
                 _cleanup_strv_free_ char **l = NULL;
 
-                r = sd_path_search(type, suffix, &l);
+                r = sd_path_lookup_strv(type, suffix, &l);
                 if (r < 0)
                         return r;
 
@@ -550,7 +550,7 @@ static int get_search(uint64_t type, char ***list) {
         return -EOPNOTSUPP;
 }
 
-_public_ int sd_path_search(uint64_t type, const char *suffix, char ***paths) {
+_public_ int sd_path_lookup_strv(uint64_t type, const char *suffix, char ***paths) {
         char **i, **j;
         _cleanup_strv_free_ char **l = NULL, **n = NULL;
         int r;
@@ -569,7 +569,7 @@ _public_ int sd_path_search(uint64_t type, const char *suffix, char ***paths) {
 
                 char *p;
 
-                r = sd_path_home(type, suffix, &p);
+                r = sd_path_lookup(type, suffix, &p);
                 if (r < 0)
                         return r;
 
index fa81632bb2786ae7928c71fd6c03c34a62989a3c..26252948c50f47b955063bec16329de9e755438e 100644 (file)
@@ -68,7 +68,7 @@ static int list_homes(void) {
                 _cleanup_free_ char *p = NULL;
                 int q;
 
-                q = sd_path_home(i, arg_suffix, &p);
+                q = sd_path_lookup(i, arg_suffix, &p);
                 if (q == -ENXIO)
                         continue;
                 if (q < 0) {
@@ -91,7 +91,7 @@ static int print_home(const char *n) {
                 if (streq(path_table[i], n)) {
                         _cleanup_free_ char *p = NULL;
 
-                        r = sd_path_home(i, arg_suffix, &p);
+                        r = sd_path_lookup(i, arg_suffix, &p);
                         if (r < 0)
                                 return log_error_errno(r, "Failed to query %s: %m", n);
 
index 16379876eb69999638532370c7b28d4710140cba..2bb0b8524432ef561749b13feba577c4dd2d10e4 100644 (file)
@@ -81,8 +81,8 @@ enum {
         _SD_PATH_MAX,
 };
 
-int sd_path_home(uint64_t type, const char *suffix, char **path);
-int sd_path_search(uint64_t type, const char *suffix, char ***paths);
+int sd_path_lookup(uint64_t type, const char *suffix, char **path);
+int sd_path_lookup_strv(uint64_t type, const char *suffix, char ***paths);
 
 _SD_END_DECLARATIONS;
 
index 780a62a2cf0c8068b7db0b85979b875e1f9add04..5888d3b9f942318994d4402ff6f3088b9a37e1af 100644 (file)
@@ -7,40 +7,40 @@
 #include "strv.h"
 #include "tests.h"
 
-static void test_sd_path_home(void) {
+static void test_sd_path_lookup(void) {
         log_info("/* %s */", __func__);
 
         for (uint64_t i = 0; i < _SD_PATH_MAX; i++) {
                 _cleanup_free_ char *t, *s;
 
-                assert_se(sd_path_home(i, NULL, &t) == 0);
+                assert_se(sd_path_lookup(i, NULL, &t) == 0);
                 assert_se(t);
                 log_info("%02"PRIu64": \"%s\"", i, t);
 
-                assert_se(sd_path_home(i, "suffix", &s) == 0);
+                assert_se(sd_path_lookup(i, "suffix", &s) == 0);
                 assert_se(s);
                 log_info("%02"PRIu64": \"%s\"", i, s);
                 assert_se(endswith(s, "/suffix"));
         }
 
         char *tt;
-        assert_se(sd_path_home(_SD_PATH_MAX, NULL, &tt) == -EOPNOTSUPP);
+        assert_se(sd_path_lookup(_SD_PATH_MAX, NULL, &tt) == -EOPNOTSUPP);
 }
 
-static void test_sd_path_search(void) {
+static void test_sd_path_lookup_strv(void) {
         log_info("/* %s */", __func__);
 
         for (uint64_t i = 0; i < _SD_PATH_MAX; i++) {
                 _cleanup_strv_free_ char **t, **s;
                 char **item;
 
-                assert_se(sd_path_search(i, NULL, &t) == 0);
+                assert_se(sd_path_lookup_strv(i, NULL, &t) == 0);
                 assert_se(t);
                 log_info("%02"PRIu64":", i);
                 STRV_FOREACH(item, t)
                         log_debug("  %s", *item);
 
-                assert_se(sd_path_search(i, "suffix", &s) == 0);
+                assert_se(sd_path_lookup_strv(i, "suffix", &s) == 0);
                 assert_se(s);
                 log_info("%02"PRIu64":", i);
                 STRV_FOREACH(item, s) {
@@ -50,12 +50,12 @@ static void test_sd_path_search(void) {
         }
 
         char *tt;
-        assert_se(sd_path_home(_SD_PATH_MAX, NULL, &tt) == -EOPNOTSUPP);
+        assert_se(sd_path_lookup(_SD_PATH_MAX, NULL, &tt) == -EOPNOTSUPP);
 }
 
 int main(void) {
         test_setup_logging(LOG_DEBUG);
 
-        test_sd_path_home();
-        test_sd_path_search();
+        test_sd_path_lookup();
+        test_sd_path_lookup_strv();
 }
index d1ba5841fd684d7fadadeaa3b093fbdc406a72bd..6ab30cdecfe10a6975815809053883a448c489c7 100644 (file)
@@ -244,7 +244,7 @@ static int specifier_directory(char specifier, const void *data, const void *use
         i = PTR_TO_UINT(data);
         assert(i < ELEMENTSOF(paths_system));
 
-        return sd_path_home(paths[i].type, paths[i].suffix, ret);
+        return sd_path_lookup(paths[i].type, paths[i].suffix, ret);
 }
 
 static int log_unresolvable_specifier(const char *filename, unsigned line) {