Project Info Name.......: gnu-hello
Description: GNU Hello


gnu-hello       
Info
Commit...:976cca6eb0ec9f60bf4b4f0f0176e638ce015784
Author...:Sami Kerola
Committer:Sami Kerola
Date.....:Sat Feb 11 11:51:43 2017 +0000
Parents..:ea0f8691df45880c536a04e42d3a7a46f21921ae

Message
hello: Mark print_help() not to return

* 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

Changes
diff --git a/bootstrap.conf b/bootstrap.conf
line changes: +1/-0
index 9e6b005..3f0cc1d
--- 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
line changes: +5/-5
index 8e6cfbd..55edfa4
--- 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)

This website is licensed under AGPL-3.0. Feel free to copy!