Subject: bin/6144: [PATCH] Add noreturn attributes to games
To: None <gnats-bugs@gnats.netbsd.org>
From: Joseph Myers <jsm@octomino.demon.co.uk>
List: netbsd-bugs
Date: 09/12/1998 13:49:59
>Number:         6144
>Category:       bin
>Synopsis:       [PATCH] Add noreturn attributes to games
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sat Sep 12 07:35:01 1998
>Last-Modified:
>Originator:     Joseph Samuel Myers
>Organization:
Trinity College, University of Cambridge, UK
>Release:        NetBSD-current of 1998-09-12
>Environment:
[
System: Linux octomino 2.0.35 #1 Wed Aug 12 15:54:21 UTC 1998 i586 unknown
Architecture: i586
]
>Description:

The patch below adds __noreturn__ attributes to the declarations of
many functions in the NetBSD games that can never return.  It is
probably not complete - some functions that can never return may not
be marked, especially those that are only used as signal handlers -
but should be self-consistent in that if these patches (or the part of
them applying to any subset of the games) are applied (and the
standard headers contain appropriate noreturn attributes for standard
functions) there should be no `noreturn function does return' or
similar warnings.

One instance in adventure that should be so marked is not included in
this patch, since the patch in bin/6079 handles that case.

>How-To-Repeat:

>Fix:

diff -ruN arithmetic/arithmetic.c arithmetic+/arithmetic.c
--- arithmetic/arithmetic.c	Tue Feb  3 12:33:56 1998
+++ arithmetic+/arithmetic.c	Sat Sep 12 12:58:19 1998
@@ -89,13 +89,13 @@
 #include <unistd.h>
 
 int	getrandom __P((int, int, int));
-void	intr __P((int));
+void	intr __P((int)) __attribute__((__noreturn__));
 int	main __P((int, char *[]));
 int	opnum __P((int));
 void	penalise __P((int, int, int));
 int	problem __P((void));
 void	showstats __P((void));
-void	usage __P((void));
+void	usage __P((void)) __attribute__((__noreturn__));
 
 char keylist[] = "+-x/";
 char defaultkeys[] = "+-";
diff -ruN atc/extern.h atc+/extern.h
--- atc/extern.h	Fri Oct 10 11:21:28 1997
+++ atc+/extern.h	Sat Sep 12 12:59:37 1998
@@ -89,8 +89,8 @@
 void		iomove __P((int));
 int		list_games __P((void));
 int		log_score __P((int));
-void		log_score_quit __P((int));
-void		loser __P((PLANE *, char *));
+void		log_score_quit __P((int)) __attribute__((__noreturn__));
+void		loser __P((PLANE *, char *)) __attribute__((__noreturn__));
 int		main __P((int, char *[]));
 char		name __P((PLANE *));
 int		next_plane __P((void));
diff -ruN backgammon/common_source/back.h backgammon+/common_source/back.h
--- backgammon/common_source/back.h	Tue Oct 14 11:09:11 1997
+++ backgammon+/common_source/back.h	Sat Sep 12 13:01:12 1998
@@ -155,7 +155,7 @@
 void	getarg __P((char ***));
 int	getcaps __P((char *));
 void	getmove __P((void));
-void	getout __P((int));
+void	getout __P((int)) __attribute__((__noreturn__));
 void	gwrite __P((void));
 void	init __P((void));
 int	last __P((void));
diff -ruN backgammon/teachgammon/tutor.h backgammon+/teachgammon/tutor.h
--- backgammon/teachgammon/tutor.h	Fri Oct 10 11:22:23 1997
+++ backgammon+/teachgammon/tutor.h	Sat Sep 12 13:02:07 1998
@@ -68,5 +68,5 @@
 
 int	brdeq __P((int *, int *));
 void	clrest __P((void));
-void	leave __P((void));
-void	tutor __P((void));
+void	leave __P((void)) __attribute__((__noreturn__));
+void	tutor __P((void)) __attribute__((__noreturn__));
diff -ruN battlestar/extern.h battlestar+/extern.h
--- battlestar/extern.h	Sun Mar 29 12:13:46 1998
+++ battlestar+/extern.h	Sat Sep 12 13:03:53 1998
@@ -311,8 +311,8 @@
 void convert __P((int));
 void crash __P((void));
 int cypher __P((void));
-void die __P((void));
-void diesig __P((int));
+void die __P((void)) __attribute__((__noreturn__));
+void diesig __P((int)) __attribute__((__noreturn__));
 void dig __P((void));
 int draw __P((void));
 void drink __P((void));
@@ -332,7 +332,7 @@
 int land __P((void));
 int launch __P((void));
 void light __P((void));
-void live __P((void));
+void live __P((void)) __attribute__((__noreturn__));
 void love __P((void));
 int move __P((int, int));
 void moveenemy __P((int));
diff -ruN boggle/boggle/extern.h boggle+/boggle/extern.h
--- boggle/boggle/extern.h	Fri Oct 13 23:57:28 1995
+++ boggle+/boggle/extern.h	Sat Sep 12 13:05:07 1998
@@ -69,5 +69,5 @@
 void	 startwords __P((void));
 void	 stoptime __P((void));
 int	 timerch __P((void));
-void	 usage __P((void));
+void	 usage __P((void)) __attribute__((__noreturn__));
 int	 validword __P((char *));
diff -ruN caesar/caesar.c caesar+/caesar.c
--- caesar/caesar.c	Sat Oct 11 11:50:55 1997
+++ caesar+/caesar.c	Sat Sep 12 13:06:14 1998
@@ -81,7 +81,7 @@
 
 
 int	main __P((int, char *[]));
-void	printit __P((char *));
+void	printit __P((char *)) __attribute__((__noreturn__));
 
 int
 main(argc, argv)
diff -ruN canfield/canfield/canfield.c canfield+/canfield/canfield.c
--- canfield/canfield/canfield.c	Sat Sep 12 11:04:40 1998
+++ canfield+/canfield/canfield.c	Sat Sep 12 13:08:09 1998
@@ -203,7 +203,7 @@
 int dbfd = -1;
 
 void	askquit __P((int));
-void	cleanup __P((int));
+void	cleanup __P((int)) __attribute__((__noreturn__));
 void	cleanupboard __P((void));
 void	clearabovemovebox __P((void));
 void	clearbelowmovebox __P((void));
diff -ruN cribbage/cribbage.h cribbage+/cribbage.h
--- cribbage/cribbage.h	Fri Oct 13 23:58:02 1995
+++ cribbage+/cribbage.h	Sat Sep 12 13:09:12 1998
@@ -106,7 +106,7 @@
 void	 prpeg __P((int, int, BOOLEAN));
 void	 prtable __P((int));
 int	 readchar __P((void));
-void	 rint __P((int));
+void	 rint __P((int)) __attribute__((__noreturn__));
 int	 score __P((BOOLEAN));
 int	 scorehand __P((CARD [], CARD, int, BOOLEAN, BOOLEAN));
 void	 shuffle __P((CARD []));
diff -ruN dm/dm.c dm+/dm.c
--- dm/dm.c	Sun Jul  5 11:04:51 1998
+++ dm+/dm.c	Sat Sep 12 13:10:32 1998
@@ -78,7 +78,7 @@
 double	load __P((void));
 int	main __P((int, char *[]));
 void	nogamefile __P((void));
-void	play __P((char **));
+void	play __P((char **)) __attribute__((__noreturn__));
 void	read_config __P((void));
 int	users __P((void));
 
diff -ruN factor/factor.c factor+/factor.c
--- factor/factor.c	Sat Oct 11 11:51:40 1997
+++ factor+/factor.c	Sat Sep 12 13:11:21 1998
@@ -90,7 +90,7 @@
 
 int	main __P((int, char *[]));
 void	pr_fact __P((ubig));	/* print factors of a value */
-void	usage __P((void));
+void	usage __P((void)) __attribute__((__noreturn__));
 
 int
 main(argc, argv)
diff -ruN fish/fish.c fish+/fish.c
--- fish/fish.c	Tue Jan 13 12:23:02 1998
+++ fish+/fish.c	Sat Sep 12 13:12:08 1998
@@ -94,7 +94,7 @@
 void	printhand __P((int *));
 void	printplayer __P((int));
 int	promove __P((void));
-void	usage __P((void));
+void	usage __P((void)) __attribute__((__noreturn__));
 int	usermove __P((void));
 
 int
diff -ruN fortune/fortune/fortune.c fortune+/fortune/fortune.c
--- fortune/fortune/fortune.c	Sun Aug 30 11:05:12 1998
+++ fortune+/fortune/fortune.c	Sat Sep 12 13:13:20 1998
@@ -158,7 +158,7 @@
 void	 print_list __P((FILEDESC *, int));
 void	 sum_noprobs __P((FILEDESC *));
 void	 sum_tbl __P((STRFILE *, STRFILE *));
-void	 usage __P((void));
+void	 usage __P((void)) __attribute__((__noreturn__));
 void	 zero_tbl __P((STRFILE *));
 
 #ifndef	NO_REGEX
diff -ruN fortune/strfile/strfile.c fortune+/strfile/strfile.c
--- fortune/strfile/strfile.c	Sat Oct 11 11:52:00 1997
+++ fortune+/strfile/strfile.c	Sat Sep 12 13:13:50 1998
@@ -142,7 +142,7 @@
 int	main __P((int, char *[]));
 void	randomize __P((void));
 char   *unctrl __P((char));
-void	usage __P((void));
+void	usage __P((void)) __attribute__((__noreturn__));
 
 
 /*
diff -ruN gomoku/gomoku.h gomoku+/gomoku.h
--- gomoku/gomoku.h	Sat Oct 11 11:52:17 1997
+++ gomoku+/gomoku.h	Sat Sep 12 13:15:27 1998
@@ -275,11 +275,11 @@
 void	cursfini __P((void));
 void	cursinit __P((void));
 void	bdwho __P((int));
-void	panic __P((char *));
+void	panic __P((char *)) __attribute__((__noreturn__));
 void	log __P((char *));
 void	dlog __P((char *));
-void	quit __P((void));
-void	quitsig __P((int));
+void	quit __P((void)) __attribute__((__noreturn__));
+void	quitsig __P((int)) __attribute__((__noreturn__));
 void	whatsup __P((int));
 int	readinput __P((FILE *));
 char   *stoc __P((int));
diff -ruN hunt/hunt/hunt.c hunt+/hunt/hunt.c
--- hunt/hunt/hunt.c	Sun Aug 30 11:05:15 1998
+++ hunt+/hunt/hunt.c	Sat Sep 12 13:16:41 1998
@@ -87,7 +87,7 @@
 void	dump_scores __P((SOCKET));
 long	env_init __P((long));
 void	fill_in_blanks __P((void));
-void	leave __P((int, char *));
+void	leave __P((int, char *)) __attribute__((__noreturn__));
 int	main __P((int, char *[]));
 # ifdef INTERNET
 SOCKET *list_drivers __P((void));
diff -ruN hunt/huntd/hunt.h hunt+/huntd/hunt.h
--- hunt/huntd/hunt.h	Sat Sep 12 11:04:45 1998
+++ hunt+/huntd/hunt.h	Sat Sep 12 13:17:26 1998
@@ -446,7 +446,7 @@
 void		stmonitor __P((PLAYER *));
 void		stplayer __P((PLAYER *, int));
 char		translate __P((char));
-SIGNAL_TYPE	cleanup __P((int));
+SIGNAL_TYPE	cleanup __P((int)) __attribute__((__noreturn__));
 SIGNAL_TYPE	intr __P((int));
 SIGNAL_TYPE	sigalrm __P((int));
 SIGNAL_TYPE	sigemt __P((int));
diff -ruN mille/mille.h mille+/mille.h
--- mille/mille.h	Mon Jul 27 11:06:00 1998
+++ mille+/mille.h	Sat Sep 12 13:20:05 1998
@@ -231,7 +231,7 @@
 int	check_ext __P((bool));
 void	check_go __P((void));
 void	check_more __P((void));
-void	die __P((int));
+void	die __P((int)) __attribute__((__noreturn__));
 void	domove __P((void));
 bool	error __P((const char *, ...));
 void	extrapolate __P((PLAY *));
diff -ruN number/number.c number+/number.c
--- number/number.c	Sat Oct 11 11:53:31 1997
+++ number+/number.c	Sat Sep 12 13:21:14 1998
@@ -86,7 +86,7 @@
 void	pfract __P((int));
 void	toobig __P((void));
 int	unit __P((int, char *));
-void	usage __P((void));
+void	usage __P((void)) __attribute__((__noreturn__));
 
 int lflag;
 
diff -ruN pig/pig.c pig+/pig.c
--- pig/pig.c	Sun Oct 12 11:26:02 1997
+++ pig+/pig.c	Sat Sep 12 13:22:12 1998
@@ -58,7 +58,7 @@
 
 int main __P((int, char *[]));
 void pigout __P((char *, int));
-void usage __P((void));
+void usage __P((void)) __attribute__((__noreturn__));
 
 int
 main(argc, argv)
diff -ruN primes/primes.c primes+/primes.c
--- primes/primes.c	Sun Oct 12 11:26:09 1997
+++ primes+/primes.c	Sat Sep 12 13:22:57 1998
@@ -110,7 +110,7 @@
 int	main __P((int, char *[]));
 void	primes __P((ubig, ubig));
 ubig	read_num_buf __P((void));
-void	usage __P((void));
+void	usage __P((void)) __attribute__((__noreturn__));
 
 int
 main(argc, argv)
diff -ruN quiz/quiz.c quiz+/quiz.c
--- quiz/quiz.c	Sun Sep 21 04:32:30 1997
+++ quiz+/quiz.c	Sat Sep 12 13:23:30 1998
@@ -78,7 +78,7 @@
 void	 quiz __P((void));
 void	 score __P((u_int, u_int, u_int));
 void	 show_index __P((void));
-void	 usage __P((void));
+void	 usage __P((void)) __attribute__((__noreturn__));
 
 int
 main(argc, argv)
diff -ruN robots/robots.h robots+/robots.h
--- robots/robots.h	Mon Oct 13 11:26:38 1997
+++ robots+/robots.h	Sat Sep 12 13:24:34 1998
@@ -131,7 +131,7 @@
 bool	must_telep __P((void));
 void	play_level __P((void));
 int	query __P((char *));
-void	quit __P((int));
+void	quit __P((int)) __attribute__((__noreturn__));
 void	reset_count __P((void));
 int	rnd __P((int));
 COORD  *rnd_pos __P((void));
diff -ruN rogue/rogue.h rogue+/rogue.h
--- rogue/rogue.h	Mon Jul 27 11:06:03 1998
+++ rogue+/rogue.h	Sat Sep 12 13:26:47 1998
@@ -491,7 +491,7 @@
 boolean	check_imitator __P((object *));
 void	check_message __P((void));
 int	check_up __P((void));
-void	clean_up __P((char *));
+void	clean_up __P((char *)) __attribute__((__noreturn__));
 void	clear_level __P((void));
 void	cnfs __P((void));
 int	coin_toss __P((void));
@@ -517,7 +517,7 @@
 void	eat __P((void));
 void	edit_opts __P((void));
 void	env_get_value __P((char **, char *, boolean));
-void	error_save __P((int));
+void	error_save __P((int)) __attribute__((__noreturn__));
 void	fight __P((int));
 void	fill_it __P((int, boolean));
 void	fill_out_level __P((void));
@@ -601,7 +601,7 @@
 boolean	mask_room __P((short, short *, short *, unsigned short));
 void	md_cbreak_no_echo_nonl __P((boolean));
 boolean	md_df __P((char *));
-void	md_exit __P((int));
+void	md_exit __P((int)) __attribute__((__noreturn__));
 void	md_gct __P((struct rogue_time *));
 char   *md_gdtcf __P((void));
 int	md_get_file_id __P((char *));
@@ -663,7 +663,7 @@
 void	put_objects __P((void));
 void	put_on_ring __P((void));
 void	put_player __P((short));
-void	put_scores __P((object *, short));
+void	put_scores __P((object *, short)) __attribute__((__noreturn__));
 void	put_stairs __P((void));
 void	quaff __P((void));
 void	quit __P((boolean));
@@ -703,7 +703,7 @@
 void	search __P((short, boolean));
 boolean	seek_gold __P((object *));
 void	sell_pack __P((void));
-void	sf_error __P((void));
+void	sf_error __P((void)) __attribute__((__noreturn__));
 void	show_average_hp __P((void));
 void	show_monsters __P((void));
 void	show_objects __P((void));
diff -ruN sail/extern.h sail+/extern.h
--- sail/extern.h	Sat Jul 25 11:06:33 1998
+++ sail+/extern.h	Sat Sep 12 13:27:41 1998
@@ -367,8 +367,8 @@
 void unboard __P((struct ship *, struct ship *, int));
 
 /* pl_1.c */
-void leave __P((int));
-void choke __P((int));
+void leave __P((int)) __attribute__((__noreturn__));
+void choke __P((int)) __attribute__((__noreturn__));
 void child __P((int));
 
 /* pl_2.c */
diff -ruN snake/snake/snake.h snake+/snake/snake.h
--- snake/snake/snake.h	Tue Oct 14 11:09:49 1997
+++ snake+/snake/snake.h	Sat Sep 12 13:28:49 1998
@@ -89,7 +89,7 @@
 void		cook __P((void));
 void		cr __P((void));
 void		delay __P((int));
-void		done __P((void));
+void		done __P((void)) __attribute__((__noreturn__));
 void		down __P((void));
 void		drawbox __P((void));
 void		flushi __P((void));
@@ -118,7 +118,7 @@
 void		snap __P((void));
 void		snrand __P((struct point *));
 void		spacewarp __P((int));
-void		stop __P((int));
+void		stop __P((int)) __attribute__((__noreturn__));
 int		stretch __P((struct point *));
 int		stretch __P((struct point *));
 void		surround __P((struct point *));
diff -ruN tetris/tetris.c tetris+/tetris.c
--- tetris/tetris.c	Mon Aug 10 11:05:09 1998
+++ tetris+/tetris.c	Sat Sep 12 13:29:45 1998
@@ -64,8 +64,8 @@
 static	void	elide __P((void));
 static	void	setup_board __P((void));
 	int	main __P((int, char **));
-	void	onintr __P((int));
-	void	usage __P((void));
+	void	onintr __P((int)) __attribute__((__noreturn__));
+	void	usage __P((void)) __attribute__((__noreturn__));
 
 /*
  * Set up the initial board.  The bottom display row is completely set,
diff -ruN tetris/tetris.h tetris+/tetris.h
--- tetris/tetris.h	Sat Oct 14 00:03:40 1995
+++ tetris+/tetris.h	Sat Sep 12 13:35:28 1998
@@ -168,4 +168,4 @@
 
 int	fits_in __P((struct shape *, int));
 void	place __P((struct shape *, int, int));
-void	stop __P((char *));
+void	stop __P((char *)) __attribute__((__noreturn__));
diff -ruN worm/worm.c worm+/worm.c
--- worm/worm.c	Sun Oct 12 11:26:42 1997
+++ worm+/worm.c	Sat Sep 12 13:31:35 1998
@@ -82,10 +82,10 @@
 char lastch;
 char outbuf[BUFSIZ];
 
-void	crash __P((void));
+void	crash __P((void)) __attribute__((__noreturn__));
 void	display __P((struct body *, char));
 int	main __P((int, char **));
-void	leave __P((int));
+void	leave __P((int)) __attribute__((__noreturn__));
 void	life __P((void));
 void	newpos __P((struct body *));
 void	process __P((char));
diff -ruN worms/worms.c worms+/worms.c
--- worms/worms.c	Sun Oct 12 11:26:44 1997
+++ worms+/worms.c	Sat Sep 12 13:32:23 1998
@@ -185,8 +185,8 @@
 
 void	 fputchar __P((int));
 int	 main __P((int, char **));
-void	 nomem __P((void));
-void	 onsig __P((int));
+void	 nomem __P((void)) __attribute__((__noreturn__));
+void	 onsig __P((int)) __attribute__((__noreturn__));
 int	 tgetent __P((char *, char *));
 int	 tgetflag __P((char *));
 int	 tgetnum __P((char *));
diff -ruN wump/wump.c wump+/wump.c
--- wump/wump.c	Sun Aug 30 11:05:28 1998
+++ wump+/wump.c	Sat Sep 12 13:33:07 1998
@@ -133,7 +133,7 @@
 int	shoot __P((char *));
 void	shoot_self __P((void));
 int	take_action __P((void));
-void	usage __P((void));
+void	usage __P((void)) __attribute__((__noreturn__));
 void	wump_kill __P((void));
 int	wump_nearby __P((void));
 
>Audit-Trail:
>Unformatted: