diff options
author | alfred <alfred@FreeBSD.org> | 2002-05-28 21:41:02 +0000 |
---|---|---|
committer | alfred <alfred@FreeBSD.org> | 2002-05-28 21:41:02 +0000 |
commit | a1f58961268c7ff96687dafb1c1ee8a549a8a26c (patch) | |
tree | 4e49be311e578160f77a3c9a0fe5802d342ad9e2 | |
parent | e13f727e6ba268ec6cde31dfcc44f0677a178a86 (diff) | |
download | FreeBSD-src-a1f58961268c7ff96687dafb1c1ee8a549a8a26c.zip FreeBSD-src-a1f58961268c7ff96687dafb1c1ee8a549a8a26c.tar.gz |
Make almost WARNS=5 compliant:
ANSI'fy function declarations.
Constify some globals and function paramters.
Remove unsused arguments.
Fix (rename) shadowed variables.
-rw-r--r-- | games/mille/comp.c | 9 | ||||
-rw-r--r-- | games/mille/end.c | 14 | ||||
-rw-r--r-- | games/mille/extern.c | 13 | ||||
-rw-r--r-- | games/mille/init.c | 16 | ||||
-rw-r--r-- | games/mille/mille.c | 15 | ||||
-rw-r--r-- | games/mille/mille.h | 9 | ||||
-rw-r--r-- | games/mille/misc.c | 18 | ||||
-rw-r--r-- | games/mille/move.c | 31 | ||||
-rw-r--r-- | games/mille/print.c | 23 | ||||
-rw-r--r-- | games/mille/roll.c | 5 | ||||
-rw-r--r-- | games/mille/save.c | 17 | ||||
-rw-r--r-- | games/mille/types.c | 8 | ||||
-rw-r--r-- | games/mille/varpush.c | 6 |
13 files changed, 83 insertions, 101 deletions
diff --git a/games/mille/comp.c b/games/mille/comp.c index ce42c2e..2cbf896 100644 --- a/games/mille/comp.c +++ b/games/mille/comp.c @@ -48,7 +48,7 @@ static const char rcsid[] = # define V_VALUABLE 40 void -calcmove() +calcmove(void) { CARD card; int *value; @@ -404,8 +404,7 @@ play_it: * Return true if the given player could conceivably win with his next card. */ bool -onecard(pp) -PLAY *pp; +onecard(PLAY *pp) { CARD bat, spd, card; @@ -437,9 +436,7 @@ PLAY *pp; } bool -canplay(pp, op, card) -PLAY *pp, *op; -CARD card; +canplay(PLAY *pp, PLAY *op, CARD card) { switch (card) { case C_200: diff --git a/games/mille/end.c b/games/mille/end.c index ff35779..90a0668 100644 --- a/games/mille/end.c +++ b/games/mille/end.c @@ -55,9 +55,8 @@ void undoex(void); * the end-of-games points to the user who deserves it (if any). */ void -finalscore(pp) - PLAY *pp; { - +finalscore(PLAY *pp) +{ int temp, tot, num; if (pp->was_finished == Finished) @@ -100,9 +99,8 @@ static int Last_tot[2]; /* last tot used for extrapolate */ * the end-of-games points to the user who deserves it (if any). */ void -extrapolate(pp) - PLAY *pp; { - +extrapolate(PLAY *pp) +{ int x, num, tot, count; num = pp - Player; @@ -145,8 +143,8 @@ extrapolate(pp) } void -undoex() { - +undoex(void) +{ reg PLAY *pp; reg int i; diff --git a/games/mille/extern.c b/games/mille/extern.c index aae29d2de..7eda243 100644 --- a/games/mille/extern.c +++ b/games/mille/extern.c @@ -52,10 +52,11 @@ bool Debug, /* set if debugging code on */ Order, /* set if hand should be sorted */ Saved; /* set if game just saved */ -char *C_fmt = "%-18.18s", /* format for printing cards */ - *Fromfile = NULL, /* startup file for game */ - Initstr[100], /* initial string for error field */ - *_cn[NUM_CARDS] = { /* Card name buffer */ +char *Fromfile = NULL, /* startup file for game */ + Initstr[100]; /* initial string for error field */ + +const char *C_fmt = "%-18.18s", /* format for printing cards */ + *_cn[NUM_CARDS] = { /* Card name buffer */ "", "25", "50", @@ -76,8 +77,8 @@ char *C_fmt = "%-18.18s", /* format for printing cards */ "Puncture Proof", "Driving Ace", "Right of Way" - }, - **C_name = &_cn[1]; /* Card names */ + }, + **C_name = &_cn[1]; /* Card names */ int Card_no, /* Card number for current move */ End, /* End value for current hand */ diff --git a/games/mille/init.c b/games/mille/init.c index f29ed22..e84da96 100644 --- a/games/mille/init.c +++ b/games/mille/init.c @@ -46,8 +46,8 @@ static const char rcsid[] = */ void -init() { - +init(void) +{ PLAY *pp; int i, j; CARD card; @@ -90,8 +90,8 @@ init() { } void -shuffle() { - +shuffle(void) +{ int i, r; CARD temp; @@ -109,8 +109,8 @@ shuffle() { } void -newboard() { - +newboard(void) +{ int i; PLAY *pp; static int first = TRUE; @@ -168,8 +168,8 @@ newboard() { } void -newscore() { - +newscore(void) +{ int i, new; PLAY *pp; static int was_full = -1; diff --git a/games/mille/mille.c b/games/mille/mille.c index 0966459..e51c175 100644 --- a/games/mille/mille.c +++ b/games/mille/mille.c @@ -59,9 +59,8 @@ static const char rcsid[] = static void usage(void); int -main(ac, av) - int ac; - char *av[]; { +main(int ac, char *av[]) +{ bool restore; @@ -137,7 +136,7 @@ main(ac, av) } static void -usage() +usage(void) { fprintf(stderr, "usage: mille [restore_file]\n"); exit(1); @@ -148,8 +147,8 @@ usage() * quit. */ void -rub(sig) -int sig; { +rub(int sig __unused) +{ (void)signal(SIGINT, SIG_IGN); if (getyn(REALLYPROMPT)) @@ -161,8 +160,8 @@ int sig; { * Time to go beddy-by */ void -die(code) -int code; { +die(int code) +{ (void)signal(SIGINT, SIG_IGN); if (outf) diff --git a/games/mille/mille.h b/games/mille/mille.h index a7cb7c0..f58d47e 100644 --- a/games/mille/mille.h +++ b/games/mille/mille.h @@ -214,7 +214,8 @@ typedef struct { extern bool Debug, Finished, Next, On_exit, Order, Saved; -extern char *C_fmt, **C_name, *Fromfile, Initstr[]; +extern const char *C_fmt, **C_name; +extern char *Fromfile, Initstr[]; extern int Card_no, End, Handstart, Movetype, Numcards[], Numgos, Numneed[], Numseen[NUM_CARDS], Play, Value[], Window; @@ -239,7 +240,7 @@ bool check_ext(bool); void check_more(void); void die(int); void domove(void); -bool error(char *, ...); +bool error(const char *, ...); #ifdef EXTRAP void extrapolate(PLAY *); #endif @@ -253,7 +254,7 @@ void newscore(void); bool onecard(PLAY *); void prboard(void); void prompt(int); -void prscore(bool); +void prscore(void); char readch(void); bool rest_f(char *); int roll(int, int); @@ -262,7 +263,7 @@ CARD safety(CARD); bool save(void); void shuffle(void); void sort(CARD *); -void varpush(int, int (*)()); +void varpush(int, int (*)(int, void *, size_t)); #ifdef EXTRAP void undoex(void); #endif diff --git a/games/mille/misc.c b/games/mille/misc.c index 0026502..aded942 100644 --- a/games/mille/misc.c +++ b/games/mille/misc.c @@ -59,7 +59,7 @@ static const char rcsid[] = /* VARARGS1 */ bool -error(char *str, ...) +error(const char *str, ...) { va_list arg; @@ -76,7 +76,7 @@ error(char *str, ...) } CARD -getcard() +getcard(void) { int c, c1; @@ -125,9 +125,8 @@ cont: ; } bool -check_ext(forcomp) -bool forcomp; { - +check_ext(bool forcomp) +{ if (End == 700) if (Play == PLAYER) { @@ -180,9 +179,8 @@ done: * also allowed. Return TRUE if the answer was yes, FALSE if no. */ bool -getyn(promptno) -int promptno; { - +getyn(int promptno) +{ char c; Saved = FALSE; @@ -225,7 +223,7 @@ int promptno; { * it. Exit appropriately. */ void -check_more() +check_more(void) { On_exit = TRUE; @@ -253,7 +251,7 @@ check_more() } char -readch() +readch(void) { int cnt; static char c; diff --git a/games/mille/move.c b/games/mille/move.c index c7624fb..25aa3b5 100644 --- a/games/mille/move.c +++ b/games/mille/move.c @@ -66,7 +66,7 @@ static int haspicked(PLAY *); static bool playcard(PLAY *); void -domove() +domove(void) { PLAY *pp; int i, j; @@ -170,8 +170,8 @@ acc: * the game is over */ static void -check_go() { - +check_go(void) +{ CARD card; PLAY *pp, *op; int i; @@ -201,8 +201,7 @@ check_go() { } static bool -playcard(pp) -PLAY *pp; +playcard(PLAY *pp) { int v; CARD card; @@ -351,7 +350,7 @@ protected: } static void -getmove() +getmove(void) { char c; #ifdef DEBUG @@ -407,7 +406,7 @@ getmove() case 'W': /* Window toggle */ Window = nextwin(Window); newscore(); - prscore(TRUE); + prscore(); wrefresh(Score); break; case 'R': /* Redraw screen */ @@ -485,9 +484,8 @@ ret: * return whether or not the player has picked */ static int -haspicked(pp) -PLAY *pp; { - +haspicked(PLAY *pp) +{ int card; if (Topcard <= Deck) @@ -505,9 +503,8 @@ PLAY *pp; { } void -account(card) -CARD card; { - +account(CARD card) +{ CARD oppos; if (card == C_INIT) @@ -531,10 +528,9 @@ CARD card; { } void -prompt(promptno) -int promptno; +prompt(int promptno) { - static char *names[] = { + static const char *names[] = { ">>:Move:", "Really?", "Another hand?", @@ -563,8 +559,7 @@ int promptno; } void -sort(hand) -CARD *hand; +sort(CARD *hand) { CARD *cp, *tp; CARD temp; diff --git a/games/mille/print.c b/games/mille/print.c index 488fbbb..45f567b 100644 --- a/games/mille/print.c +++ b/games/mille/print.c @@ -52,8 +52,8 @@ static void show_card(int, int, CARD, CARD *); static void show_score(int, int, int, int *); void -prboard() { - +prboard(void) +{ PLAY *pp; int i, j, k, temp; @@ -70,7 +70,7 @@ prboard() { show_card(14, temp, pp->battle, &pp->sh_battle); show_card(16, temp, pp->speed, &pp->sh_speed); for (i = C_25; i <= C_200; i++) { - char *name; + const char *name; int end; if (pp->nummiles[i] == pp->sh_nummiles[i]) @@ -84,7 +84,7 @@ prboard() { pp->sh_nummiles[i] = end; } } - prscore(TRUE); + prscore(); temp = CARD_STRT; pp = &Player[PLAYER]; for (i = 0; i < HAND_SZ; i++) @@ -107,10 +107,9 @@ prboard() { * Show the given card if it is different from the last one shown */ static void -show_card(y, x, c, lc) -int y, x; -CARD c, *lc; +show_card(int y, int x, CARD c, CARD *lc) { + if (c == *lc) return; @@ -121,9 +120,8 @@ CARD c, *lc; static char Score_fmt[] = "%4d"; void -prscore(for_real) -bool for_real; { - +prscore(void) +{ PLAY *pp; int x; @@ -168,10 +166,9 @@ bool for_real; { * showed it. */ static void -show_score(y, x, s, ls) -int y, x; -int s, *ls; +show_score(int y, int x, int s, int *ls) { + if (s == *ls) return; diff --git a/games/mille/roll.c b/games/mille/roll.c index 714b51f..74b8cb2 100644 --- a/games/mille/roll.c +++ b/games/mille/roll.c @@ -49,9 +49,8 @@ static const char rcsid[] = */ int -roll(ndie, nsides) -int ndie, nsides; { - +roll(int ndie, int nsides) +{ int tot; tot = 0; diff --git a/games/mille/save.c b/games/mille/save.c index 54a1d38..f52fbf7 100644 --- a/games/mille/save.c +++ b/games/mille/save.c @@ -67,11 +67,11 @@ typedef struct stat STAT; */ bool -save() { - +save(void) +{ extern int errno; char *sp; - int outf; + int loutf; time_t *tp; char buf[80]; time_t tme; @@ -122,7 +122,7 @@ over: && getyn(OVERWRITEFILEPROMPT) == FALSE)) return FALSE; - if ((outf = creat(buf, 0644)) < 0) { + if ((loutf = creat(buf, 0644)) < 0) { error(strerror(errno)); return FALSE; } @@ -134,8 +134,8 @@ over: for (; *sp != '\n'; sp++) continue; *sp = '\0'; - varpush(outf, write); - close(outf); + varpush(loutf, write); + close(loutf); wprintw(Score, " [%s]", buf); wclrtoeol(Score); wrefresh(Score); @@ -148,9 +148,8 @@ over: * be cleaned up before the game starts. */ bool -rest_f(file) -char *file; { - +rest_f(char *file) +{ char *sp; int inf; char buf[80]; diff --git a/games/mille/types.c b/games/mille/types.c index d54f46f..2c3839b 100644 --- a/games/mille/types.c +++ b/games/mille/types.c @@ -46,15 +46,15 @@ static const char rcsid[] = */ int -isrepair(card) -CARD card; { +isrepair(CARD card) +{ return card == C_GAS || card == C_SPARE || card == C_REPAIRS || card == C_INIT; } CARD -safety(card) -CARD card; { +safety(CARD card) +{ switch (card) { case C_EMPTY: diff --git a/games/mille/varpush.c b/games/mille/varpush.c index 853f005..ba98123 100644 --- a/games/mille/varpush.c +++ b/games/mille/varpush.c @@ -51,10 +51,8 @@ static const char rcsid[] = * channel file. func() is either read or write. */ void -varpush(file, func) -int file; -int (*func)(); { - +varpush(int file, int (*func)()) +{ int temp; (*func)(file, (char *) &Debug, sizeof Debug); |