From 4590ba16d6a2f3c955b11cab480527437e0b7bc1 Mon Sep 17 00:00:00 2001 From: wyld-sw Date: Fri, 20 Jan 2017 15:59:11 -0500 Subject: [PATCH] Addressed warnings from -Weverything subset: -Wconditional-uninitialized -Wshadow -Wswitch-enum -Wunreachable-code-break -Wunused-macros --- src/act.wizard.c | 6 ------ src/bsd-snprintf.c | 1 - src/class.c | 11 ----------- src/db.c | 5 +---- src/dg_mobcmd.c | 1 - src/dg_triggers.c | 2 -- src/genolc.c | 2 -- src/ibt.c | 2 -- src/interpreter.c | 1 - src/lists.c | 2 -- src/magic.c | 2 +- src/medit.c | 1 - src/mud_event.c | 8 +++++++- src/oasis_list.c | 2 -- src/objsave.c | 2 +- src/protocol.c | 1 - src/qedit.c | 3 +-- src/quest.c | 1 - src/sedit.c | 1 - src/zmalloc.c | 3 --- 20 files changed, 11 insertions(+), 46 deletions(-) diff --git a/src/act.wizard.c b/src/act.wizard.c index 470699c..13eabfe 100644 --- a/src/act.wizard.c +++ b/src/act.wizard.c @@ -3228,7 +3228,6 @@ static int perform_set(struct char_data *ch, struct char_data *vict, int mode, c break; case 53: /* variable */ return perform_set_dg_var(ch, vict, val_arg); - break; case 54: /* weight */ GET_WEIGHT(vict) = value; affect_total(vict); @@ -3484,11 +3483,6 @@ struct zcheck_armor { {ITEM_WEAR_HOLD, 10, "Held item"} }; -/*These are strictly boolean*/ -#define CAN_WEAR_WEAPONS 0 /* toggle - can a weapon also be a piece of armor? */ -#define MAX_APPLIES_LIMIT 1 /* toggle - is there a limit at all? */ -#define CHECK_ITEM_RENT 0 /* do we check for rent cost == 0 ? */ -#define CHECK_ITEM_COST 0 /* do we check for item cost == 0 ? */ /* Applies limits !! Very Important: Keep these in the same order as in Structs.h. * To ignore an apply, set max_aff to -99. These will be ignored if MAX_APPLIES_LIMIT = 0 */ struct zcheck_affs { diff --git a/src/bsd-snprintf.c b/src/bsd-snprintf.c index 274957a..ec1abd4 100644 --- a/src/bsd-snprintf.c +++ b/src/bsd-snprintf.c @@ -93,7 +93,6 @@ # include "conf.h" # include "sysdep.h" -# define MAX(a, b) ((a) < (b) ? (b) : (a)) #if defined(BROKEN_SNPRINTF) /* For those with broken snprintf() */ # undef HAVE_SNPRINTF diff --git a/src/class.c b/src/class.c index dab0fb8..17de38e 100644 --- a/src/class.c +++ b/src/class.c @@ -8,9 +8,6 @@ * CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. * **************************************************************************/ -/** Help buffer the global variable definitions */ -#define __CLASS_C__ - /* This file attempts to concentrate most of the code which must be changed * in order for new classes to be added. If you're adding a new class, you * should go through this entire file from beginning to end and add the @@ -1866,7 +1863,6 @@ const char *title_male(int chclass, int level) case LVL_GRGOD: return "the God of Magic"; default: return "the Mage"; } - break; case CLASS_CLERIC: switch (level) { @@ -1896,7 +1892,6 @@ const char *title_male(int chclass, int level) case LVL_GRGOD: return "the God of Good and Evil"; default: return "the Cleric"; } - break; case CLASS_THIEF: switch (level) { @@ -1926,7 +1921,6 @@ const char *title_male(int chclass, int level) case LVL_GRGOD: return "the God of Thieves and Tradesmen"; default: return "the Thief"; } - break; case CLASS_WARRIOR: switch(level) { @@ -1956,7 +1950,6 @@ const char *title_male(int chclass, int level) case LVL_GRGOD: return "the God of War"; default: return "the Warrior"; } - break; } /* Default title for classes which do not have titles defined */ @@ -2010,7 +2003,6 @@ const char *title_female(int chclass, int level) case LVL_GRGOD: return "the Goddess of Magic"; default: return "the Witch"; } - break; case CLASS_CLERIC: switch (level) { @@ -2040,7 +2032,6 @@ const char *title_female(int chclass, int level) case LVL_GRGOD: return "the Goddess of Good and Evil"; default: return "the Cleric"; } - break; case CLASS_THIEF: switch (level) { @@ -2070,7 +2061,6 @@ const char *title_female(int chclass, int level) case LVL_GRGOD: return "the Goddess of Thieves and Tradesmen"; default: return "the Thief"; } - break; case CLASS_WARRIOR: switch(level) { @@ -2100,7 +2090,6 @@ const char *title_female(int chclass, int level) case LVL_GRGOD: return "the Goddess of War"; default: return "the Warrior"; } - break; } /* Default title for classes which do not have titles defined */ diff --git a/src/db.c b/src/db.c index 2c76af1..3019139 100644 --- a/src/db.c +++ b/src/db.c @@ -1553,12 +1553,9 @@ static void parse_simple_mob(FILE *mob_f, int i, int nr) * assigns the correct value to the mob as appropriate. Adding new e-specs is * absurdly easy -- just add a new CASE statement to this function! No other * changes need to be made anywhere in the code. - * CASE : Requires a parameter through 'value'. - * BOOL_CASE : Being specified at all is its value. */ + * CASE : Requires a parameter through 'value'. */ #define CASE(test) \ if (value && !matched && !str_cmp(keyword, test) && (matched = TRUE)) -#define BOOL_CASE(test) \ - if (!value && !matched && !str_cmp(keyword, test) && (matched = TRUE)) #define RANGE(low, high) \ (num_arg = MAX((low), MIN((high), (num_arg)))) diff --git a/src/dg_mobcmd.c b/src/dg_mobcmd.c index e02071e..bb0ed94 100644 --- a/src/dg_mobcmd.c +++ b/src/dg_mobcmd.c @@ -45,7 +45,6 @@ static void mob_log(char_data *mob, const char *format, ...) /* Macro to determine if a mob is permitted to use these commands. */ #define MOB_OR_IMPL(ch) \ ((IS_NPC(ch) && (!(ch)->desc || GET_LEVEL((ch)->desc->original) >= LVL_IMPL)) || (SCRIPT(ch) && TRIGGERS(SCRIPT(ch)))) -#define MOB_OR_PLAYER(ch) (GET_LEVEL(ch) > 0) /* mob commands */ /* prints the argument to all the rooms aroud the mobile */ diff --git a/src/dg_triggers.c b/src/dg_triggers.c index d48c754..3035b27 100644 --- a/src/dg_triggers.c +++ b/src/dg_triggers.c @@ -285,7 +285,6 @@ int entry_mtrigger(char_data *ch) for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) { if (TRIGGER_CHECK(t, MTRIG_ENTRY) && (rand_number(1, 100) <= GET_TRIG_NARG(t))){ return script_driver(&ch, t, MOB_TRIGGER, TRIG_NEW); - break; } } @@ -1134,7 +1133,6 @@ int drop_wtrigger(obj_data *obj, char_data *actor) return 0; else return ret_val; - break; } return 1; diff --git a/src/genolc.c b/src/genolc.c index 724390e..2ee33e2 100644 --- a/src/genolc.c +++ b/src/genolc.c @@ -5,8 +5,6 @@ * Copyright 1996 by Harvey Gilpin, 1997-2001 by George Greer. * **************************************************************************/ -#define __GENOLC_C__ - #include "conf.h" #include "sysdep.h" #include "structs.h" diff --git a/src/ibt.c b/src/ibt.c index ad8b955..dd500ea 100755 --- a/src/ibt.c +++ b/src/ibt.c @@ -1018,7 +1018,6 @@ void ibtedit_parse(struct descriptor_data *d, char *arg) write_to_output(d, "Do you wish to save your changes? : "); return; } - break; case IBTEDIT_MAIN_MENU: switch (*arg) { @@ -1080,7 +1079,6 @@ void ibtedit_parse(struct descriptor_data *d, char *arg) ibtedit_disp_main_menu(d); return; } - break; case IBTEDIT_NAME: smash_tilde(arg); diff --git a/src/interpreter.c b/src/interpreter.c index ed9ee6c..b01684f 100644 --- a/src/interpreter.c +++ b/src/interpreter.c @@ -1354,7 +1354,6 @@ void nanny(struct descriptor_data *d, char *arg) case CON_GET_PROTOCOL: write_to_output(d, "Collecting Protocol Information... Please Wait.\r\n"); return; - break; case CON_GET_NAME: /* wait for input of name */ if (d->character == NULL) { CREATE(d->character, struct char_data, 1); diff --git a/src/lists.c b/src/lists.c index 8d3231c..6ec4c8f 100644 --- a/src/lists.c +++ b/src/lists.c @@ -205,7 +205,6 @@ void * next_in_list(struct iterator_data * pIterator) struct item_data * find_in_list(void * pContent, struct list_data * pList) { - struct iterator_data Iterator; void * pFoundItem; struct item_data *pItem = NULL; bool found; @@ -281,7 +280,6 @@ void * simple_list(struct list_data * pList) void * random_from_list(struct list_data * pList) { - struct iterator_data Iterator; void * pFoundItem; bool found; int number; diff --git a/src/magic.c b/src/magic.c index bcfefec..5c6e9cc 100644 --- a/src/magic.c +++ b/src/magic.c @@ -969,7 +969,7 @@ void mag_creations(int level, struct char_data *ch, int spellnum) void mag_rooms(int level, struct char_data *ch, int spellnum) { room_rnum rnum; - int duration; + int duration = 0; bool failure = FALSE; event_id IdNum = eNULL; const char *msg = NULL; diff --git a/src/medit.c b/src/medit.c index a02bd97..9cba8f2 100644 --- a/src/medit.c +++ b/src/medit.c @@ -571,7 +571,6 @@ void medit_parse(struct descriptor_data *d, char *arg) write_to_output(d, "Do you wish to save your changes? : "); return; } - break; case MEDIT_MAIN_MENU: i = 0; diff --git a/src/mud_event.c b/src/mud_event.c index 7f29252..97ba251 100644 --- a/src/mud_event.c +++ b/src/mud_event.c @@ -77,6 +77,12 @@ EVENTFUNC(event_countdown) REMOVE_BIT_AR(ROOM_FLAGS(rnum), ROOM_DARK); send_to_room(rnum, "The dark shroud disappates.\r\n"); break; + case ePROTOCOLS: + break; + case eWHIRLWIND: + break; + case eNULL: + break; default: break; } @@ -234,7 +240,7 @@ void clear_char_event_list(struct char_data * ch) void change_event_duration(struct char_data * ch, event_id iId, long time) { struct event * pEvent; - struct mud_event_data * pMudEvent; + struct mud_event_data * pMudEvent = 0; bool found = FALSE; if (ch->events == NULL) diff --git a/src/oasis_list.c b/src/oasis_list.c index e666070..63c956d 100644 --- a/src/oasis_list.c +++ b/src/oasis_list.c @@ -408,8 +408,6 @@ ACMD(do_oasis_list) return; } else if (is_abbrev(arg, "level") || is_abbrev(arg, "flags")) { - int i; - if (!*arg2) { send_to_char(ch, "Which mobile flag or level do you want to list?\r\n"); for (i = 0; i < NUM_MOB_FLAGS; i++) { diff --git a/src/objsave.c b/src/objsave.c index 1a6e205..be45bf6 100644 --- a/src/objsave.c +++ b/src/objsave.c @@ -1185,7 +1185,7 @@ static int Crash_load_objs(struct char_data *ch) { unsigned long cost; struct obj_data *cont_row[MAX_BAG_ROWS]; int rentcode = RENT_UNDEF; - int timed,netcost,gold,account,nitems; + int timed=0,netcost=0,gold,account,nitems; obj_save_data *loaded, *current; if (!get_filename(filename, sizeof(filename), CRASH_FILE, GET_NAME(ch))) diff --git a/src/protocol.c b/src/protocol.c index 16a0271..6517354 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -113,7 +113,6 @@ static const char s_Gauge5[] = "\005\002Opponent\002darkred\002OPPONENT_HEALTH\ #define NUMBER_READ_ONLY false, false, false, false, -1, -1, 0, NULL #define NUMBER_READ_ONLY_SET_TO(x) false, false, false, false, -1, -1, x, NULL #define STRING_READ_ONLY true, false, false, false, -1, -1, 0, NULL -#define NUMBER_IN_THE_RANGE(x,y) false, true, false, false, x, y, 0, NULL #define BOOLEAN_SET_TO(x) false, true, false, false, 0, 1, x, NULL #define STRING_WITH_LENGTH_OF(x,y) true, true, false, false, x, y, 0, NULL #define STRING_WRITE_ONCE(x,y) true, true, true, false, -1, -1, 0, NULL diff --git a/src/qedit.c b/src/qedit.c index 32dff0d..c71a193 100644 --- a/src/qedit.c +++ b/src/qedit.c @@ -407,7 +407,6 @@ void qedit_parse(struct descriptor_data *d, char *arg) "Invalid choice!\r\nDo you wish to save the quest? : "); return; } - break; /*-------------------------------------------------------------------*/ case QEDIT_CONFIRM_DELETE: switch (*arg) { @@ -433,7 +432,6 @@ void qedit_parse(struct descriptor_data *d, char *arg) "Invalid choice!\r\nDo you wish to delete the quest? : "); return; } - break; /*-------------------------------------------------------------------*/ case QEDIT_MAIN_MENU: @@ -747,3 +745,4 @@ void qedit_string_cleanup(struct descriptor_data *d, int terminator) break; } } + diff --git a/src/quest.c b/src/quest.c index b0bb47c..3581e0a 100644 --- a/src/quest.c +++ b/src/quest.c @@ -206,7 +206,6 @@ void parse_quest(FILE *quest_f, int nr) case 'S': total_quests = ++i; return; - break; } } } /* parse_quest */ diff --git a/src/sedit.c b/src/sedit.c index bd1755b..c042fec 100644 --- a/src/sedit.c +++ b/src/sedit.c @@ -467,7 +467,6 @@ void sedit_parse(struct descriptor_data *d, char *arg) write_to_output(d, "Invalid choice!\r\nDo you wish to save your changes? : "); return; } - break; case SEDIT_MAIN_MENU: i = 0; diff --git a/src/zmalloc.c b/src/zmalloc.c index 82ca5c8..5e2cf0b 100644 --- a/src/zmalloc.c +++ b/src/zmalloc.c @@ -11,9 +11,6 @@ * Makefile: # Any special flags you want to pass to the compiler * Makefile: MYFLAGS = -Wall -DMEMORY_DEBUG */ -/* protect our calloc() and free() calls from recursive redefinition: */ -#define ZMALLOC_H - #include "conf.h" #include #include