chiark / gitweb /
localectl: fix --help text
[elogind.git] / src / locale / localectl.c
index b3acb3ec456f4e97e4aa08b226ca76a3ca3875f3..ce31e1ffce9c97459cfe9db44090c317a1dc3d91 100644 (file)
@@ -384,15 +384,14 @@ static int add_locales_from_archive(Set *locales) {
 }
 
 static int add_locales_from_libdir (Set *locales) {
-        DIR *dir;
+        DIR _cleanup_closedir_ *dir;
         struct dirent *entry;
         int r;
 
         dir = opendir("/usr/lib/locale");
         if (!dir) {
                 log_error("Failed to open locale directory: %m");
-                r = -errno;
-                goto finish;
+                return -errno;
         }
 
         errno = 0;
@@ -406,10 +405,8 @@ static int add_locales_from_libdir (Set *locales) {
                         continue;
 
                 z = strdup(entry->d_name);
-                if (!z) {
-                        r = log_oom();
-                        goto finish;
-                }
+                if (!z)
+                        return log_oom();
 
                 r = set_put(locales, z);
                 if (r < 0) {
@@ -417,7 +414,7 @@ static int add_locales_from_libdir (Set *locales) {
 
                         if (r != -EEXIST) {
                                 log_error("Failed to add locale: %s", strerror(-r));
-                                goto finish;
+                                return r;
                         }
                 }
 
@@ -426,21 +423,15 @@ static int add_locales_from_libdir (Set *locales) {
 
         if (errno != 0) {
                 log_error("Failed to read locale directory: %m");
-                r = -errno;
-                goto finish;
+                return -errno;
         }
 
-        r = 0;
-
- finish:
-        closedir(dir);
-        return r;
+        return 0;
 }
 
 static int list_locales(DBusConnection *bus, char **args, unsigned n) {
-        Set *locales;
+        _cleanup_set_free_ Set *locales;
         _cleanup_strv_free_ char **l = NULL;
-        char **j;
         int r;
 
         locales = set_new(string_hash_func, string_compare_func);
@@ -449,31 +440,23 @@ static int list_locales(DBusConnection *bus, char **args, unsigned n) {
 
         r = add_locales_from_archive(locales);
         if (r < 0 && r != -ENOENT)
-                goto finish;
+                return r;
 
         r = add_locales_from_libdir(locales);
         if (r < 0)
-                goto finish;
+                return r;
 
         l = set_get_strv(locales);
-        if (!l) {
-                r = log_oom();
-                goto finish;
-        }
+        if (!l)
+                return log_oom();
 
         strv_sort(l);
 
         pager_open_if_enabled();
 
-        STRV_FOREACH(j, l)
-                puts(*j);
+        strv_print(l);
 
-        r = 0;
-
-finish:
-        set_free(locales);
-
-        return r;
+        return 0;
 }
 
 static int set_vconsole_keymap(DBusConnection *bus, char **args, unsigned n) {
@@ -554,7 +537,6 @@ static int nftw_cb(
 
 static int list_vconsole_keymaps(DBusConnection *bus, char **args, unsigned n) {
         char _cleanup_strv_free_ **l = NULL;
-        char **i;
 
         keymaps = set_new(string_hash_func, string_compare_func);
         if (!keymaps)
@@ -581,9 +563,7 @@ static int list_vconsole_keymaps(DBusConnection *bus, char **args, unsigned n) {
 
         pager_open_if_enabled();
 
-        STRV_FOREACH(i, l)
-                puts(*i);
-
+        strv_print(l);
 
         return 0;
 }
@@ -629,7 +609,7 @@ static int set_x11_keymap(DBusConnection *bus, char **args, unsigned n) {
 static int help(void) {
 
         printf("%s [OPTIONS...] COMMAND ...\n\n"
-               "Query or change system time and date settings.\n\n"
+               "Query or change system locale and keyboard settings.\n\n"
                "  -h --help              Show this help\n"
                "     --version           Show package version\n"
                "     --no-convert        Don't convert keyboard mappings\n"