]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
setarch: use errtryhelp()
authorRuediger Meier <ruediger.meier@ga-group.nl>
Wed, 21 Jun 2017 18:23:09 +0000 (20:23 +0200)
committerRuediger Meier <ruediger.meier@ga-group.nl>
Thu, 22 Jun 2017 19:34:47 +0000 (21:34 +0200)
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
sys-utils/setarch.c

index eb9cf21a09f3cf000e54b35a5d18bf8561b62802..b14dbea40814f4c24acd01b09f39aa66854f8366 100644 (file)
@@ -84,7 +84,7 @@
 
 static int archwrapper;
 
-static void __attribute__((__noreturn__)) show_help(void)
+static void __attribute__((__noreturn__)) usage(void)
 {
        fputs(USAGE_HEADER, stdout);
        if (!archwrapper)
@@ -121,17 +121,6 @@ static void __attribute__((__noreturn__)) show_help(void)
        exit(EXIT_SUCCESS);
 }
 
-static void __attribute__((__noreturn__)) show_usage(const char *s)
-{
-       if (s)
-               errx(EXIT_FAILURE,
-                    _("%s\nTry `%s --help' for more information."), s,
-                    program_invocation_short_name);
-       else
-               errx(EXIT_FAILURE, _("Try `%s --help' for more information."),
-                    program_invocation_short_name);
-}
-
 static void __attribute__((__noreturn__))
     show_version(void)
 {
@@ -301,9 +290,10 @@ int main(int argc, char *argv[])
        textdomain(PACKAGE);
        atexit(close_stdout);
 
-       if (argc < 1)
-               show_usage(_("Not enough arguments"));
-
+       if (argc < 1) {
+               warnx(_("Not enough arguments"));
+               errtryhelp(EXIT_FAILURE);
+       }
        archwrapper = strcmp(program_invocation_short_name, "setarch") != 0;
        if (archwrapper)
                arch = program_invocation_short_name;   /* symlinks to setarch */
@@ -328,7 +318,7 @@ int main(int argc, char *argv[])
        while ((c = getopt_long(argc, argv, "+hVv3BFILRSTXZ", longopts, NULL)) != -1) {
                switch (c) {
                case 'h':
-                       show_help();
+                       usage();
                        break;
                case 'V':
                        show_version();