Mercurial > hg > early-roguelike
changeset 285:17005af49963
Fix some potential problems detected by clang.
Most of these are unnecessary comparisons and functions returning the
wrong types.
author | John "Elwin" Edwards |
---|---|
date | Sat, 23 Sep 2017 09:47:00 -0400 |
parents | 6376b514a30b |
children | 3b61f1dfcc91 |
files | arogue5/main.c arogue5/mdport.c arogue5/rogue.h arogue7/mdport.c arogue7/rogue.h rogue3/init.c rogue3/rogue.h rogue4/main.c srogue/main.c xrogue/rogue.h xrogue/state.c |
diffstat | 11 files changed, 24 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/arogue5/main.c Fri Sep 22 16:24:40 2017 -0400 +++ b/arogue5/main.c Sat Sep 23 09:47:00 2017 -0400 @@ -200,8 +200,7 @@ } if (!use_savedir) { - if ((whoami == NULL) || (*whoami == '\0') || - (strcmp(whoami,"dosuser")==0)) + if ((*whoami == '\0') || (strcmp(whoami,"dosuser")==0)) { echo(); mvaddstr(23,2,"Rogue's Name? "); @@ -209,7 +208,7 @@ noecho(); } - if ((whoami == NULL) || (*whoami == '\0')) + if (*whoami == '\0') strcpy(whoami,"Rodney"); }
--- a/arogue5/mdport.c Fri Sep 22 16:24:40 2017 -0400 +++ b/arogue5/mdport.c Sat Sep 23 09:47:00 2017 -0400 @@ -132,7 +132,7 @@ static int md_standout_mode = 0; -int +void md_raw_standout(void) { #ifdef _WIN32 @@ -155,7 +155,7 @@ #endif } -int +void md_raw_standend(void) { #ifdef _WIN32 @@ -223,7 +223,7 @@ #endif } -int +void md_normaluser(void) { #ifndef _WIN32 @@ -596,7 +596,7 @@ #endif } -int +void md_srand(int seed) { #ifdef _WIN32
--- a/arogue5/rogue.h Fri Sep 22 16:24:40 2017 -0400 +++ b/arogue5/rogue.h Sat Sep 23 09:47:00 2017 -0400 @@ -1189,12 +1189,12 @@ extern void md_init(void); extern FILE * md_fdopen(int fd, char *mode); extern int md_unlink(char *file); -extern int md_normaluser(void); +extern void md_normaluser(void); extern int md_getuid(void); extern long md_memused(void); extern int md_readchar(WINDOW *win); extern int md_shellescape(void); -extern int md_srand(int seed); +extern void md_srand(int seed); extern int md_rand(void); extern int md_erasechar(void); extern int md_killchar(void);
--- a/arogue7/mdport.c Fri Sep 22 16:24:40 2017 -0400 +++ b/arogue7/mdport.c Sat Sep 23 09:47:00 2017 -0400 @@ -111,7 +111,7 @@ static int md_standout_mode = 0; -int +void md_raw_standout(void) { #ifdef _WIN32 @@ -134,7 +134,7 @@ #endif } -int +void md_raw_standend(void) { #ifdef _WIN32 @@ -213,7 +213,7 @@ } -int +void md_normaluser(void) { #ifndef _WIN32 @@ -581,7 +581,7 @@ #endif } -int +void md_srand(int seed) { #ifdef _WIN32
--- a/arogue7/rogue.h Fri Sep 22 16:24:40 2017 -0400 +++ b/arogue7/rogue.h Sat Sep 23 09:47:00 2017 -0400 @@ -1417,12 +1417,12 @@ void md_init(void); int md_killchar(void); long md_memused(void); -int md_normaluser(void); +void md_normaluser(void); int md_rand(void); unsigned int md_random_seed(void); int md_readchar(WINDOW *win); int md_shellescape(void); -int md_srand(int seed); +void md_srand(int seed); int md_unlink(char *file); int md_unlink_open_file(char *file, FILE *inf);
--- a/rogue3/init.c Fri Sep 22 16:24:40 2017 -0400 +++ b/rogue3/init.c Sat Sep 23 09:47:00 2017 -0400 @@ -65,7 +65,7 @@ char *ws_type[MAXSTICKS]; /* Is it a wand or a staff */ char file_name[256]; /* Save file name */ char home[PATH_MAX]; /* User's home directory */ -unsigned char prbuf[80]; /* Buffer for sprintfs */ +char prbuf[80]; /* Buffer for sprintfs */ int max_hp; /* Player's max hit points */ int ntraps; /* Number of traps on this level */ int max_level; /* Deepest player has gone */
--- a/rogue3/rogue.h Fri Sep 22 16:24:40 2017 -0400 +++ b/rogue3/rogue.h Sat Sep 23 09:47:00 2017 -0400 @@ -469,7 +469,7 @@ extern struct magic_item p_magic[MAXPOTIONS]; /* Names and chances for potions */ extern struct thing player; /* The rogue */ extern int playing; /* True until he quits */ -extern unsigned char prbuf[80]; /* Buffer for sprintfs */ +extern char prbuf[80]; /* Buffer for sprintfs */ extern int purse; /* How much gold the rogue has */ extern int quiet; /* Number of quiet turns */ extern char * r_guess[MAXRINGS]; /* Players guess at what ring is */
--- a/rogue4/main.c Fri Sep 22 16:24:40 2017 -0400 +++ b/rogue4/main.c Sat Sep 23 09:47:00 2017 -0400 @@ -181,7 +181,7 @@ exit(1); } - if ((whoami == NULL) || (*whoami == '\0') || (strcmp(whoami,"dosuser")==0)) + if ((*whoami == '\0') || (strcmp(whoami,"dosuser")==0)) { echo(); mvaddstr(23,2,"Rogue's Name? "); @@ -189,7 +189,7 @@ noecho(); } - if ((whoami == NULL) || (*whoami == '\0')) + if (*whoami == '\0') strcpy(whoami,"Rodney"); setup();
--- a/srogue/main.c Fri Sep 22 16:24:40 2017 -0400 +++ b/srogue/main.c Sat Sep 23 09:47:00 2017 -0400 @@ -201,7 +201,7 @@ byebye(1); } - if ((whoami == NULL) || (*whoami == '\0') || (strcmp(whoami,"dosuser")==0)) + if ((*whoami == '\0') || (strcmp(whoami,"dosuser")==0)) { echo(); mvaddstr(23,2,"Rogue's Name? "); @@ -209,7 +209,7 @@ noecho(); } - if ((whoami == NULL) || (*whoami == '\0')) + if (*whoami == '\0') strcpy(whoami,"Rodney"); setup();
--- a/xrogue/rogue.h Fri Sep 22 16:24:40 2017 -0400 +++ b/xrogue/rogue.h Sat Sep 23 09:47:00 2017 -0400 @@ -1503,12 +1503,12 @@ int md_getuid(void); long md_memused(void); -int md_normaluser(void); +void md_normaluser(void); int md_rand(int range); unsigned int md_random_seed(void); void md_setup(void); int md_shellescape(void); -int md_srand(int seed); +void md_srand(int seed); /* * Now all the global variables