bug-hello
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/2] hello: Mark print_help() not to return


From: Sami Kerola
Subject: [PATCH 1/2] hello: Mark print_help() not to return
Date: Sat, 11 Feb 2017 12:19:00 +0000

* bootstrap.conf: include stdnoreturn module.
* src/hello.c: mark print_help() not to return, and remove unreachable
  code.

Reference: https://www.gnu.org/software/gnulib/manual/html_node/
stdnoreturn_002eh.html
---
 bootstrap.conf |  1 +
 src/hello.c    | 10 +++++-----
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/bootstrap.conf b/bootstrap.conf
index 9e6b005..3f0cc1d 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -37,6 +37,7 @@ gnulib_modules="
     non-recursive-gnulib-prefix-hack
     progname
     readme-release
+    stdnoreturn
     update-copyright
     wchar
 "
diff --git a/src/hello.c b/src/hello.c
index 8e6cfbd..55edfa4 100644
--- a/src/hello.c
+++ b/src/hello.c
@@ -18,6 +18,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <config.h>
+#include <stdnoreturn.h>
+
 #include "system.h"
 #include "errno.h"
 #include "error.h"
@@ -25,7 +27,7 @@
 #include "xalloc.h"
 
 /* Forward declarations.  */
-static void print_help (FILE *out);
+static _Noreturn void print_help (FILE *restrict out);
 static void print_version (void);
 
 int
@@ -82,8 +84,6 @@ main (int argc, char *argv[])
        break;
       case OPT_HELP:
        print_help (stdout);
-       exit (EXIT_SUCCESS);
-       break;
       case 't':
        greeting_msg = _("hello, world");
        break;
@@ -117,8 +117,8 @@ main (int argc, char *argv[])
    several pieces to help translators be able to align different
    blocks and identify the various pieces.  */
 
-static void
-print_help (FILE *out)
+static _Noreturn void
+print_help (FILE *restrict out)
 {
   const char *lc_messages = setlocale (LC_MESSAGES, NULL);
   /* TRANSLATORS: --help output 1 (synopsis)
-- 
2.11.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]