diff options
author | tb <tb@cvs.openbsd.org> | 2016-01-07 16:00:35 +0000 |
---|---|---|
committer | tb <tb@cvs.openbsd.org> | 2016-01-07 16:00:35 +0000 |
commit | 93e376267b624e9b6d6dc70ec32418c59d2a25b0 (patch) | |
tree | 9b0fedba72c0c99cf7d268ba0c169cb908c27a59 | |
parent | 58a106c10757a33412a67cbda574c32351dea1a8 (diff) |
Some basic code maintenance in games/
- in main() replace exit with return
- drop some /* NOTREACHED */ lint comments along the way.
- make more use of standard CFLAGS, esp. -Wimplicit-function-declaration
- add and sort some headers when needed
- add straightforward pledges to some programs used at compile time
discussed with and ok mestre@
42 files changed, 159 insertions, 118 deletions
diff --git a/games/adventure/main.c b/games/adventure/main.c index 61c0bcd43ed..d589dd964c9 100644 --- a/games/adventure/main.c +++ b/games/adventure/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.21 2015/11/30 08:14:48 tb Exp $ */ +/* $OpenBSD: main.c,v 1.22 2016/01/07 16:00:31 tb Exp $ */ /* $NetBSD: main.c,v 1.5 1996/05/21 21:53:09 mrg Exp $ */ /*- @@ -71,7 +71,7 @@ main(int argc, char *argv[]) errx(1, "can't open file"); /* So give up */ case 2: /* Oops -- file was altered */ rspeak(202); /* You dissolve */ - exit(2); /* File could be non-adventure */ + return 2; /* File could be non-adventure */ } /* So don't unlink it. */ } diff --git a/games/adventure/setup.c b/games/adventure/setup.c index f062ac368fc..4bf438e76f4 100644 --- a/games/adventure/setup.c +++ b/games/adventure/setup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: setup.c,v 1.12 2014/12/31 15:45:57 tedu Exp $ */ +/* $OpenBSD: setup.c,v 1.13 2016/01/07 16:00:31 tb Exp $ */ /* $NetBSD: setup.c,v 1.2 1995/03/21 12:05:10 cgd Exp $ */ /*- @@ -49,6 +49,7 @@ #include <err.h> #include <stdio.h> #include <stdlib.h> +#include <unistd.h> #define USAGE "Usage: setup file > data.c (file is typically glorkz)\n" @@ -63,13 +64,20 @@ main(int argc, char *argv[]) FILE *infile; int c, count, linestart; + if (pledge("stdio rpath", NULL) == -1) + err(1, "pledge"); + if (argc != 2) { fprintf(stderr, USAGE); - exit(1); + return 1; } if ((infile = fopen(argv[1], "r")) == NULL) err(1, "Can't read file %s", argv[1]); + + if (pledge("stdio", NULL) == -1) + err(1, "pledge"); + puts("/*\n * data.c: created by setup from the ascii data file."); puts(SIG1); puts(SIG2); @@ -103,5 +111,5 @@ main(int argc, char *argv[]) } puts("\n\t0\n};"); fclose(infile); - exit(0); + return 0; } diff --git a/games/atc/main.c b/games/atc/main.c index 2d8526f9345..ea3a42da1f8 100644 --- a/games/atc/main.c +++ b/games/atc/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.26 2015/12/31 16:50:29 mestre Exp $ */ +/* $OpenBSD: main.c,v 1.27 2016/01/07 16:00:31 tb Exp $ */ /* $NetBSD: main.c,v 1.4 1995/04/27 21:22:25 mycroft Exp $ */ /*- @@ -129,7 +129,7 @@ main(int argc, char *argv[]) } if (f_usage || f_showscore || f_list || f_printpath) - exit(0); + return 0; if (file == NULL) file = default_game(); @@ -137,7 +137,7 @@ main(int argc, char *argv[]) file = okay_game(file); if (file == NULL || read_file(file) < 0) - exit(1); + return 1; setup_screen(sp); diff --git a/games/banner/banner.c b/games/banner/banner.c index c4fd015b435..61e3eb82171 100644 --- a/games/banner/banner.c +++ b/games/banner/banner.c @@ -1,4 +1,4 @@ -/* $OpenBSD: banner.c,v 1.19 2015/12/25 23:41:43 gsoares Exp $ */ +/* $OpenBSD: banner.c,v 1.20 2016/01/07 16:00:31 tb Exp $ */ /* $NetBSD: banner.c,v 1.4 1995/04/22 11:55:15 cgd Exp $ */ /* @@ -1038,7 +1038,7 @@ main(int argc, char *argv[]) default: (void)fprintf(stderr, "usage: banner [-w width] message ...\n"); - exit(1); + return 1; } argc -= optind; argv += optind; @@ -1098,7 +1098,7 @@ main(int argc, char *argv[]) j++; } if (j) - exit(1); + return 1; if (trace) printf("Message '%s' is OK\n",message); @@ -1115,7 +1115,7 @@ main(int argc, char *argv[]) while (!term) { if (pc < 0 || pc >= NBYTES) { printf("bad pc: %d\n",pc); - exit(1); + return 1; } x = data_table[pc] & 0377; if (trace) diff --git a/games/bcd/bcd.c b/games/bcd/bcd.c index 5d97d35f372..9b47f999198 100644 --- a/games/bcd/bcd.c +++ b/games/bcd/bcd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bcd.c,v 1.22 2015/10/23 02:01:15 jsg Exp $ */ +/* $OpenBSD: bcd.c,v 1.23 2016/01/07 16:00:31 tb Exp $ */ /* $NetBSD: bcd.c,v 1.6 1995/04/24 12:22:23 cgd Exp $ */ /* @@ -139,7 +139,7 @@ main(int argc, char *argv[]) default: fprintf(stderr, "usage: bcd [-l] [string ...]\n"); fprintf(stderr, "usage: bcd -d [-l]\n"); - exit(1); + return 1; } } argc -= optind; @@ -166,7 +166,7 @@ main(int argc, char *argv[]) while (fgets(cardline, sizeof(cardline), stdin)) printcard(cardline); } - exit(0); + return 0; } void diff --git a/games/boggle/boggle/bog.c b/games/boggle/boggle/bog.c index 91747020024..8e114eed29a 100644 --- a/games/boggle/boggle/bog.c +++ b/games/boggle/boggle/bog.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bog.c,v 1.27 2016/01/03 14:38:16 mestre Exp $ */ +/* $OpenBSD: bog.c,v 1.28 2016/01/07 16:00:31 tb Exp $ */ /* $NetBSD: bog.c,v 1.5 1995/04/24 12:22:32 cgd Exp $ */ /*- @@ -160,20 +160,20 @@ main(int argc, char *argv[]) newgame(bspec); while ((p = batchword(stdin)) != NULL) (void) printf("%s\n", p); - exit(0); + return 0; } setup(); prompt("Loading the dictionary..."); if ((dictfp = opendict(DICT)) == NULL) { warn("%s", DICT); cleanup(); - exit(1); + return 1; } #ifdef LOADDICT if (loaddict(dictfp) < 0) { warnx("can't load %s", DICT); cleanup(); - exit(1); + return 1; } (void)fclose(dictfp); dictfp = NULL; @@ -181,7 +181,7 @@ main(int argc, char *argv[]) if (loadindex(DICTINDEX) < 0) { warnx("can't load %s", DICTINDEX); cleanup(); - exit(1); + return 1; } prompt("Type <space> to begin..."); @@ -211,7 +211,7 @@ main(int argc, char *argv[]) } } cleanup(); - exit(0); + return 0; } /* diff --git a/games/boggle/mkdict/Makefile b/games/boggle/mkdict/Makefile index f6d23d27efa..732461f718f 100644 --- a/games/boggle/mkdict/Makefile +++ b/games/boggle/mkdict/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.3 1998/09/24 06:45:06 pjanzen Exp $ +# $OpenBSD: Makefile,v 1.4 2016/01/07 16:00:31 tb Exp $ # $NetBSD: Makefile,v 1.2 1995/03/21 12:14:47 cgd Exp $ # @(#)Makefile 8.1 (Berkeley) 6/11/93 @@ -9,4 +9,5 @@ CC=${HOSTCC} install: +.include "../../Makefile.inc" .include <bsd.prog.mk> diff --git a/games/boggle/mkdict/mkdict.c b/games/boggle/mkdict/mkdict.c index 7ef93ef9c3a..7fe5be96f37 100644 --- a/games/boggle/mkdict/mkdict.c +++ b/games/boggle/mkdict/mkdict.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mkdict.c,v 1.12 2015/10/24 17:27:06 mmcc Exp $ */ +/* $OpenBSD: mkdict.c,v 1.13 2016/01/07 16:00:31 tb Exp $ */ /* $NetBSD: mkdict.c,v 1.2 1995/03/21 12:14:49 cgd Exp $ */ /*- @@ -43,10 +43,11 @@ #include <ctype.h> #include <err.h> +#include <limits.h> #include <stdio.h> #include <stdlib.h> -#include <limits.h> #include <string.h> +#include <unistd.h> #include "bog.h" @@ -59,6 +60,9 @@ main(int argc, char *argv[]) int current, len, prev, qcount; char buf[2][MAXWORDLEN + 1]; + if (pledge("stdio", NULL) == -1) + err(1, "pledge"); + prev = 0; current = 1; buf[prev][0] = '\0'; @@ -112,5 +116,5 @@ main(int argc, char *argv[]) current = !current; } warnx("%d words", nwords); - exit(0); + return 0; } diff --git a/games/boggle/mkindex/Makefile b/games/boggle/mkindex/Makefile index 68eedb21581..3f7d9693917 100644 --- a/games/boggle/mkindex/Makefile +++ b/games/boggle/mkindex/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.3 1998/09/24 06:45:06 pjanzen Exp $ +# $OpenBSD: Makefile,v 1.4 2016/01/07 16:00:31 tb Exp $ # $NetBSD: Makefile,v 1.2 1995/03/21 12:14:51 cgd Exp $ # @(#)Makefile 8.1 (Berkeley) 6/11/93 @@ -9,4 +9,5 @@ CC=${HOSTCC} install: +.include "../../Makefile.inc" .include <bsd.prog.mk> diff --git a/games/boggle/mkindex/mkindex.c b/games/boggle/mkindex/mkindex.c index 82740d2149c..3ebf79d3419 100644 --- a/games/boggle/mkindex/mkindex.c +++ b/games/boggle/mkindex/mkindex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mkindex.c,v 1.8 2009/10/27 23:59:24 deraadt Exp $ */ +/* $OpenBSD: mkindex.c,v 1.9 2016/01/07 16:00:31 tb Exp $ */ /* $NetBSD: mkindex.c,v 1.2 1995/03/21 12:14:52 cgd Exp $ */ /*- @@ -33,8 +33,10 @@ * SUCH DAMAGE. */ +#include <err.h> #include <stdio.h> #include <stdlib.h> +#include <unistd.h> #include "bog.h" @@ -47,6 +49,9 @@ main(int argc, char *argv[]) long off, start; char buf[MAXWORDLEN + 1]; + if (pledge("stdio", NULL) == -1) + err(1, "pledge"); + prev = '\0'; off = start = 0L; while (nextword(stdin, buf, &clen, &rlen) != NULL) { @@ -59,7 +64,7 @@ main(int argc, char *argv[]) off += clen + 1; } printf("%c %6ld %6ld\n", prev, start, off - 1); - exit(0); + return 0; } /* diff --git a/games/bs/bs.c b/games/bs/bs.c index bbbb06c6298..54367c5ba68 100644 --- a/games/bs/bs.c +++ b/games/bs/bs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bs.c,v 1.35 2016/01/03 14:38:17 mestre Exp $ */ +/* $OpenBSD: bs.c,v 1.36 2016/01/07 16:00:32 tb Exp $ */ /* * Copyright (c) 1986, Bruce Holloway * All rights reserved. @@ -1392,6 +1392,5 @@ main(int argc, char *argv[]) } while (playagain()); uninitgame(0); - /*NOTREACHED*/ - exit(0); + return 0; } diff --git a/games/canfield/cfscores/cfscores.c b/games/canfield/cfscores/cfscores.c index 2706a67905b..cb947c12d54 100644 --- a/games/canfield/cfscores/cfscores.c +++ b/games/canfield/cfscores/cfscores.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cfscores.c,v 1.21 2015/12/02 18:34:10 tb Exp $ */ +/* $OpenBSD: cfscores.c,v 1.22 2016/01/07 16:00:32 tb Exp $ */ /* $NetBSD: cfscores.c,v 1.3 1995/03/21 15:08:37 cgd Exp $ */ /* @@ -79,7 +79,7 @@ main(int argc, char *argv[]) err(2, "%s", scorepath); printuser(); - exit(0); + return 0; } /* diff --git a/games/cribbage/crib.c b/games/cribbage/crib.c index f4db45e8b63..6e04b4bddfa 100644 --- a/games/cribbage/crib.c +++ b/games/cribbage/crib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crib.c,v 1.21 2015/12/31 18:10:19 mestre Exp $ */ +/* $OpenBSD: crib.c,v 1.22 2016/01/07 16:00:32 tb Exp $ */ /* $NetBSD: crib.c,v 1.7 1997/07/10 06:47:29 mikel Exp $ */ /*- @@ -64,7 +64,7 @@ main(int argc, char *argv[]) case '?': default: (void) fprintf(stderr, "usage: cribbage [-emqr]\n"); - exit(1); + return 1; } initscr(); @@ -115,7 +115,7 @@ main(int argc, char *argv[]) } while (playing); bye(); - exit(0); + return 0; } /* diff --git a/games/factor/factor.c b/games/factor/factor.c index 96d917cdd57..d7457c42bad 100644 --- a/games/factor/factor.c +++ b/games/factor/factor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: factor.c,v 1.25 2016/01/04 11:58:35 mestre Exp $ */ +/* $OpenBSD: factor.c,v 1.26 2016/01/07 16:00:32 tb Exp $ */ /* $NetBSD: factor.c,v 1.5 1995/03/23 08:28:07 cgd Exp $ */ /* @@ -104,7 +104,7 @@ main(int argc, char *argv[]) if (fgets(buf, sizeof(buf), stdin) == NULL) { if (ferror(stdin)) err(1, "stdin"); - exit (0); + return 0; } buf[strcspn(buf, "\n")] = '\0'; for (p = buf; isblank((unsigned char)*p); ++p) @@ -137,7 +137,7 @@ main(int argc, char *argv[]) pr_fact(val); } } - exit(0); + return 0; } /* diff --git a/games/fortune/fortune/fortune.c b/games/fortune/fortune/fortune.c index 226016af719..3ca589ed601 100644 --- a/games/fortune/fortune/fortune.c +++ b/games/fortune/fortune/fortune.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fortune.c,v 1.49 2016/01/04 11:58:35 mestre Exp $ */ +/* $OpenBSD: fortune.c,v 1.50 2016/01/07 16:00:32 tb Exp $ */ /* $NetBSD: fortune.c,v 1.8 1995/03/23 08:28:40 cgd Exp $ */ /*- @@ -152,18 +152,18 @@ main(int ac, char *av[]) { if (pledge("stdio rpath", NULL) == -1) { perror("pledge"); - exit(1); + return 1; } getargs(ac, av); if (Match) - exit(find_matches() != 0); + return find_matches() != 0; init_prob(); if ((Short_only && minlen_in_list(File_list) > SLEN) || (Long_only && maxlen_in_list(File_list) <= SLEN)) - exit(0); + return 0; do { get_fort(); @@ -177,7 +177,7 @@ main(int ac, char *av[]) (void) fortlen(); sleep((unsigned int) max(Fort_len / CPERS, MINW)); } - exit(0); + return 0; } void diff --git a/games/fortune/strfile/strfile.c b/games/fortune/strfile/strfile.c index cf207cd7fe6..c8ade5f0fd0 100644 --- a/games/fortune/strfile/strfile.c +++ b/games/fortune/strfile/strfile.c @@ -1,4 +1,4 @@ -/* $OpenBSD: strfile.c,v 1.26 2016/01/04 11:58:35 mestre Exp $ */ +/* $OpenBSD: strfile.c,v 1.27 2016/01/07 16:00:32 tb Exp $ */ /* $NetBSD: strfile.c,v 1.4 1995/04/24 12:23:09 cgd Exp $ */ /*- @@ -137,6 +137,9 @@ main(int ac, char *av[]) STR *fp; static char string[257]; + if (pledge("stdio rpath wpath cpath", NULL) == -1) + err(1, "pledge"); + getargs(ac, av); /* evalute arguments */ dc = Delimch; if ((inf = fopen(Infile, "r")) == NULL) @@ -144,6 +147,10 @@ main(int ac, char *av[]) if ((outf = fopen(Outfile, "w")) == NULL) err(1, "%s", Outfile); + + if (pledge("stdio", NULL) == -1) + err(1, "pledge"); + if (!STORING_PTRS) (void) fseek(outf, sizeof Tbl, SEEK_SET); @@ -237,7 +244,7 @@ main(int ac, char *av[]) } if (fclose(outf)) err(1, "fclose `%s'", Outfile); - exit(0); + return 0; } /* diff --git a/games/fortune/unstr/unstr.c b/games/fortune/unstr/unstr.c index edfef6cd98f..d70e97f9fdc 100644 --- a/games/fortune/unstr/unstr.c +++ b/games/fortune/unstr/unstr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: unstr.c,v 1.12 2016/01/04 11:58:35 mestre Exp $ */ +/* $OpenBSD: unstr.c,v 1.13 2016/01/07 16:00:32 tb Exp $ */ /* $NetBSD: unstr.c,v 1.3 1995/03/23 08:29:00 cgd Exp $ */ /*- @@ -52,6 +52,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> #include "strfile.h" @@ -70,11 +71,18 @@ main(int ac, char *av[]) { static STRFILE tbl; /* description table */ + if (pledge("stdio rpath wpath cpath", NULL) == -1) + err(1, "pledge"); + getargs(av); if ((Inf = fopen(Infile, "r")) == NULL) err(1, "fopen `%s'", Infile); if ((Dataf = fopen(Datafile, "r")) == NULL) err(1, "fopen `%s'", Datafile); + + if (pledge("stdio", NULL) == -1) + err(1, "pledge"); + (void) fread(&tbl.str_version, sizeof(tbl.str_version), 1, Dataf); (void) fread(&tbl.str_numstr, sizeof(tbl.str_numstr), 1, Dataf); (void) fread(&tbl.str_longlen, sizeof(tbl.str_longlen), 1, Dataf); @@ -87,7 +95,7 @@ main(int ac, char *av[]) order_unstr(&tbl); (void) fclose(Inf); (void) fclose(Dataf); - exit(0); + return 0; } void diff --git a/games/gomoku/main.c b/games/gomoku/main.c index 1b23e7c0d35..68805f92a7d 100644 --- a/games/gomoku/main.c +++ b/games/gomoku/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.30 2015/12/06 12:00:16 tobias Exp $ */ +/* $OpenBSD: main.c,v 1.31 2016/01/07 16:00:32 tb Exp $ */ /* * Copyright (c) 1994 * The Regents of the University of California. All rights reserved. @@ -113,7 +113,7 @@ main(argc, argv) fprintf(stderr, "usage: %s [-bcdu] [-D debugfile] [inputfile]\n", __progname); - exit(1); + return 1; } } argc -= optind; diff --git a/games/grdc/grdc.c b/games/grdc/grdc.c index 5da19c842f7..ae49b2bc324 100644 --- a/games/grdc/grdc.c +++ b/games/grdc/grdc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: grdc.c,v 1.24 2016/01/04 17:33:24 mestre Exp $ */ +/* $OpenBSD: grdc.c,v 1.25 2016/01/07 16:00:32 tb Exp $ */ /* * * Copyright 2002 Amos Shapir. Public domain. @@ -234,14 +234,14 @@ main(int argc, char *argv[]) refresh(); endwin(); fprintf(stderr, "grdc terminated by signal %d\n", sigtermed); - exit(1); + return 1; } } while (n == 0 || nowtv.tv_sec < endtv.tv_sec); standend(); clear(); refresh(); endwin(); - return(0); + return 0; } void diff --git a/games/hack/hack.main.c b/games/hack/hack.main.c index abf079b1a50..5d2ce344734 100644 --- a/games/hack/hack.main.c +++ b/games/hack/hack.main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hack.main.c,v 1.19 2015/12/16 14:21:50 tb Exp $ */ +/* $OpenBSD: hack.main.c,v 1.20 2016/01/07 16:00:32 tb Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, @@ -166,7 +166,7 @@ main(int argc, char **argv) chdirx(dir,0); #endif prscore(argc, argv); - exit(0); + return 0; } /* diff --git a/games/hack/makedefs.c b/games/hack/makedefs.c index af1c25a909f..1a80ab91448 100644 --- a/games/hack/makedefs.c +++ b/games/hack/makedefs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: makedefs.c,v 1.8 2015/10/24 17:43:28 mmcc Exp $ */ +/* $OpenBSD: makedefs.c,v 1.9 2016/01/07 16:00:32 tb Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, @@ -62,10 +62,11 @@ */ #include <ctype.h> +#include <err.h> +#include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <fcntl.h> #include <unistd.h> /* construct definitions of object constants */ @@ -88,13 +89,16 @@ main(int argc, char **argv) int propct = 0; char *sp; + if (pledge("stdio rpath", NULL) == -1) + err(1, "pledge"); + if (argc != 2) { (void)fprintf(stderr, "usage: makedefs file\n"); - exit(1); + return 1; } if ((fd = open(argv[1], O_RDONLY)) < 0) { perror(argv[1]); - exit(1); + return 1; } skipuntil("objects[] = {"); while(getentry()) { @@ -122,7 +126,7 @@ main(int argc, char **argv) printf("#define LAST_GEM (JADE+1)\n"); printf("#define LAST_RING %d\n", propct); printf("#define NROFOBJECTS %d\n", index-1); - exit(0); + return 0; } char line[LINSZ], *lp = line, *lp0 = line, *lpe = line; diff --git a/games/hunt/hunt/hunt.c b/games/hunt/hunt/hunt.c index 4555007e91c..5b458f0a38c 100644 --- a/games/hunt/hunt/hunt.c +++ b/games/hunt/hunt/hunt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hunt.c,v 1.16 2015/12/26 00:26:39 mestre Exp $ */ +/* $OpenBSD: hunt.c,v 1.17 2016/01/07 16:00:32 tb Exp $ */ /* $NetBSD: hunt.c,v 1.8 1998/09/13 15:27:28 hubertf Exp $ */ /* * Copyright (c) 1983-2003, Regents of the University of California. @@ -154,7 +154,7 @@ main(ac, av) fputs("usage: hunt [-bcfmqSs] [-n name] [-p port] " "[-t team] [-w message] [[-h] host]\n", stderr); - exit(1); + return 1; } } if (optind + 1 < ac) @@ -172,7 +172,7 @@ main(ac, av) if (Show_scores) { dump_scores(); - exit(0); + return 0; } if (Query_driver) { @@ -187,7 +187,7 @@ main(ac, av) if (Sock_host) break; } - exit(0); + return 0; } if (Otto_mode) { if (Am_monitor) @@ -259,8 +259,7 @@ main(ac, av) break; } leave(0, (char *) NULL); - /* NOTREACHED */ - return(0); + return 0; } /* diff --git a/games/hunt/huntd/driver.c b/games/hunt/huntd/driver.c index 19060ecffb7..b375a1c9e3b 100644 --- a/games/hunt/huntd/driver.c +++ b/games/hunt/huntd/driver.c @@ -1,4 +1,4 @@ -/* $OpenBSD: driver.c,v 1.23 2015/12/16 14:21:50 tb Exp $ */ +/* $OpenBSD: driver.c,v 1.24 2016/01/07 16:00:32 tb Exp $ */ /* $NetBSD: driver.c,v 1.5 1997/10/20 00:37:16 lukem Exp $ */ /* * Copyright (c) 1983-2003, Regents of the University of California. @@ -126,7 +126,7 @@ erred: "usage: %s [-bs] [-a addr] [-D var=value] " "[-p port]\n", __progname); - exit(2); + return 2; } } if (optind < ac) @@ -315,7 +315,7 @@ again: /* Fin: */ cleanup(0); - exit(0); + return 0; } /* diff --git a/games/mille/mille.c b/games/mille/mille.c index 9d25d9e2f76..5d4a6e70e7b 100644 --- a/games/mille/mille.c +++ b/games/mille/mille.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mille.c,v 1.22 2015/11/30 08:49:06 tb Exp $ */ +/* $OpenBSD: mille.c,v 1.23 2016/01/07 16:00:32 tb Exp $ */ /* $NetBSD: mille.c,v 1.4 1995/03/24 05:01:48 cgd Exp $ */ /* @@ -64,15 +64,14 @@ main(ac, av) break; default: fprintf(stderr, "usage: %s [file]\n", __progname); - exit(1); - /* NOTREACHED */ + return 1; } Play = PLAYER; initscr(); if ((LINES < 24) || (COLS < 80)) { endwin(); fprintf(stderr, "Screen must be at least 24x80\n"); - exit(1); + return 1; } delwin(stdscr); stdscr = Board = newwin(BOARD_Y, BOARD_X, 0, 0); diff --git a/games/monop/initdeck.c b/games/monop/initdeck.c index 210adfa7c7f..9118facfeb3 100644 --- a/games/monop/initdeck.c +++ b/games/monop/initdeck.c @@ -1,4 +1,4 @@ -/* $OpenBSD: initdeck.c,v 1.14 2015/08/22 14:47:41 deraadt Exp $ */ +/* $OpenBSD: initdeck.c,v 1.15 2016/01/07 16:00:32 tb Exp $ */ /* $NetBSD: initdeck.c,v 1.3 1995/03/23 08:34:43 cgd Exp $ */ /* @@ -34,6 +34,7 @@ #include <stdio.h> #include <stdlib.h> #include <unistd.h> + #include "deck.h" /* @@ -70,6 +71,9 @@ main(ac, av) { int n; + if (pledge("stdio rpath wpath cpath", NULL) == -1) + err(1, "pledge"); + getargs(ac, av); if ((inf = fopen(infile, "r")) == NULL) err(1, "%s", infile); @@ -86,6 +90,9 @@ main(ac, av) if ((outf = fopen(outfile, "w")) == NULL) err(1, "%s", outfile); + if (pledge("stdio", NULL) == -1) + err(1, "pledge"); + fwrite(&deck[0].num_cards, sizeof(deck[0].num_cards), 1, outf); fwrite(&deck[0].top_card, sizeof(deck[0].top_card), 1, outf); fwrite(&deck[0].gojf_used, sizeof(deck[0].gojf_used), 1, outf); @@ -125,8 +132,9 @@ main(ac, av) } fclose(outf); - printf("There were %d com. chest and %d chance cards\n", CC_D.num_cards, CH_D.num_cards); - exit(0); + printf("There were %d com. chest and %d chance cards\n", CC_D.num_cards, + CH_D.num_cards); + return 0; } static void diff --git a/games/morse/morse.c b/games/morse/morse.c index b11b5c6141e..798c5afb78e 100644 --- a/games/morse/morse.c +++ b/games/morse/morse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: morse.c,v 1.18 2016/01/04 17:33:24 mestre Exp $ */ +/* $OpenBSD: morse.c,v 1.19 2016/01/07 16:00:33 tb Exp $ */ /* * Copyright (c) 1988, 1993 @@ -127,7 +127,7 @@ main(int argc, char *argv[]) case '?': case 'h': default: fprintf(stderr, "usage: morse [-d | -s] [string ...]\n"); - exit(1); + return 1; } argc -= optind; argv += optind; @@ -183,7 +183,7 @@ main(int argc, char *argv[]) morse(ch); show("...-.-"); /* SK */ } - exit(0); + return 0; } void diff --git a/games/number/number.c b/games/number/number.c index 5789ed740b0..749e9b9efe4 100644 --- a/games/number/number.c +++ b/games/number/number.c @@ -1,4 +1,4 @@ -/* $OpenBSD: number.c,v 1.18 2016/01/04 17:33:24 mestre Exp $ */ +/* $OpenBSD: number.c,v 1.19 2016/01/07 16:00:33 tb Exp $ */ /* * Copyright (c) 1988, 1993, 1994 @@ -112,7 +112,7 @@ main(int argc, char *argv[]) if (lflag) (void)printf("\n"); } - exit(0); + return 0; } void diff --git a/games/pig/pig.c b/games/pig/pig.c index 67aa3d71299..4818cd72366 100644 --- a/games/pig/pig.c +++ b/games/pig/pig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pig.c,v 1.15 2016/01/04 17:33:24 mestre Exp $ */ +/* $OpenBSD: pig.c,v 1.16 2016/01/07 16:00:33 tb Exp $ */ /* $NetBSD: pig.c,v 1.2 1995/03/23 08:41:40 cgd Exp $ */ /*- @@ -72,7 +72,7 @@ main(int argc, char *argv[]) } (void)putchar(ch); } - exit(0); + return 0; } void diff --git a/games/pom/pom.c b/games/pom/pom.c index 4beb4174ab0..e8e61792f48 100644 --- a/games/pom/pom.c +++ b/games/pom/pom.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pom.c,v 1.20 2016/01/04 17:33:24 mestre Exp $ */ +/* $OpenBSD: pom.c,v 1.21 2016/01/07 16:00:33 tb Exp $ */ /* $NetBSD: pom.c,v 1.6 1996/02/06 22:47:29 jtc Exp $ */ /* @@ -130,7 +130,7 @@ main(int argc, char *argv[]) today); } } - exit(0); + return 0; } /* diff --git a/games/ppt/ppt.c b/games/ppt/ppt.c index 82ba8b1e9d9..cd997f7f043 100644 --- a/games/ppt/ppt.c +++ b/games/ppt/ppt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ppt.c,v 1.15 2016/01/04 17:33:24 mestre Exp $ */ +/* $OpenBSD: ppt.c,v 1.16 2016/01/07 16:00:33 tb Exp $ */ /* $NetBSD: ppt.c,v 1.4 1995/03/23 08:35:40 cgd Exp $ */ /* @@ -122,7 +122,7 @@ main(int argc, char **argv) putppt(c); (void) puts(EDGE); } - exit(0); + return 0; } void diff --git a/games/primes/primes.c b/games/primes/primes.c index 1867220bd6a..26eaf6760f4 100644 --- a/games/primes/primes.c +++ b/games/primes/primes.c @@ -1,4 +1,4 @@ -/* $OpenBSD: primes.c,v 1.20 2016/01/04 11:58:35 mestre Exp $ */ +/* $OpenBSD: primes.c,v 1.21 2016/01/07 16:00:33 tb Exp $ */ /* $NetBSD: primes.c,v 1.5 1995/04/24 12:24:47 cgd Exp $ */ /* @@ -165,7 +165,7 @@ main(int argc, char *argv[]) if (start > stop) errx(1, "start value must be less than stop value."); primes(start, stop); - exit(0); + return 0; } /* diff --git a/games/quiz/quiz.c b/games/quiz/quiz.c index dd632ec661a..23ad0584af1 100644 --- a/games/quiz/quiz.c +++ b/games/quiz/quiz.c @@ -1,4 +1,4 @@ -/* $OpenBSD: quiz.c,v 1.26 2016/01/04 17:33:24 mestre Exp $ */ +/* $OpenBSD: quiz.c,v 1.27 2016/01/07 16:00:33 tb Exp $ */ /* $NetBSD: quiz.c,v 1.9 1995/04/22 10:16:58 cgd Exp $ */ /*- @@ -98,7 +98,7 @@ main(int argc, char *argv[]) default: usage(); } - exit(0); + return 0; } void diff --git a/games/rain/rain.c b/games/rain/rain.c index dca39b85810..6a10c49d251 100644 --- a/games/rain/rain.c +++ b/games/rain/rain.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rain.c,v 1.20 2016/01/04 17:33:24 mestre Exp $ */ +/* $OpenBSD: rain.c,v 1.21 2016/01/07 16:00:33 tb Exp $ */ /* * Copyright (c) 1980, 1993 @@ -77,7 +77,7 @@ main(int argc, char *argv[]) case 'h': default: (void)fprintf(stderr, "usage: rain [-d delay]\n"); - exit(1); + return 1; } /* Convert delay from ms -> ns */ @@ -108,7 +108,7 @@ main(int argc, char *argv[]) for (j = 0;;) { if (sig_caught) { endwin(); - exit(0); + return 0; } x = arc4random_uniform(tcols) + 2; y = arc4random_uniform(tlines) + 2; diff --git a/games/random/random.c b/games/random/random.c index e9eefa3d8ff..b1e039611e2 100644 --- a/games/random/random.c +++ b/games/random/random.c @@ -1,4 +1,4 @@ -/* $OpenBSD: random.c,v 1.17 2016/01/04 11:58:35 mestre Exp $ */ +/* $OpenBSD: random.c,v 1.18 2016/01/07 16:00:33 tb Exp $ */ /* $NetBSD: random.c,v 1.3 1995/04/22 07:44:05 cgd Exp $ */ /* @@ -118,7 +118,7 @@ main(int argc, char *argv[]) } if (ferror(stdin)) err(2, "stdin"); - exit (0); + return 0; } void diff --git a/games/robots/main.c b/games/robots/main.c index 0d903f43690..d8b5ef9158f 100644 --- a/games/robots/main.c +++ b/games/robots/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.23 2016/01/04 17:33:24 mestre Exp $ */ +/* $OpenBSD: main.c,v 1.24 2016/01/07 16:00:33 tb Exp $ */ /* $NetBSD: main.c,v 1.5 1995/04/22 10:08:54 cgd Exp $ */ /* @@ -130,7 +130,7 @@ main(int ac, char *av[]) if (show_only) { show_score(); - exit(0); + return 0; } if (score_wfd < 0) { @@ -165,7 +165,6 @@ main(int ac, char *av[]) score(score_wfd); } while (another()); quit(0); - /* NOT REACHED */ } /* diff --git a/games/sail/main.c b/games/sail/main.c index 756bf23927f..938cc33f768 100644 --- a/games/sail/main.c +++ b/games/sail/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.9 2015/12/16 14:16:27 tb Exp $ */ +/* $OpenBSD: main.c,v 1.10 2016/01/07 16:00:33 tb Exp $ */ /* $NetBSD: main.c,v 1.3 1995/04/22 10:37:01 cgd Exp $ */ /* @@ -54,7 +54,7 @@ main(argc, argv) fd = open("/dev/null", O_RDONLY); if (fd < 3) - exit(1); + return 1; close(fd); p = __progname; diff --git a/games/snake/snake.c b/games/snake/snake.c index 96dad57e9dc..f5183f26a6b 100644 --- a/games/snake/snake.c +++ b/games/snake/snake.c @@ -1,4 +1,4 @@ -/* $OpenBSD: snake.c,v 1.22 2016/01/04 17:33:24 mestre Exp $ */ +/* $OpenBSD: snake.c,v 1.23 2016/01/07 16:00:33 tb Exp $ */ /* $NetBSD: snake.c,v 1.8 1995/04/29 00:06:41 mycroft Exp $ */ /* @@ -166,7 +166,7 @@ main(int argc, char *argv[]) snscore(rawscores, 0); else printf("no scores so far\n"); - exit(0); + return 0; break; case 't': /* slow terminal */ fast = 0; @@ -176,7 +176,7 @@ main(int argc, char *argv[]) default: fputs("usage: snake [-st] [-l length] [-w width]\n", stderr); - exit(1); + return 1; } readscores(1); @@ -237,8 +237,7 @@ main(int argc, char *argv[]) chase(&snake[i], &snake[i - 1]); setup(); mainloop(); - /* NOT REACHED */ - return(0); + return 0; } /* Main command loop */ diff --git a/games/tetris/tetris.c b/games/tetris/tetris.c index f2c7d84cf28..90ce7d0f838 100644 --- a/games/tetris/tetris.c +++ b/games/tetris/tetris.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tetris.c,v 1.28 2016/01/04 17:33:24 mestre Exp $ */ +/* $OpenBSD: tetris.c,v 1.29 2016/01/07 16:00:33 tb Exp $ */ /* $NetBSD: tetris.c,v 1.2 1995/04/22 07:42:47 cgd Exp $ */ /*- @@ -185,7 +185,7 @@ main(int argc, char *argv[]) break; case 's': showscores(0); - exit(0); + return 0; default: usage(); } @@ -342,7 +342,7 @@ main(int argc, char *argv[]) showscores(level); - exit(0); + return 0; } void diff --git a/games/trek/main.c b/games/trek/main.c index c576d2d2502..a1f952f32dc 100644 --- a/games/trek/main.c +++ b/games/trek/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.16 2016/01/07 14:37:51 mestre Exp $ */ +/* $OpenBSD: main.c,v 1.17 2016/01/07 16:00:33 tb Exp $ */ /* $NetBSD: main.c,v 1.4 1995/04/22 10:59:10 cgd Exp $ */ /* @@ -152,7 +152,7 @@ main(int argc, char **argv) if (setjmp(env)) { if ( !getynpar("Another game") ) - exit(0); + return 0; } do { diff --git a/games/worm/worm.c b/games/worm/worm.c index 176d3229922..31392105d20 100644 --- a/games/worm/worm.c +++ b/games/worm/worm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: worm.c,v 1.37 2016/01/04 17:33:24 mestre Exp $ */ +/* $OpenBSD: worm.c,v 1.38 2016/01/07 16:00:33 tb Exp $ */ /* * Copyright (c) 1980, 1993 @@ -136,7 +136,7 @@ main(int argc, char **argv) while (1) { if (wantleave) { endwin(); - exit(0); + return 0; } if (wantsuspend) { move(LINES-1, 0); diff --git a/games/worms/worms.c b/games/worms/worms.c index 38253dd7571..566439ecfe8 100644 --- a/games/worms/worms.c +++ b/games/worms/worms.c @@ -1,4 +1,4 @@ -/* $OpenBSD: worms.c,v 1.24 2016/01/04 17:33:24 mestre Exp $ */ +/* $OpenBSD: worms.c,v 1.25 2016/01/07 16:00:34 tb Exp $ */ /* * Copyright (c) 1980, 1993 @@ -218,7 +218,7 @@ main(int argc, char *argv[]) default: (void)fprintf(stderr, "usage: worms [-ft] [-d delay] [-l length] [-n number]\n"); - exit(1); + return 1; } /* Convert delay from ms -> ns */ @@ -286,7 +286,7 @@ main(int argc, char *argv[]) refresh(); if (sig_caught) { endwin(); - exit(0); + return 0; } nanosleep(&sleeptime, NULL); for (n = 0, w = &worm[0]; n < number; n++, w++) { diff --git a/games/wump/wump.c b/games/wump/wump.c index 3720e02cc38..ee378186c30 100644 --- a/games/wump/wump.c +++ b/games/wump/wump.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wump.c,v 1.30 2016/01/04 17:33:24 mestre Exp $ */ +/* $OpenBSD: wump.c,v 1.31 2016/01/07 16:00:34 tb Exp $ */ /* * Copyright (c) 1989, 1993 @@ -255,7 +255,7 @@ quiver holds %d custom super anti-evil Wumpus arrows. Good luck.\n", if (!getans("\nCare to play another game? (y-n) ")) { (void)printf("\n"); - exit(0); + return 0; } clear_things_in_cave(); if (!getans("In the same cave? (y-n) ")) { |