chiark / gitweb /
core: unify how we create the notify and private dbus socket
[elogind.git] / src / boot / bootctl.c
index bdefd57dfc8e860cd8f61f5edb55cffa078d2c34..51b51c4254cf34ecd13fe933b47270ade7f1661b 100644 (file)
 #include "util.h"
 #include "utf8.h"
 
-static int help(void) {
+static void help(void) {
         printf("%s [OPTIONS...] COMMAND ...\n\n"
-               "Query or change firmware and boot mananger settings.\n\n"
+               "Query or change firmware and boot manager settings.\n\n"
                "  -h --help              Show this help\n"
                "     --version           Show package version\n"
                "Commands:\n"
-               "  status                 Show current time settings\n",
-               program_invocation_short_name);
-
-        return 0;
+               "  status                 Show current boot settings\n"
+               , program_invocation_short_name);
 }
 
 static int parse_argv(int argc, char *argv[]) {
@@ -50,16 +48,17 @@ static int parse_argv(int argc, char *argv[]) {
         };
 
         static const struct option options[] = {
-                { "help",                no_argument,       NULL, 'h'                     },
-                { "version",             no_argument,       NULL, ARG_VERSION             },
-                { NULL,                  0,                 NULL, 0                       }
+                { "help",        no_argument, NULL, 'h'          },
+                { "version",     no_argument, NULL, ARG_VERSION  },
+                {}
         };
 
         int c;
 
         assert(argc >= 0);
         assert(argv);
-        while ((c = getopt_long(argc, argv, "+hH:P", options, NULL)) >= 0) {
+
+        while ((c = getopt_long(argc, argv, "h", options, NULL)) >= 0)
 
                 switch (c) {
 
@@ -76,10 +75,8 @@ 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");
                 }
-        }
 
         return 1;
 }
@@ -158,10 +155,10 @@ static int show_status(char **args, unsigned n) {
                 printf("Selected Firmware Entry:\n");
                 printf("        Title: %s\n", strna(info->fw_entries[info->fw_entry_active].title));
                 if (!sd_id128_equal(info->fw_entries[info->fw_entry_active].part_uuid, SD_ID128_NULL))
-                        printf("          ESP: /dev/disk/by-partuuid/%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\n",
+                        printf("    Partition: /dev/disk/by-partuuid/%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\n",
                                SD_ID128_FORMAT_VAL(info->fw_entries[info->fw_entry_active].part_uuid));
                 else
-                        printf("          ESP: n/a\n");
+                        printf("    Partition: n/a\n");
                 if (info->fw_entries[info->fw_entry_active].path)
                         printf("         File: %s%s\n", draw_special_char(DRAW_TREE_RIGHT), info->fw_entries[info->fw_entry_active].path);
         }
@@ -171,10 +168,10 @@ static int show_status(char **args, unsigned n) {
                 printf("Boot Loader:\n");
                 printf("      Product: %s\n", info->loader);
                 if (!sd_id128_equal(info->loader_part_uuid, SD_ID128_NULL))
-                        printf("          ESP: /dev/disk/by-partuuid/%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\n",
+                        printf("    Partition: /dev/disk/by-partuuid/%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\n",
                                SD_ID128_FORMAT_VAL(info->loader_part_uuid));
                         else
-                                printf("          ESP: n/a\n");
+                                printf("    Partition: n/a\n");
                 printf("         File: %s%s\n", draw_special_char(DRAW_TREE_RIGHT), strna(info->loader_image_path));
                 printf("\n");
 
@@ -268,21 +265,17 @@ static int bootctl_main(int argc, char *argv[]) {
 }
 
 int main(int argc, char *argv[]) {
-        int r, retval = EXIT_FAILURE;
+        int r;
 
         log_parse_environment();
         log_open();
 
         r = parse_argv(argc, argv);
-        if (r < 0)
-                goto finish;
-        else if (r == 0) {
-                retval = EXIT_SUCCESS;
+        if (r <= 0)
                 goto finish;
-        }
 
         r = bootctl_main(argc, argv);
-        retval = r < 0 ? EXIT_FAILURE : r;
-finish:
-        return retval;
+
+ finish:
+        return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
 }