From 7b2fb4d0b56c74ac3fea57b9232f778a65f79c23 Mon Sep 17 00:00:00 2001 From: keni Date: Fri, 18 Apr 2008 17:37:33 +0000 Subject: [PATCH] more warning cleanup (trunk only) More warning bits that never got committed. More appropriate compiler flags for warning checks (macosx only for the moment). The changes in dgn*[lc] just rename line_number to nh_line_number to avoid a clash, so no need to regenerate the lex output. --- src/cmd.c | 5 ++--- src/dungeon.c | 2 +- src/files.c | 12 ++++++------ sys/share/ioctl.c | 2 +- sys/unix/hints/macosx | 3 +++ util/dgn_comp.l | 6 +++--- util/dgn_main.c | 8 ++++---- 7 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/cmd.c b/src/cmd.c index 4d751d30d..b8bdf286e 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -160,7 +160,7 @@ STATIC_DCL char FDECL(cmd_from_func, (int NDECL((*)))); STATIC_PTR int NDECL(doattributes); STATIC_PTR int NDECL(doconduct); /**/ -STATIC_DCL void FDECL(enlght_line, (const char *,const char *,const char *,char *)); +STATIC_DCL void FDECL(enlght_line, (const char *,const char *,const char *,const char *)); STATIC_DCL char *FDECL(enlght_combatinc, (const char *,int,int,char *)); STATIC_DCL void FDECL(enlght_halfdmg, (int,int)); STATIC_DCL boolean NDECL(walking_on_water); @@ -991,8 +991,7 @@ static const char static void enlght_line(start, middle, end, ps) -const char *start, *middle, *end; -char *ps; +const char *start, *middle, *end, *ps; { char buf[BUFSZ]; diff --git a/src/dungeon.c b/src/dungeon.c index a38689b4c..798a59ed1 100644 --- a/src/dungeon.c +++ b/src/dungeon.c @@ -2069,7 +2069,7 @@ recalc_mapseen() { mapseen *mptr; struct monst *shkp; - int x, y, ridx; + unsigned int x, y, ridx; /* Should not happen in general, but possible if in the process * of being booted from the quest. The mapseen object gets diff --git a/src/files.c b/src/files.c index 411972145..cb10c0d40 100644 --- a/src/files.c +++ b/src/files.c @@ -2553,7 +2553,7 @@ parse_sym_line(buf, which_set) char *buf; int which_set; { - int i, val; + int val; struct symparse *symp = (struct symparse *)0; char *bufp, *commentp, *altp; @@ -2715,10 +2715,10 @@ int which_set; break; case 5: /* restrictions: xxxx*/ if (chosen_symset_start) { - i = 0; - while (known_restrictions[i]) { - if (!strcmpi(known_restrictions[i], bufp)) { - switch(i) { + int n = 0; + while (known_restrictions[n]) { + if (!strcmpi(known_restrictions[n], bufp)) { + switch(n) { case 0: symset[which_set].primary = 1; break; case 1: symset[which_set].rogue = 1; @@ -2728,7 +2728,7 @@ int which_set; } break; /* while loop */ } - i++; + n++; } /* Don't allow unicode set if code can't handle it */ if (symset[which_set].unicode && diff --git a/sys/share/ioctl.c b/sys/share/ioctl.c index 63bc29927..fa06f8fb9 100644 --- a/sys/share/ioctl.c +++ b/sys/share/ioctl.c @@ -54,7 +54,7 @@ struct termios termio; struct termio termio; # endif # endif -# ifdef AMIX +# if defined(AMIX) || defined(__APPLE__) #include # endif /* AMIX */ #endif diff --git a/sys/unix/hints/macosx b/sys/unix/hints/macosx index d542fc56a..10fac071d 100644 --- a/sys/unix/hints/macosx +++ b/sys/unix/hints/macosx @@ -44,6 +44,9 @@ GAMEUID = games GAMEGRP = $(GAMEUID) +#CC=gcc -W -Wimplicit -Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wcast-qual -Wwrite-strings -DGCC_WARN +CC=gcc -Wall -Wextra -Wno-missing-field-initializers -Wimplicit -Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wcast-qual -Wwrite-strings -DGCC_WARN + # # You shouldn't need to change anything below here. # diff --git a/util/dgn_comp.l b/util/dgn_comp.l index b95a54785..98a3aad6d 100644 --- a/util/dgn_comp.l +++ b/util/dgn_comp.l @@ -73,7 +73,7 @@ void FDECL(init_yyout, (FILE *)); extern YYSTYPE yylval; -int line_number = 1; +int nh_line_number = 1; %} %% @@ -110,8 +110,8 @@ RNDCHLEVEL return(RNDCHLEVEL); yylval.str = (char *) alloc(strlen(yytext+1)+1); Strcpy(yylval.str, yytext+1); /* Discard the first \" */ return(STRING); } -^#.*\n { line_number++; } -\r?\n { line_number++; } +^#.*\n { nh_line_number++; } +\r?\n { nh_line_number++; } [ \t]+ ; /* skip trailing tabs & spaces */ . { return yytext[0]; } %% diff --git a/util/dgn_main.c b/util/dgn_main.c index 250fd76a4..c83a6cf8c 100644 --- a/util/dgn_main.c +++ b/util/dgn_main.c @@ -33,7 +33,7 @@ #define MAX_ERRORS 25 extern int NDECL (yyparse); -extern int line_number; +extern int nh_line_number; const char *fname = "(stdin)"; int fatal_error = 0; @@ -135,7 +135,7 @@ char **argv; init_yyin(fin); init_yyout(fout); (void) yyparse(); - line_number = 1; + nh_line_number = 1; if (fatal_error > 0) { errors_encountered = TRUE; fatal_error = 0; @@ -161,7 +161,7 @@ char **argv; void yyerror(s) const char *s; { - (void) fprintf(stderr,"%s : line %d : %s\n",fname,line_number, s); + (void) fprintf(stderr,"%s : line %d : %s\n",fname,nh_line_number, s); if (++fatal_error > MAX_ERRORS) { (void) fprintf(stderr,"Too many errors, good bye!\n"); exit(EXIT_FAILURE); @@ -175,7 +175,7 @@ const char *s; void yywarning(s) const char *s; { - (void) fprintf(stderr,"%s : line %d : WARNING : %s\n",fname,line_number,s); + (void) fprintf(stderr,"%s : line %d : WARNING : %s\n",fname,nh_line_number,s); } int yywrap()