bug-hello
[Top][All Lists]
Advanced

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

Re: yet another hello pretest


From: Eric Blake
Subject: Re: yet another hello pretest
Date: Thu, 09 Nov 2006 06:33:05 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.7) Gecko/20060909 Thunderbird/1.5.0.7 Mnenhy/0.7.4.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Karl Berry on 11/8/2006 5:55 PM:
> In case anyone is not totally bored already, one more time for gettext
> 0.16 (thanks Bruno)...
> ftp://alpha.gnu.org/gnu/hello/hello-2.1.95.tar.bz2 (or .gz)

Alas, it fails to build with 'gcc -Wall -Werror', because you didn't mark
my_exit with __attribute__((noreturn)):

if gcc -DLOCALEDIR=\"/usr/local/share/locale\" -DHAVE_CONFIG_H -I. -I.
- -I..  -I../gnulib/lib -I../gnulib/lib -I/usr/local/include  -g2 -Wall
- -Werror -MT hello.o -MD -MP -MF ".deps/hello.Tpo" -c -o hello.o hello.c; \
        then mv -f ".deps/hello.Tpo" ".deps/hello.Po"; else rm -f
".deps/hello.Tpo"; exit 1; fi
hello.c: In function `main':
hello.c:119: warning: control reaches end of non-void function

Not to mention you used exit (1), instead of the nicer exit
(EXIT_FAILURE).  This patch doesn't show it, but you may want to pull in
the gnulib module exit, to ensure the existence of EXIT_SUCCESS.  I don't
know if using the gnulib atexit module is necessary any more; the last
Solaris release that didn't support atexit has already passed end-of-life.
 Attached is a patch for hello.c.

Also, you may want to get rid of the space-tab formatting errors in your
ChangeLog.

2006-11-09  Eric Blake  <address@hidden>

        * hello.c (main): Use atexit, to avoid warning with 'gcc -Wall
        -Werror'.
        (my_exit): Delete, no longer needed.

- --
Life is short - so eat dessert first!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFUy4R84KuGfSFAYARAlyvAJ9SA43+2/V2YdVNDR9D3uRTINmTpgCfXT1m
XQy3JeNaKsaEvRUvAq1jRXM=
=h3Ef
-----END PGP SIGNATURE-----
--- src/hello.c.orig    2006-11-09 06:20:41.062500000 -0700
+++ src/hello.c 2006-11-09 06:28:09.203125000 -0700
@@ -33,7 +33,6 @@ static const struct option longopts[] =
   { NULL, 0, NULL, 0 }
 };
 
-static void my_exit (void);
 static void print_help (void);
 static void print_version (void);
 
@@ -55,20 +54,27 @@ main (int argc, char *argv[])
   textdomain (PACKAGE);
 #endif
 
+  /* Even exiting has subtleties.  The /dev/full device on GNU/Linux
+     can be used for testing whether writes are checked properly.  For
+     instance, hello >/dev/null should exit unsuccessfully.  On exit,
+     if any writes failed, change the exit status.  This is
+     implemented in the Gnulib module "closeout".  */
+  atexit (close_stdout);
+
   while ((optc = getopt_long (argc, argv, "g:hntv", longopts, NULL)) != -1)
     switch (optc)
       {
       /* One goal here is having --help and --version exit immediately.  */
       case 'v':
         print_version ();
-        my_exit ();
+        exit (EXIT_SUCCESS);
         break;
       case 'g':
         greeting = optarg;
         break;
       case 'h':
         print_help ();
-        my_exit ();
+        exit (EXIT_SUCCESS);
         break;
       case 'n':
         n = 1;
@@ -88,7 +94,7 @@ main (int argc, char *argv[])
         fputs (_("Too many arguments\n"), stderr);
       fprintf (stderr, _("Try `%s --help' for more information.\n"),
                program_name);
-      exit (1);
+      exit (EXIT_FAILURE);
     }
 
   /* Print greeting message and exit. */
@@ -115,24 +121,7 @@ main (int argc, char *argv[])
       puts (greeting);
     }
 
-  my_exit ();
-}
-
-
-
-/* Even exiting has subtleties.  The /dev/full device on GNU/Linux can
-   be used for testing whether writes are checked properly.  For instance,
-   hello >/dev/null should exit unsuccessfully.  */
-
-static void
-my_exit (void)
-{
-  /* Exit unsuccessfully if the write failed.  This is implemented in
-     the Gnulib module "closeout".  */
-  close_stdout ();
-
-  /* Otherwise, exit successfully.  */
-  exit (0);
+  exit (EXIT_SUCCESS);
 }
 
 

reply via email to

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