From 0ded4cf7e232ab0f194c8abbe35f38f8811dd6ff Mon Sep 17 00:00:00 2001 From: Zach Langley Date: Fri, 7 Nov 2014 21:19:32 -0800 Subject: [PATCH] Fix more warnings and some style. --- src/house.c | 2 +- src/interpreter.c | 6 ++--- src/msgedit.c | 2 +- src/mud_event.c | 11 ++++---- src/oasis_list.c | 68 +++++++++++++++++++++++++---------------------- src/utils.c | 4 +-- 6 files changed, 48 insertions(+), 45 deletions(-) diff --git a/src/house.c b/src/house.c index a0585e3..7ef1a8a 100644 --- a/src/house.c +++ b/src/house.c @@ -219,7 +219,7 @@ static void House_save_control(void) return; } /* write all the house control recs in one fell swoop. Pretty nifty, eh? */ - if (fwrite(house_control, sizeof(struct house_control_rec), num_of_houses, fl) != num_of_houses) { + if (fwrite(house_control, sizeof(struct house_control_rec), num_of_houses, fl) != (size_t)num_of_houses) { perror("SYSERR: Unable to save house control file."); return; } diff --git a/src/interpreter.c b/src/interpreter.c index 48336bf..3dcf2d4 100644 --- a/src/interpreter.c +++ b/src/interpreter.c @@ -1282,7 +1282,7 @@ EVENTFUNC(get_protocols) struct descriptor_data *d; struct mud_event_data *pMudEvent; char buf[MAX_STRING_LENGTH]; - int len; + size_t len; if (event_obj == NULL) return 0; @@ -1298,9 +1298,9 @@ EVENTFUNC(get_protocols) if (d->pProtocol->pVariables[eMSDP_XTERM_256_COLORS]->ValueInt) len += snprintf(buf + len, MAX_STRING_LENGTH - len, "\tO[\toColors\tO] \tw256\tn | "); else if (d->pProtocol->pVariables[eMSDP_ANSI_COLORS]->ValueInt) - len += snprintf(buf + len, MAX_STRING_LENGTH - len, "\tO[\toColors\tO] \twAnsi\tn | "); + len += snprintf(buf + len, MAX_STRING_LENGTH - len, "\tO[\toColors\tO] \twAnsi\tn | "); else - len += snprintf(buf + len, MAX_STRING_LENGTH - len, "[Colors] No Color | "); + len += snprintf(buf + len, MAX_STRING_LENGTH - len, "[Colors] No Color | "); len += snprintf(buf + len, MAX_STRING_LENGTH - len, "\tO[\toMXP\tO] \tw%s\tn | ", d->pProtocol->bMXP ? "Yes" : "No"); len += snprintf(buf + len, MAX_STRING_LENGTH - len, "\tO[\toMSDP\tO] \tw%s\tn | ", d->pProtocol->bMSDP ? "Yes" : "No"); diff --git a/src/msgedit.c b/src/msgedit.c index 064325d..2ce9856 100644 --- a/src/msgedit.c +++ b/src/msgedit.c @@ -133,7 +133,7 @@ static void show_messages(struct char_data *ch) { int i, half = MAX_MESSAGES / 2, count = 0; char buf[MAX_STRING_LENGTH]; - int len; + size_t len; len = snprintf(buf, sizeof(buf), "\t1Message List:\tn \r\n"); diff --git a/src/mud_event.c b/src/mud_event.c index 3272f0a..7f29252 100644 --- a/src/mud_event.c +++ b/src/mud_event.c @@ -76,9 +76,9 @@ EVENTFUNC(event_countdown) case eSPL_DARKNESS: REMOVE_BIT_AR(ROOM_FLAGS(rnum), ROOM_DARK); send_to_room(rnum, "The dark shroud disappates.\r\n"); - break; + break; default: - break; + break; } return 0; @@ -231,13 +231,13 @@ void clear_char_event_list(struct char_data * ch) } /* change_event_duration contributed by Ripley */ -void change_event_duration(struct char_data * ch, event_id iId, long time) { - +void change_event_duration(struct char_data * ch, event_id iId, long time) +{ struct event * pEvent; struct mud_event_data * pMudEvent; bool found = FALSE; - if (ch->events == NULL); + if (ch->events == NULL) return; if (ch->events->iSize == 0) @@ -246,7 +246,6 @@ void change_event_duration(struct char_data * ch, event_id iId, long time) { clear_simple_list(); while ((pEvent = (struct event *) simple_list(ch->events)) != NULL) { - if (!pEvent->isMudEvent) continue; diff --git a/src/oasis_list.c b/src/oasis_list.c index 3a132cf..e666070 100644 --- a/src/oasis_list.c +++ b/src/oasis_list.c @@ -41,7 +41,8 @@ static void list_zones(struct char_data *ch, zone_rnum rnum, zone_vnum vmin, zon void perform_mob_flag_list(struct char_data * ch, char *arg) { - int num, mob_flag, found = 0, len; + int num, mob_flag, found = 0; + size_t len; struct char_data *mob; char buf[MAX_STRING_LENGTH]; @@ -54,8 +55,8 @@ void perform_mob_flag_list(struct char_data * ch, char *arg) len = snprintf(buf, sizeof(buf), "Listing mobiles with %s%s%s flag set.\r\n", QYEL, action_bits[mob_flag], QNRM); - for(num=0;num<=top_of_mobt;num++) { - if(IS_SET_AR((mob_proto[num].char_specials.saved.act), mob_flag)) { + for (num = 0; num <= top_of_mobt; num++) { + if (IS_SET_AR((mob_proto[num].char_specials.saved.act), mob_flag)) { if ((mob = read_mobile(num, REAL)) != NULL) { char_to_room(mob, 0); @@ -77,7 +78,8 @@ void perform_mob_flag_list(struct char_data * ch, char *arg) void perform_mob_level_list(struct char_data * ch, char *arg) { - int num, mob_level, found = 0, len; + int num, mob_level, found = 0; + size_t len; struct char_data *mob; char buf[MAX_STRING_LENGTH]; @@ -89,9 +91,8 @@ void perform_mob_level_list(struct char_data * ch, char *arg) } len = snprintf(buf, sizeof(buf), "Listing mobiles of level %s%d%s\r\n", QYEL, mob_level, QNRM); - for(num=0;num<=top_of_mobt;num++) { - if((mob_proto[num].player.level) == mob_level) { - + for (num = 0; num <= top_of_mobt; num++) { + if ((mob_proto[num].player.level) == mob_level) { if ((mob = read_mobile(num, REAL)) != NULL) { char_to_room(mob, 0); len += snprintf(buf + len, sizeof(buf) - len, "%s%3d. %s[%s%5d%s]%s %s%s\r\n", CCNRM(ch, C_NRM),++found, @@ -116,8 +117,8 @@ void add_to_obj_list(struct obj_list_item *lst, int num_items, obj_vnum nvo, int int j, tmp_v; obj_vnum tmp_ov; - for(j=0;j lst[j].val) { + for (j = 0; j < num_items; j++) { + if (nval > lst[j].val) { tmp_ov = lst[j].vobj; tmp_v = lst[j].val; @@ -132,7 +133,8 @@ void add_to_obj_list(struct obj_list_item *lst, int num_items, obj_vnum nvo, int void perform_obj_type_list(struct char_data * ch, char *arg) { - int num, itemtype, v1, v2, found = 0, len = 0, tmp_len = 0; + int num, itemtype, v1, v2, found = 0; + size_t len = 0, tmp_len = 0; obj_vnum ov; obj_rnum r_num; char buf[MAX_STRING_LENGTH]; @@ -142,8 +144,8 @@ void perform_obj_type_list(struct char_data * ch, char *arg) len = snprintf(buf, sizeof(buf), "Listing all objects of type %s[%s]%s\r\n", QYEL, item_types[itemtype], QNRM); - for(num=0;num<=top_of_objt;num++) { - if(obj_proto[num].obj_flags.type_flag == itemtype) { + for (num = 0; num <= top_of_objt; num++) { + if (obj_proto[num].obj_flags.type_flag == itemtype) { if ((r_num = real_object(obj_index[num].vnum)) != NOTHING) { /* Seems silly? */ /* Set default vals, which may be changed below */ ov = obj_index[num].vnum; @@ -246,25 +248,26 @@ void perform_obj_type_list(struct char_data * ch, char *arg) void perform_obj_aff_list(struct char_data * ch, char *arg) { - int num, i, apply, v1 = 0, found = 0, len = 0, tmp_len = 0; + int num, i, apply, v1 = 0, found = 0; + size_t len = 0, tmp_len = 0; struct obj_list_item lst[MAX_OBJ_LIST]; obj_rnum r_num; obj_vnum ov; char buf[MAX_STRING_LENGTH]; - for(i=0;i0 && apply= NUM_APPLIES) { send_to_char(ch, "Not a valid affect"); return; } /* Special cases below */ else if ((apply == APPLY_CLASS) || /* olist affect 7 is Weapon Damage */ (apply == APPLY_LEVEL) ) { /* olist affect 8 is AC-Apply for Armor */ - for (num=0;num<=top_of_objt;num++) { + for (num = 0; num <= top_of_objt; num++) { if ((apply == APPLY_CLASS && obj_proto[num].obj_flags.type_flag == ITEM_WEAPON) || (apply == APPLY_LEVEL && obj_proto[num].obj_flags.type_flag == ITEM_ARMOR) ) { ov = obj_index[num].vnum; @@ -283,7 +286,7 @@ void perform_obj_aff_list(struct char_data * ch, char *arg) else if (apply == APPLY_LEVEL) len = snprintf(buf, sizeof(buf), "Highest AC Apply for Armor\r\n"); - for(i=0;i%s - List top %d objects with affect\r\n", QYEL, QNRM, MAX_OBJ_LIST); send_to_char(ch, "Just type %solist affect%s or %solist type%s to view available options\r\n", QYEL, QNRM, QYEL, QNRM); return; - } - else if (is_abbrev(arg, "type") || is_abbrev(arg, "affect")) { + } else if (is_abbrev(arg, "type") || is_abbrev(arg, "affect")) { if (is_abbrev(arg, "type")) { if (!*arg2) { send_to_char(ch, "Which object type do you want to list?\r\n"); @@ -459,8 +460,7 @@ ACMD(do_oasis_list) } else { /* Assume arg = affect */ if (!*arg2) { send_to_char(ch, "Which object affect do you want to list?\r\n"); - for (i=0; i sizeof(buf)) break; } @@ -752,7 +755,8 @@ static void list_shops(struct char_data *ch, zone_rnum rnum, shop_vnum vmin, sho /* List all zones in the world (sort of like 'show zones'). */ static void list_zones(struct char_data *ch, zone_rnum rnum, zone_vnum vmin, zone_vnum vmax, char *name) { - int counter = 0, len=0, tmp_len = 0; + int counter = 0; + size_t len = 0, tmp_len = 0; zone_rnum i; zone_vnum bottom, top; char buf[MAX_STRING_LENGTH]; diff --git a/src/utils.c b/src/utils.c index 52b9cc0..fb47a05 100644 --- a/src/utils.c +++ b/src/utils.c @@ -983,8 +983,8 @@ void char_from_furniture(struct char_data *ch) */ void column_list(struct char_data *ch, int num_cols, const char **list, int list_length, bool show_nums) { - size_t max_len = 0; - int num_per_col, col_width,r,c,i, offset=0, len=0, temp_len; + size_t max_len = 0, len = 0, temp_len; + int num_per_col, col_width, r, c, i, offset = 0; char buf[MAX_STRING_LENGTH]; /* Work out the longest list item */