chiark / gitweb /
clients: various simplifications
[elogind.git] / src / locale / localectl.c
index fb21bfd7f76726c07728ae1742de605d792f9dde..c70470fe0070ef99241d9bebca1c25f3f4c33e77 100644 (file)
@@ -104,15 +104,15 @@ static void print_status_info(StatusInfo *i) {
 
 static int show_status(sd_bus *bus, char **args, unsigned n) {
         StatusInfo info = {};
-        const struct bus_properties_map map[]  = {
-                { "s",  "VConsoleKeymap",       &info.vconsole_keymap },
-                { "s",  "VConsoleKeymap",       &info.vconsole_keymap },
-                { "s",  "VConsoleKeymapToggle", &info.vconsole_keymap_toggle},
-                { "s",  "X11Layout",            &info.x11_layout },
-                { "s",  "X11Model",             &info.x11_model },
-                { "s",  "X11Variant",           &info.x11_variant },
-                { "s",  "X11Options",           &info.x11_options },
-                { "as", "Locale",               &info.locale },
+        static const struct bus_properties_map map[]  = {
+                { "VConsoleKeymap",       "s",  NULL, offsetof(StatusInfo, vconsole_keymap) },
+                { "VConsoleKeymap",       "s",  NULL, offsetof(StatusInfo, vconsole_keymap) },
+                { "VConsoleKeymapToggle", "s",  NULL, offsetof(StatusInfo, vconsole_keymap_toggle) },
+                { "X11Layout",            "s",  NULL, offsetof(StatusInfo, x11_layout) },
+                { "X11Model",             "s",  NULL, offsetof(StatusInfo, x11_model) },
+                { "X11Variant",           "s",  NULL, offsetof(StatusInfo, x11_variant) },
+                { "X11Options",           "s",  NULL, offsetof(StatusInfo, x11_options) },
+                { "Locale",               "as", NULL, offsetof(StatusInfo, locale) },
                 {}
         };
         int r;
@@ -122,7 +122,8 @@ static int show_status(sd_bus *bus, char **args, unsigned n) {
         r = bus_map_all_properties(bus,
                                    "org.freedesktop.locale1",
                                    "/org/freedesktop/locale1",
-                                   map);
+                                   map,
+                                   &info);
         if (r < 0)
                 goto fail;
 
@@ -793,33 +794,27 @@ static int localectl_main(sd_bus *bus, int argc, char *argv[]) {
 }
 
 int main(int argc, char*argv[]) {
-        int r, ret = EXIT_FAILURE;
         _cleanup_bus_unref_ sd_bus *bus = NULL;
+        int r;
 
         setlocale(LC_ALL, "");
         log_parse_environment();
         log_open();
 
         r = parse_argv(argc, argv);
-        if (r < 0)
+        if (r <= 0)
                 goto finish;
-        else if (r == 0) {
-                ret = EXIT_SUCCESS;
-                goto finish;
-        }
 
         r = bus_open_transport(arg_transport, arg_host, false, &bus);
         if (r < 0) {
                 log_error("Failed to create bus connection: %s", strerror(-r));
-                ret = EXIT_FAILURE;
                 goto finish;
         }
 
         r = localectl_main(bus, argc, argv);
-        ret = r < 0 ? EXIT_FAILURE : r;
 
 finish:
         pager_close();
 
-        return ret;
+        return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
 }