From 09ac707a1c3554762b92d3bd2355bcf33bde72f4 Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Thu, 28 Dec 2017 22:57:41 +0100 Subject: [PATCH] Add __attribute__((__noreturn__)) to various function prototypes in games/. This general cleanup is useful in various ways. It helps the compiler optimize better and it also helps later GCCs detect better when to give -Wimplicit-fallthrough warnings and when not. Found-with: -Wsuggest-attribute=noreturn --- games/adventure/hdr.h | 5 ++--- games/arithmetic/arithmetic.c | 4 ++-- games/atc/extern.h | 4 ++-- games/backgammon/common_source/back.h | 4 ++-- games/backgammon/teachgammon/tutor.h | 6 ++++-- games/battlestar/externs.h | 5 ++--- games/cribbage/cribbage.h | 3 +-- games/hack/hack.h | 11 +++++------ games/hangman/hangman.h | 2 +- games/hunt/hunt/client.h | 5 ++--- games/hunt/huntd/server.h | 3 +-- games/larn/header.h | 3 +-- games/mille/mille.c | 3 +-- games/mille/mille.h | 3 +-- games/number/number.c | 2 +- games/phantasia/io.c | 2 +- games/phantasia/setup.c | 3 +-- games/pig/pig.c | 2 +- games/quiz/quiz.c | 4 ++-- games/robots/robots.h | 2 +- games/rogue/rogue.h | 12 ++++++------ games/sail/externs.h | 8 ++++---- games/tetris/tetris.c | 2 +- games/tetris/tetris.h | 2 +- games/trek/trek.h | 8 ++++---- games/worm/worm.c | 4 ++-- games/worms/worms.c | 2 +- games/wump/wump.c | 2 +- 28 files changed, 54 insertions(+), 62 deletions(-) diff --git a/games/adventure/hdr.h b/games/adventure/hdr.h index 9f2f96475d..740141f3bf 100644 --- a/games/adventure/hdr.h +++ b/games/adventure/hdr.h @@ -50,7 +50,6 @@ * . * * $FreeBSD: src/games/adventure/hdr.h,v 1.5.2.1 2001/03/05 11:43:11 kris Exp $ - * $DragonFly: src/games/adventure/hdr.h,v 1.3 2004/09/12 17:19:58 dillon Exp $ */ /* hdr.h: included by c advent files */ @@ -157,7 +156,7 @@ int abbnum, bonus, clock1, clock2, closed, /* various flags and counters */ int demo, limit; int at(int objj); -int bug(int n); +int bug(int n) __dead2; void carry(int, int); void caveclose(void); void checkhints(void); @@ -169,7 +168,7 @@ int dark(void); void datime(int *d, int *t); char *decr(const char *, const char *, const char *, const char *, const char *); void die(int entry); -void done(int entry); +void done(int entry) __dead2; void drop(int object, int where); void dstroy(int); int fdwarf(void); diff --git a/games/arithmetic/arithmetic.c b/games/arithmetic/arithmetic.c index 3089ed7dcb..5eba4cc297 100644 --- a/games/arithmetic/arithmetic.c +++ b/games/arithmetic/arithmetic.c @@ -72,12 +72,12 @@ #include static int getrandom(int, int, int); -static void intr(int); +static void intr(int) __dead2; static int opnum(int); static void penalise(int, int, int); static int problem(void); static void showstats(void); -static void usage(void); +static void usage(void) __dead2; static const char keylist[] = "+-x/"; static const char defaultkeys[] = "+-"; diff --git a/games/atc/extern.h b/games/atc/extern.h index 6f0909b1cb..246f499e6e 100644 --- a/games/atc/extern.h +++ b/games/atc/extern.h @@ -67,7 +67,7 @@ extern void ioclrtobot(void); extern void ioclrtoeol(int); extern void ioerror(int, int, const char *); extern void iomove(int); -extern void loser(const PLANE *, const char *); +extern void loser(const PLANE *, const char *) __dead2; extern void planewin(void); extern void redraw(void); extern void setup_screen(const C_SCREEN *); @@ -81,7 +81,7 @@ extern void delete(LIST *, PLANE *); extern PLANE *newplane(void); /* log.c */ extern int log_score(int); -extern void log_score_quit(int); +extern void log_score_quit(int) __dead2; extern void open_score_file(void); /* update.c */ extern int addplane(void); diff --git a/games/backgammon/common_source/back.h b/games/backgammon/common_source/back.h index 3b64c596c9..84c8744cdc 100644 --- a/games/backgammon/common_source/back.h +++ b/games/backgammon/common_source/back.h @@ -134,7 +134,7 @@ int count(void); void curmove(int, int); void dble(void); int dblgood(void); -void errexit(const char *); +void errexit(const char *) __dead2; void fancyc(char); void fboard(void); void fixtty(int); @@ -142,7 +142,7 @@ int freemen(int); void getarg(int, char **); int getcaps(const char *); void getmove(void); -void getout(int); /* function to exit backgammon cleanly */ +void getout(int) __dead2; /* function to exit backgammon cleanly */ void gwrite(void); void init(void); int makmove(int); diff --git a/games/backgammon/teachgammon/tutor.h b/games/backgammon/teachgammon/tutor.h index 2fb0b47f88..1912204c11 100644 --- a/games/backgammon/teachgammon/tutor.h +++ b/games/backgammon/teachgammon/tutor.h @@ -29,8 +29,10 @@ * @(#)tutor.h 8.1 (Berkeley) 5/31/93 */ -void leave(void); -void tutor(void); +#include + +void leave(void) __dead2; +void tutor(void) __dead2; struct situatn { int brd[26]; diff --git a/games/battlestar/externs.h b/games/battlestar/externs.h index aed0b4a8ba..a994d8a8a2 100644 --- a/games/battlestar/externs.h +++ b/games/battlestar/externs.h @@ -29,7 +29,6 @@ * @(#)externs.h 8.1 (Berkeley) 5/31/93 * * $FreeBSD: src/games/battlestar/externs.h,v 1.9.2.1 2001/03/05 11:45:36 kris Exp $ - * $DragonFly: src/games/battlestar/externs.h,v 1.4 2006/08/08 16:47:20 pavalos Exp $ */ #include @@ -313,7 +312,7 @@ int card(const char *, int); void chime(void); void crash(void); int cypher(void); -void die(int); +void die(int) __dead2; void dig(void); int draw(void); void drink(void); @@ -331,7 +330,7 @@ void kiss(void); int land(void); int launch(void); void light(void); -void live(void); +void live(void) __dead2; void love(void); void murder(void); void news(void); diff --git a/games/cribbage/cribbage.h b/games/cribbage/cribbage.h index 44b97b1cdf..2b5682bddb 100644 --- a/games/cribbage/cribbage.h +++ b/games/cribbage/cribbage.h @@ -27,7 +27,6 @@ * SUCH DAMAGE. * * @(#)cribbage.h 8.1 (Berkeley) 5/31/93 - * $DragonFly: src/games/cribbage/cribbage.h,v 1.3 2005/08/03 13:31:00 eirikn Exp $ */ @@ -71,7 +70,7 @@ char *get_line(void); int getuchar(void); int infrom(CARD [], int, const char *); void instructions(void); -void intr(int); +void intr(int) __dead2; bool isone(CARD, CARD [], int); void makedeck(CARD []); void makeknown(CARD [], int); diff --git a/games/hack/hack.h b/games/hack/hack.h index f87538748e..7358dfc42c 100644 --- a/games/hack/hack.h +++ b/games/hack/hack.h @@ -1,6 +1,5 @@ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* hack.h - version 1.0.3 */ -/* $DragonFly: src/games/hack/hack.h,v 1.4 2006/08/21 19:45:32 pavalos Exp $ */ #include "config.h" #include @@ -272,7 +271,7 @@ void done_in_by(struct monst *); void done(const char *); void clearlocks(void); #ifdef NOSAVEONHANGUP -void hangup(int); +void hangup(int) __dead2; #endif char *eos(char *); void charcat(char *, char); @@ -461,7 +460,7 @@ void atl(int, int, char); void on_scr(int, int); void tmp_at(schar, schar); void Tmp_at(schar, schar); -void setclipped(void); +void setclipped(void) __dead2; void at(xchar, xchar, char); void prme(void); int doredraw(void); @@ -505,7 +504,7 @@ void outrumor(void); /* hack.save.c */ int dosave(void); #ifndef NOSAVEONHANGUP -void hangup(int); +void hangup(int) __dead2; #endif bool dorecover(int); struct obj *restobjchn(int); @@ -616,14 +615,14 @@ void drown(void); void gettty(void); void settty(const char *); void setftty(void); -void error(const char *, ...) __printflike(1, 2); +void error(const char *, ...) __printflike(1, 2) __dead2; void getlin(char *); void getret(void); void cgetret(const char *); void xwaitforspace(const char *); char *parse(void); char readchar(void); -void end_of_input(void); +void end_of_input(void) __dead2; /* hack.u_init.c */ void u_init(void); diff --git a/games/hangman/hangman.h b/games/hangman/hangman.h index 4aba72cf93..680862a3ea 100644 --- a/games/hangman/hangman.h +++ b/games/hangman/hangman.h @@ -91,7 +91,7 @@ extern int syms; extern int symfd; extern off_t symoffs, symsize; -void die(int); +void die(int) __dead2; void endgame(void); void getguess(void); void getword(void); diff --git a/games/hunt/hunt/client.h b/games/hunt/hunt/client.h index c8abf70059..695806ac0c 100644 --- a/games/hunt/hunt/client.h +++ b/games/hunt/hunt/client.h @@ -29,7 +29,6 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $OpenBSD: client.h,v 1.4 2003/06/17 00:44:21 pjanzen Exp $ - * $DragonFly: src/games/hunt/hunt/client.h,v 1.1 2008/09/02 21:50:20 dillon Exp $ */ /* hunt.c */ @@ -39,8 +38,8 @@ extern char * Send_message; /* -w message */ extern int Socket; /* connection to server */ extern char map_key[256]; /* HUNT envvar */ -void bad_con(void); -void bad_ver(void); +void bad_con(void) __dead2; +void bad_ver(void) __dead2; void intr(int); /* connect.c */ diff --git a/games/hunt/huntd/server.h b/games/hunt/huntd/server.h index 785606ec78..77322262d5 100644 --- a/games/hunt/huntd/server.h +++ b/games/hunt/huntd/server.h @@ -30,7 +30,6 @@ * * $OpenBSD: server.h,v 1.9 2004/01/16 00:13:19 espie Exp $ * $NetBSD: hunt.h,v 1.5 1998/09/13 15:27:28 hubertf Exp $ - * $DragonFly: src/games/hunt/huntd/server.h,v 1.1 2008/09/02 21:50:21 dillon Exp $ */ @@ -233,7 +232,7 @@ void message(PLAYER *, const char *); /* driver.c */ int rand_num(int); void checkdam(PLAYER *, PLAYER *, IDENT *, int, char); -void cleanup(int); +void cleanup(int) __dead2; /* execute.c */ void mon_execute(PLAYER *); diff --git a/games/larn/header.h b/games/larn/header.h index 5516aa1761..153713b569 100644 --- a/games/larn/header.h +++ b/games/larn/header.h @@ -1,5 +1,4 @@ /* header.h Larn is copyrighted 1986 by Noah Morgan. */ -/* $DragonFly: src/games/larn/header.h,v 1.5 2006/08/26 17:05:05 pavalos Exp $ */ #include #include @@ -357,7 +356,7 @@ extern struct _itm itm_[]; extern const char *potionhide[], *potionname[], *scrollhide[], *scrollname[]; /* bill.c */ -void mailbill(void); +void mailbill(void) __dead2; /* create.c */ void makeplayer(void); diff --git a/games/mille/mille.c b/games/mille/mille.c index ce936a015a..2fb4e95309 100644 --- a/games/mille/mille.c +++ b/games/mille/mille.c @@ -27,7 +27,6 @@ * SUCH DAMAGE. * * $FreeBSD: src/games/mille/mille.c,v 1.10 1999/12/12 06:17:24 billf Exp $ - * $DragonFly: src/games/mille/mille.c,v 1.5 2006/08/27 17:17:23 pavalos Exp $ * * @(#) Copyright (c) 1982, 1993 The Regents of the University of California. All rights reserved. * @(#)mille.c 8.1 (Berkeley) 5/31/93 @@ -42,7 +41,7 @@ * @(#)mille.c 1.3 (Berkeley) 5/10/83 */ -static void usage (void); +static void usage (void) __dead2; int main(int ac, char *av[]) diff --git a/games/mille/mille.h b/games/mille/mille.h index 4e7ffcb26f..9e83a28b8d 100644 --- a/games/mille/mille.h +++ b/games/mille/mille.h @@ -29,7 +29,6 @@ * @(#)mille.h 8.1 (Berkeley) 5/31/93 * * $FreeBSD: src/games/mille/mille.h,v 1.7 1999/12/12 06:17:24 billf Exp $ - * $DragonFly: src/games/mille/mille.h,v 1.6 2006/08/27 17:17:23 pavalos Exp $ */ #include @@ -220,7 +219,7 @@ void calcmove(void); bool canplay(PLAY *, PLAY *, CARD); bool check_ext(bool); void check_more(void); -void die(int); +void die(int) __dead2; void domove(void); bool error(const char *, ...); #ifdef EXTRAP diff --git a/games/number/number.c b/games/number/number.c index 14fcb7d4ed..967491162b 100644 --- a/games/number/number.c +++ b/games/number/number.c @@ -68,7 +68,7 @@ static void convert(char *); static int number(char *, int); static void pfract(int); static int unit(int, char *); -static void usage(void); +static void usage(void) __dead2; static int lflag; diff --git a/games/phantasia/io.c b/games/phantasia/io.c index 8dfd7d4725..780d534014 100644 --- a/games/phantasia/io.c +++ b/games/phantasia/io.c @@ -14,7 +14,7 @@ extern void leavegame(void); /* phantglobs.c */ extern double drandom(void); -void catchalarm(int); +void catchalarm(int) __dead2; int getanswer(const char *, bool); void getstring(char *, int); double infloat(void); diff --git a/games/phantasia/setup.c b/games/phantasia/setup.c index e80744d2d8..9da19de185 100644 --- a/games/phantasia/setup.c +++ b/games/phantasia/setup.c @@ -2,7 +2,6 @@ * setup.c - set up all files for Phantasia * * $FreeBSD: src/games/phantasia/setup.c,v 1.11 1999/11/16 02:57:34 billf Exp $ - * $DragonFly: src/games/phantasia/setup.c,v 1.3 2005/05/31 00:06:26 swildner Exp $ */ #include "include.h" #include @@ -13,7 +12,7 @@ /* phantglobs.c */ extern double drandom(void); -void Error(const char *, const char *); +void Error(const char *, const char *) __dead2; static const char *files[] = { /* all files to create */ _SPATH_MONST, diff --git a/games/pig/pig.c b/games/pig/pig.c index 6499cb0bf1..6e99e647ca 100644 --- a/games/pig/pig.c +++ b/games/pig/pig.c @@ -40,7 +40,7 @@ #include static void pigout(char *, int); -static void usage(void); +static void usage(void) __dead2; int main(int argc, char **argv) diff --git a/games/quiz/quiz.c b/games/quiz/quiz.c index 0636a1b880..10ef998094 100644 --- a/games/quiz/quiz.c +++ b/games/quiz/quiz.c @@ -54,14 +54,14 @@ static u_int qsize; char *appdstr (char *, char *, size_t); void downcase (char *); -void err (const char *, ...) __printflike(1, 2); +void err (const char *, ...) __printflike(1, 2) __dead2; void get_cats (char *, char *); void get_file (const char *); char *next_cat (char *); void quiz (void); void score (u_int, u_int, u_int); void show_index (void); -void usage (void); +void usage (void) __dead2; int main(int argc, char **argv) diff --git a/games/robots/robots.h b/games/robots/robots.h index 1118513a92..28e4757738 100644 --- a/games/robots/robots.h +++ b/games/robots/robots.h @@ -104,7 +104,7 @@ void make_level(void); void move_robots(int); void play_level(void); int query(const char *); -void quit(int); +void quit(int) __dead2; void reset_count(void); COORD *rnd_pos(void); void score(void); diff --git a/games/rogue/rogue.h b/games/rogue/rogue.h index 4fea6d18a3..2f2c06dcb3 100644 --- a/games/rogue/rogue.h +++ b/games/rogue/rogue.h @@ -459,12 +459,12 @@ void s_con_mon(object *); /* init.c */ boolean init(int, char**); -void clean_up(const char *); +void clean_up(const char *) __dead2; void start_window(void); void stop_window(void); void byebye(int); void onintr(int); -void error_save(int); +void error_save(int) __dead2; /* inventory.c */ void inventory(const object *, unsigned short); @@ -503,7 +503,7 @@ const char *md_gln(void); void md_sleep(int); char *md_getenv(const char *); char *md_malloc(int); -void md_exit(int); +void md_exit(int) __dead2; void md_lock(boolean); void md_shell(const char *); #endif @@ -627,10 +627,10 @@ void save_into_file(const char *); void restore(const char *); /* score.c */ -void killed_by(const object *, short); -void win(void); +void killed_by(const object *, short) __dead2; +void win(void) __dead2; void quit(boolean); -void put_scores(const object *, short); +void put_scores(const object *, short) __dead2; boolean is_vowel(short); void xxxx(char *, short); long xxx(boolean); diff --git a/games/sail/externs.h b/games/sail/externs.h index ab039afbef..2ae1c77955 100644 --- a/games/sail/externs.h +++ b/games/sail/externs.h @@ -353,12 +353,12 @@ bool boarding(struct ship *, char); void unboard(struct ship *, struct ship *, char); /* pl_1.c */ -void leave(int); -void choke(int); +void leave(int) __dead2; +void choke(int) __dead2; void child(int); /* pl_2.c */ -void play(void); +void play(void) __dead2; /* pl_3.c */ void acceptcombat(void); @@ -400,7 +400,7 @@ void leftview(void); void rightview(void); /* pl_main.c */ -void pl_main(void); +void pl_main(void) __dead2; /* sync.c */ void fmtship(char *, size_t, const char *, struct ship *); diff --git a/games/tetris/tetris.c b/games/tetris/tetris.c index 5d5079f88f..e217654977 100644 --- a/games/tetris/tetris.c +++ b/games/tetris/tetris.c @@ -62,7 +62,7 @@ char key_msg[100]; int showpreview, classic; static void elide(void); -void onintr(int __unused); +__dead2 void onintr(int __unused); const struct shape *randshape(void); static void setup_board(void); __dead2 void usage(void); diff --git a/games/tetris/tetris.h b/games/tetris/tetris.h index e3d2507760..66d54efa59 100644 --- a/games/tetris/tetris.h +++ b/games/tetris/tetris.h @@ -174,4 +174,4 @@ extern int classic; int fits_in(const struct shape *, int); void place(const struct shape *, int, int); -void stop(const char *); +void stop(const char *) __dead2; diff --git a/games/trek/trek.h b/games/trek/trek.h index c5d977ce20..8b7c07fd79 100644 --- a/games/trek/trek.h +++ b/games/trek/trek.h @@ -408,13 +408,13 @@ void killb(int, int); void kills(int, int, int); void killd(int, int, int); void klmove(int); -void lose(int); +void lose(int) __dead2; void lrscan(int); double move(int, int, double, double); void nova(int, int); void out(int); void phaser(int); -void play(void); +void play(void) __dead2; void ram(int, int); int ranf(int); double franf(void); @@ -434,8 +434,8 @@ const char *systemname(struct quad *); void torped(int); char *bmove(const void *, void *, size_t); bool sequal(const char *, const char *); -void syserr(const char *, ...) __printflike(1, 2); +void syserr(const char *, ...) __dead2 __printflike(1, 2); void visual(int); void warp(int, int, double); void dowarp(int); -void win(void); +void win(void) __dead2; diff --git a/games/worm/worm.c b/games/worm/worm.c index 181684e51d..976013362e 100644 --- a/games/worm/worm.c +++ b/games/worm/worm.c @@ -66,9 +66,9 @@ static int start_len = LENGTH; static char lastch; static char outbuf[BUFSIZ]; -static void crash(void); +static void crash(void) __dead2; static void display(struct body *, char); -static void leave(int); +static void leave(int) __dead2; static void life(void); static void newpos(struct body *); static void prize(void); diff --git a/games/worms/worms.c b/games/worms/worms.c index 6f57484702..9990320bda 100644 --- a/games/worms/worms.c +++ b/games/worms/worms.c @@ -166,7 +166,7 @@ static struct worm { static volatile sig_atomic_t sig_caught = 0; -static void nomem(void); +static void nomem(void) __dead2; static void onsig(int); int diff --git a/games/wump/wump.c b/games/wump/wump.c index 1676d37937..838fd7507e 100644 --- a/games/wump/wump.c +++ b/games/wump/wump.c @@ -118,7 +118,7 @@ static void pit_survive(void); static int shoot(char *); static void shoot_self(void); static int take_action(void); -static void usage(void); +static void usage(void) __dead2; static void wump_kill(void); static int wump_nearby(void); -- 2.41.0