From 3bd3681e0fbddf82ca7fa12af67cf139fe1e6379 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Thu, 9 Nov 2017 20:13:47 -0800 Subject: [PATCH] maint: use noreturn, not ATTRIBUTE_NORETURN Use gnulib's stdnoreturn module so we can include 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 | 1 + gzip.c | 4 ++-- gzip.h | 15 ++++++--------- lib/.gitignore | 1 + m4/.gitignore | 1 + 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/bootstrap.conf b/bootstrap.conf index b973839..e44837f 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -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 637b791..59ab553 100644 --- 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 76abd51..23a1cb8 100644 --- a/gzip.h +++ b/gzip.h @@ -31,10 +31,6 @@ # 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 /* for off_t */ #include #include +#include #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); diff --git a/lib/.gitignore b/lib/.gitignore index 4df1a38..6b1ea36 100644 --- a/lib/.gitignore +++ b/lib/.gitignore @@ -219,3 +219,4 @@ /xsize.h /yesno.c /yesno.h +/stdnoreturn.in.h diff --git a/m4/.gitignore b/m4/.gitignore index 2aecca5..5ce3776 100644 --- a/m4/.gitignore +++ b/m4/.gitignore @@ -150,3 +150,4 @@ /yesno.m4 /host-cpu-c-abi.m4 /year2038.m4 +/stdnoreturn.m4 -- 2.47.2