-----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 <[EMAIL PROTECTED]>
* 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 [EMAIL PROTECTED]
-----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);
}