chiark / gitweb /
pam: externally our booleans are ints, not unsigneds
[elogind.git] / src / hostname / hostnamectl.c
index 8d8dc3d7f357e73a24def4fe363f08f28c45d168..af428179144cea540b87acf2160961b10cb3bb29 100644 (file)
@@ -142,12 +142,12 @@ static int show_one_name(sd_bus *bus, const char* attr) {
 
 static int show_all_names(sd_bus *bus) {
         StatusInfo info = {};
-        const struct bus_properties_map map[]  = {
-                { "s",  "Hostname",       &info.hostname },
-                { "s",  "StaticHostname", &info.static_hostname },
-                { "s",  "PrettyHostname", &info.pretty_hostname },
-                { "s",  "IconName",       &info.icon_name },
-                { "s",  "Chassis",        &info.chassis },
+        static const struct bus_properties_map map[]  = {
+                { "Hostname",       "s", NULL, offsetof(StatusInfo, hostname) },
+                { "StaticHostname", "s", NULL, offsetof(StatusInfo, static_hostname) },
+                { "PrettyHostname", "s", NULL, offsetof(StatusInfo, pretty_hostname) },
+                { "IconName",       "s", NULL, offsetof(StatusInfo, icon_name) },
+                { "Chassis",        "s", NULL, offsetof(StatusInfo, chassis) },
                 {}
         };
         int r;
@@ -155,7 +155,8 @@ static int show_all_names(sd_bus *bus) {
         r = bus_map_all_properties(bus,
                                    "org.freedesktop.hostname1",
                                    "/org/freedesktop/hostname1",
-                                   map);
+                                   map,
+                                   &info);
         if (r < 0)
                 goto fail;
 
@@ -313,13 +314,13 @@ static int parse_argv(int argc, char *argv[]) {
         static const struct option options[] = {
                 { "help",            no_argument,       NULL, 'h'                 },
                 { "version",         no_argument,       NULL, ARG_VERSION         },
-                { "transient",       no_argument,       NULL, ARG_TRANSIENT   },
-                { "static",          no_argument,       NULL, ARG_STATIC      },
-                { "pretty",          no_argument,       NULL, ARG_PRETTY      },
+                { "transient",       no_argument,       NULL, ARG_TRANSIENT       },
+                { "static",          no_argument,       NULL, ARG_STATIC          },
+                { "pretty",          no_argument,       NULL, ARG_PRETTY          },
                 { "host",            required_argument, NULL, 'H'                 },
                 { "machine",         required_argument, NULL, 'M'                 },
                 { "no-ask-password", no_argument,       NULL, ARG_NO_ASK_PASSWORD },
-                { NULL,              0,                 NULL, 0                   }
+                {}
         };
 
         int c;
@@ -332,8 +333,7 @@ static int parse_argv(int argc, char *argv[]) {
                 switch (c) {
 
                 case 'h':
-                        help();
-                        return 0;
+                        return help();
 
                 case ARG_VERSION:
                         puts(PACKAGE_STRING);
@@ -370,8 +370,7 @@ static int parse_argv(int argc, char *argv[]) {
                         return -EINVAL;
 
                 default:
-                        log_error("Unknown option code %c", c);
-                        return -EINVAL;
+                        assert_not_reached("Unhandled option");
                 }
         }
 
@@ -457,8 +456,8 @@ static int hostnamectl_main(sd_bus *bus, int argc, char *argv[]) {
 }
 
 int main(int argc, char *argv[]) {
-        int r;
         _cleanup_bus_unref_ sd_bus *bus = NULL;
+        int r;
 
         setlocale(LC_ALL, "");
         log_parse_environment();