maint: use noreturn, not ATTRIBUTE_NORETURN
authorJim Meyering <meyering@fb.com>
Fri, 10 Nov 2017 04:13:47 +0000 (20:13 -0800)
committerJim Meyering <meyering@fb.com>
Fri, 10 Nov 2017 04:46:03 +0000 (20:46 -0800)
Use gnulib's stdnoreturn module so we can include
<stdnoreturn.h> and the "noreturn" helper macro, thus
replacing the definition and uses of ATTRIBUTE_NORETURN.
* bootstrap.conf (gnulib_modules): Add stdnoreturn.
* gzip.h (ATTRIBUTE_NORETURN): Remove definition.
Include stdnoreturn.h and use "noreturn" for each
ATTRIBUTE_NORETURN-adorned function declaration.
* gzip.c (do_exit, try_help): Use "noreturn".

bootstrap.conf
gzip.c
gzip.h
lib/.gitignore
m4/.gitignore

index b973839645793f36579e4fe6e096b57c7408dfdf..e44837faeba848f443fe2d416f185154f31860a2 100644 (file)
@@ -53,6 +53,7 @@ readme-release
 realloc-gnu
 savedir
 stat-time
+stdnoreturn
 sys_stat
 time
 unistd-safer
diff --git a/gzip.c b/gzip.c
index 637b7913ec9e5d7fa18a822846fa07ab2bc3be07..59ab553e448a157a267dcf2cd9eaf84d9f2ac903 100644 (file)
--- a/gzip.c
+++ b/gzip.c
@@ -305,7 +305,7 @@ static const struct option longopts[] =
 
 /* local functions */
 
-local void try_help     (void) ATTRIBUTE_NORETURN;
+local noreturn void try_help (void);
 local void help         (void);
 local void license      (void);
 local void version      (void);
@@ -325,7 +325,7 @@ local void copy_stat    (struct stat *ifstat);
 local void install_signal_handlers (void);
 local void remove_output_file (void);
 local RETSIGTYPE abort_gzip_signal (int);
-local void do_exit      (int exitcode) ATTRIBUTE_NORETURN;
+local noreturn void do_exit (int exitcode);
 static void finish_out (void);
       int main          (int argc, char **argv);
 static int (*work) (int infile, int outfile) = zip; /* function to call */
diff --git a/gzip.h b/gzip.h
index 76abd51949a57fb7c03c9fa4204a81dcc34bd378..23a1cb85e8c5620843a75806a6b27355eec34881 100644 (file)
--- a/gzip.h
+++ b/gzip.h
 # endif
 #endif
 
-#ifndef ATTRIBUTE_NORETURN
-# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
-#endif
-
 /* I don't like nested includes, but the following headers are used
  * too often
  */
@@ -42,6 +38,7 @@
 #include <sys/types.h> /* for off_t */
 #include <time.h>
 #include <string.h>
+#include <stdnoreturn.h>
 #define memzero(s, n) memset ((voidp)(s), 0, (n))
 
 #ifndef RETSIGTYPE
@@ -279,7 +276,7 @@ extern int unpack     (int in, int out);
 extern int unlzh      (int in, int out);
 
         /* in gzip.c */
-extern void abort_gzip (void) ATTRIBUTE_NORETURN;
+extern noreturn void abort_gzip (void);
 
         /* in deflate.c */
 extern void lm_init (int pack_level, ush *flags);
@@ -312,11 +309,11 @@ extern char *gzip_base_name (char *fname) _GL_ATTRIBUTE_PURE;
 extern int xunlink        (char *fname);
 extern void make_simple_name (char *name);
 extern char *add_envopt   (int *argcp, char ***argvp, char const *env);
-extern void gzip_error    (char const *m) ATTRIBUTE_NORETURN;
-extern void xalloc_die    (void) ATTRIBUTE_NORETURN;
+extern noreturn void gzip_error    (char const *m);
+extern noreturn void xalloc_die    (void);
 extern void warning       (char const *m);
-extern void read_error    (void) ATTRIBUTE_NORETURN;
-extern void write_error   (void) ATTRIBUTE_NORETURN;
+extern noreturn void read_error    (void);
+extern noreturn void write_error   (void);
 extern void display_ratio (off_t num, off_t den, FILE *file);
 extern void fprint_off    (FILE *, off_t, int);
 
index 4df1a38dda3cb12144de10665ceb234b7d94f923..6b1ea36ba62f469d604faf71fbb57bd0151e4c11 100644 (file)
 /xsize.h
 /yesno.c
 /yesno.h
+/stdnoreturn.in.h
index 2aecca59e54db184bae4ed01103c70608a28b282..5ce37763bb51a4e6bc94b7532178eb450a408c0c 100644 (file)
 /yesno.m4
 /host-cpu-c-abi.m4
 /year2038.m4
+/stdnoreturn.m4