Make almost WARNS=5 compliant:

ANSI'fy function declarations.
Constify some globals and function paramters.
Remove unsused arguments.
Fix (rename) shadowed variables.
This commit is contained in:
Alfred Perlstein 2002-05-28 21:41:02 +00:00
parent a72b2ac607
commit 14e5925796
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=97429
13 changed files with 83 additions and 101 deletions

View File

@ -48,7 +48,7 @@ static const char rcsid[] =
# define V_VALUABLE 40
void
calcmove()
calcmove(void)
{
CARD card;
int *value;
@ -404,8 +404,7 @@ calcmove()
* 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:

View File

@ -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;

View File

@ -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 */

View File

@ -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;

View File

@ -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)

View File

@ -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

View File

@ -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 @@ bool forcomp; {
* 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;

View File

@ -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 @@ domove()
* 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 @@ PLAY *pp;
}
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 @@ getmove()
* 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;

View File

@ -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;

View File

@ -49,9 +49,8 @@ static const char rcsid[] =
*/
int
roll(ndie, nsides)
int ndie, nsides; {
roll(int ndie, int nsides)
{
int tot;
tot = 0;

View File

@ -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 @@ save() {
&& 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 @@ save() {
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 @@ save() {
* be cleaned up before the game starts.
*/
bool
rest_f(file)
char *file; {
rest_f(char *file)
{
char *sp;
int inf;
char buf[80];

View File

@ -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:

View File

@ -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);