more ATTNORETURN

A recent commit to alloc.c by Keni drew attention to the fact that
there are extern prototypes scattered around in various .c files.
Those can make use of ATTRNORETURN (non-gcc compilers and C23) the
same way the prototypes in extern.h can, and they were overlooked
when ATTRNORETURN was first added.
This commit is contained in:
nhmall
2023-01-12 15:38:15 -05:00
parent 1b4161c168
commit 6e136c6f7d
9 changed files with 26 additions and 22 deletions

View File

@@ -288,7 +288,7 @@ extern int alternative_palette(char *);
#endif #endif
#define nethack_enter(argc, argv) nethack_enter_windows() #define nethack_enter(argc, argv) nethack_enter_windows()
extern void nethack_exit(int) NORETURN; ATTRNORETURN extern void nethack_exit(int) NORETURN;
extern boolean file_exists(const char *); extern boolean file_exists(const char *);
extern boolean file_newer(const char *, const char *); extern boolean file_newer(const char *, const char *);
#ifndef SYSTEM_H #ifndef SYSTEM_H

View File

@@ -29,7 +29,7 @@ static void disclose(int, boolean);
static void get_valuables(struct obj *); static void get_valuables(struct obj *);
static void sort_valuables(struct valuable_data *, int); static void sort_valuables(struct valuable_data *, int);
static void artifact_score(struct obj *, boolean, winid); static void artifact_score(struct obj *, boolean, winid);
static void really_done(int) NORETURN; ATTRNORETURN static void really_done(int) NORETURN;
static void savelife(int); static void savelife(int);
static boolean should_query_disclose_option(int, char *); static boolean should_query_disclose_option(int, char *);
#ifdef DUMPLOG #ifdef DUMPLOG
@@ -38,7 +38,7 @@ static void dump_plines(void);
static void dump_everything(int, time_t); static void dump_everything(int, time_t);
#if defined(__BEOS__) || defined(MICRO) || defined(OS2) || defined(WIN32) #if defined(__BEOS__) || defined(MICRO) || defined(OS2) || defined(WIN32)
extern void nethack_exit(int) NORETURN; ATTRNORETURN extern void nethack_exit(int) NORETURN;
#else #else
#define nethack_exit exit #define nethack_exit exit
#endif #endif

View File

@@ -25,7 +25,7 @@
#endif #endif
#if defined(MICRO) || defined(OS2) #if defined(MICRO) || defined(OS2)
void nethack_exit(int) NORETURN; ATTRNORETURN void nethack_exit(int) NORETURN;
#else #else
#define nethack_exit exit #define nethack_exit exit
#endif #endif

View File

@@ -29,7 +29,7 @@
#endif #endif
#if defined(MICRO) || defined(OS2) #if defined(MICRO) || defined(OS2)
void nethack_exit(int) NORETURN; ATTRNORETURN void nethack_exit(int) NORETURN;
#else #else
#define nethack_exit exit #define nethack_exit exit
#endif #endif

View File

@@ -35,10 +35,10 @@ static void process_options(int, char **);
static void consume_arg(int, int *, char ***); static void consume_arg(int, int *, char ***);
static void consume_two_args(int, int *, char ***); static void consume_two_args(int, int *, char ***);
static void early_options(int *, char ***, char **); static void early_options(int *, char ***, char **);
static void opt_terminate(void) NORETURN; ATTRNORETURN static void opt_terminate(void) NORETURN;
static void opt_usage(const char *) NORETURN; ATTRNORETURN static void opt_usage(const char *) NORETURN;
static void opt_showpaths(const char *); static void opt_showpaths(const char *);
static void scores_only(int, char **, const char *) NORETURN; ATTRNORETURN static void scores_only(int, char **, const char *) NORETURN;
#ifdef _M_UNIX #ifdef _M_UNIX
extern void check_sco_console(void); extern void check_sco_console(void);
@@ -702,7 +702,7 @@ early_options(int *argc_p, char ***argv_p, char **hackdir_p)
/* for command-line options that perform some immediate action and then /* for command-line options that perform some immediate action and then
terminate the program without starting play, like 'nethack --version' terminate the program without starting play, like 'nethack --version'
or 'nethack -s Zelda'; do some cleanup before that termination */ or 'nethack -s Zelda'; do some cleanup before that termination */
static void ATTRNORETURN static void
opt_terminate(void) opt_terminate(void)
{ {
config_error_done(); /* free memory allocated by config_error_init() */ config_error_done(); /* free memory allocated by config_error_init() */
@@ -711,7 +711,7 @@ opt_terminate(void)
/*NOTREACHED*/ /*NOTREACHED*/
} }
static void ATTRNORETURN static void
opt_usage(const char *hackdir) opt_usage(const char *hackdir)
{ {
#ifdef CHDIR #ifdef CHDIR
@@ -744,7 +744,7 @@ opt_showpaths(const char *dir)
/* handle "-s <score options> [character-names]" to show all the entries /* handle "-s <score options> [character-names]" to show all the entries
in the high scores file ('record') belonging to particular characters; in the high scores file ('record') belonging to particular characters;
nethack will end after doing so without starting play */ nethack will end after doing so without starting play */
static void ATTRNORETURN static void
scores_only(int argc, char **argv, const char *dir) scores_only(int argc, char **argv, const char *dir)
{ {
/* do this now rather than waiting for final termination, in case there /* do this now rather than waiting for final termination, in case there

View File

@@ -27,7 +27,7 @@ char *translate_path_variables(const char *, char *);
char *exename(void); char *exename(void);
boolean fakeconsole(void); boolean fakeconsole(void);
void freefakeconsole(void); void freefakeconsole(void);
extern void nethack_exit(int) NORETURN; ATTRNORETURN extern void nethack_exit(int) NORETURN;
#if defined(MSWIN_GRAPHICS) #if defined(MSWIN_GRAPHICS)
extern void mswin_destroy_reg(void); extern void mswin_destroy_reg(void);
#endif #endif
@@ -454,6 +454,8 @@ extern const char *known_restrictions[]; /* symbols.c */
* WinMain exist, the resulting executable won't work correctly. * WinMain exist, the resulting executable won't work correctly.
*/ */
DISABLE_WARNING_UNREACHABLE_CODE
#if defined(__MINGW32__) && defined(MSWIN_GRAPHICS) #if defined(__MINGW32__) && defined(MSWIN_GRAPHICS)
#define MAIN mingw_main #define MAIN mingw_main
#else #else
@@ -735,6 +737,8 @@ attempt_restore:
return 0; return 0;
} }
RESTORE_WARNING_UNREACHABLE_CODE
static void static void
process_options(int argc, char * argv[]) process_options(int argc, char * argv[])
{ {

View File

@@ -14,8 +14,8 @@
#include <string.h> #include <string.h>
#endif #endif
static void xexit(int) NORETURN; ATTRNORETURN static void xexit(int) NORETURN;
extern void panic(const char *, ...) NORETURN; ATTRNORETURN extern void panic(const char *, ...) NORETURN;
char *eos(char *); /* also used by dlb.c */ char *eos(char *); /* also used by dlb.c */
FILE *fopen_datafile(const char *, const char *); FILE *fopen_datafile(const char *, const char *);
unsigned FITSuint_(unsigned long long, const char *, int); unsigned FITSuint_(unsigned long long, const char *, int);
@@ -33,8 +33,8 @@ extern boolean open_library(const char *, library *);
extern void close_library(library *); extern void close_library(library *);
static void Write(int, char *, long); static void Write(int, char *, long);
static void usage(void) NORETURN; ATTRNORETURN static void usage(void) NORETURN;
static void verbose_help(void) NORETURN; ATTRNORETURN static void verbose_help(void) NORETURN;
static void write_dlb_directory(int, int, libdir *, long, long, long); static void write_dlb_directory(int, int, libdir *, long, long, long);
static char default_progname[] = "dlb"; static char default_progname[] = "dlb";
@@ -78,7 +78,7 @@ static char origdir[255] = "";
* C dir chdir to dir (used ONCE, not like tar's -C) * C dir chdir to dir (used ONCE, not like tar's -C)
*/ */
static void ATTRNORETURN static void
usage(void) usage(void)
{ {
(void) printf("Usage: %s [ctxCIfv] arguments... [files...]\n", progname); (void) printf("Usage: %s [ctxCIfv] arguments... [files...]\n", progname);
@@ -88,7 +88,7 @@ usage(void)
/*NOTREACHED*/ /*NOTREACHED*/
} }
static void ATTRNORETURN static void
verbose_help(void) verbose_help(void)
{ {
static const char *const long_help[] = { static const char *const long_help[] = {
@@ -537,7 +537,7 @@ write_dlb_directory(int out, int nfiles, libdir *ld,
#endif /* DLBLIB */ #endif /* DLBLIB */
#endif /* DLB */ #endif /* DLB */
static void ATTRNORETURN static void
xexit(int retcd) xexit(int retcd)
{ {
#ifdef DLB #ifdef DLB

View File

@@ -179,9 +179,9 @@ unsigned FITSuint_(unsigned long long, const char *, int);
#include "../src/mdlib.c" #include "../src/mdlib.c"
static void makedefs_exit(int) NORETURN; ATTRNORETURN static void makedefs_exit(int) NORETURN;
static void ATTRNORETURN static void
makedefs_exit(int how) makedefs_exit(int how)
{ {
#if 0 /* makedefs doesn't need to do this */ #if 0 /* makedefs doesn't need to do this */

View File

@@ -53,7 +53,7 @@ Version _WIN_32IE Platform/IE
/*#define COMCTL_URL /*#define COMCTL_URL
* "http://www.microsoft.com/msdownload/ieplatform/ie/comctrlx86.asp"*/ * "http://www.microsoft.com/msdownload/ieplatform/ie/comctrlx86.asp"*/
extern void nethack_exit(int) NORETURN; ATTRNORETURN extern void nethack_exit(int) NORETURN;
static TCHAR *_get_cmd_arg(TCHAR *pCmdLine); static TCHAR *_get_cmd_arg(TCHAR *pCmdLine);
static HRESULT GetComCtlVersion(LPDWORD pdwMajor, LPDWORD pdwMinor); static HRESULT GetComCtlVersion(LPDWORD pdwMajor, LPDWORD pdwMinor);
BOOL WINAPI BOOL WINAPI