? a.c ? out ? splint_cleanup1.diff.bz2 ? splint_weak ? files_to_check ? diff Index: ai/advdomestic.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/ai/advdomestic.c,v retrieving revision 1.77 diff -u -r1.77 advdomestic.c --- ai/advdomestic.c 2002/01/02 20:55:13 1.77 +++ ai/advdomestic.c 2002/02/04 20:08:36 @@ -683,6 +683,8 @@ choice->type = CT_NONMIL; choice->choice = unit_type; /* default */ ai_choose_ferryboat(pplayer, pcity, choice); + } else { + /* FIXME: handle this case */ } } @@ -708,6 +710,8 @@ choice->type = CT_NONMIL; choice->choice = unit_type; /* default */ ai_choose_ferryboat(pplayer, pcity, choice); + } else { + /* FIXME: handle this case */ } } Index: ai/advmilitary.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/ai/advmilitary.c,v retrieving revision 1.82 diff -u -r1.82 advmilitary.c --- ai/advmilitary.c 2002/01/29 22:06:14 1.82 +++ ai/advmilitary.c 2002/02/04 20:08:37 @@ -956,7 +956,9 @@ choice->type = CT_DEFENDER; choice->choice = u; return; - } else if (num_role_units(F_DIPLOMAT)>0) { + } + + if (num_role_units(F_DIPLOMAT)>0) { u = get_role_unit(F_DIPLOMAT, 0); pplayer->ai.tech_want[get_unit_type(u)->tech_requirement] += 16000; } Index: ai/aiunit.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/ai/aiunit.c,v retrieving revision 1.159 diff -u -r1.159 aiunit.c --- ai/aiunit.c 2002/01/29 22:06:14 1.159 +++ ai/aiunit.c 2002/02/04 20:08:38 @@ -350,6 +350,7 @@ handle_unit_activity_request(punit, ACTIVITY_IDLE); if (pplayer->ai.control && is_military_unit(punit)) { pcity = find_city_by_id(punit->homecity); + assert(pcity != NULL); if (pcity && map_get_continent(pcity->x, pcity->y) == con) ai_military_gohome(pplayer, punit); else if (pcity) { @@ -1535,7 +1536,9 @@ } } return; /* Jane, stop this crazy thing! */ - } else if (!is_tiles_adjacent(punit->x, punit->y, dest_x, dest_y)) { + } + + if (!is_tiles_adjacent(punit->x, punit->y, dest_x, dest_y)) { /* if what we want to kill is adjacent, and findvictim didn't want it, WAIT! */ if ((went = ai_military_gothere(pplayer, punit, dest_x, dest_y))) { if (went > 0) flag = punit->moves_left; Index: client/control.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/control.c,v retrieving revision 1.64 diff -u -r1.64 control.c --- client/control.c 2001/12/08 15:15:50 1.64 +++ client/control.c 2002/02/04 20:08:41 @@ -458,11 +458,13 @@ punit->x, punit->y)) { popup_diplomat_dialog(pdiplomat, punit->x, punit->y); return; - } else if (pcity - && is_diplomat_action_available(pdiplomat, DIPLOMAT_ANY_ACTION, - pcity->x, pcity->y) - && diplomat_can_do_action(pdiplomat, DIPLOMAT_ANY_ACTION, - pcity->x, pcity->y)) { + } + + if (pcity + && is_diplomat_action_available(pdiplomat, DIPLOMAT_ANY_ACTION, + pcity->x, pcity->y) + && diplomat_can_do_action(pdiplomat, DIPLOMAT_ANY_ACTION, pcity->x, + pcity->y)) { popup_diplomat_dialog(pdiplomat, pcity->x, pcity->y); return; } @@ -1044,9 +1046,8 @@ if(!pinfo->carried && !was_teleported) { int dx=pinfo->x - x; - if(dx>1) dx=-1; - else if(dx<-1) - dx=1; + if (dx > 1) dx = -1; + if (dx < -1) dx = 1; if(smooth_move_units) move_unit_map_canvas(punit, x, y, dx, pinfo->y - punit->y); refresh_tile_mapcanvas(x, y, 1); Index: client/helpdata.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/helpdata.c,v retrieving revision 1.40 diff -u -r1.40 helpdata.c --- client/helpdata.c 2002/01/17 10:26:29 1.40 +++ client/helpdata.c 2002/02/04 20:08:41 @@ -166,7 +166,8 @@ if (*ta != ' ') { if (*tb == ' ') return -1; break; - } else if (*tb != ' ') { + } + if (*tb != ' ') { if (*ta == ' ') return 1; break; } @@ -692,13 +693,16 @@ } if (utype->fuel>0) { sprintf(buf+strlen(buf), _("* Must end ")); - if (utype->fuel==2) { + if (utype->fuel==1) { + sprintf(buf+strlen(buf), _("the same ")); + } else if (utype->fuel==2) { sprintf(buf+strlen(buf), _("second ")); } else if (utype->fuel==3) { sprintf(buf+strlen(buf), _("third ")); - } else if (utype->fuel>=4) { + } else { sprintf(buf+strlen(buf), _("%dth "), utype->fuel); } + /* FIXME: should use something like get_units_with_flag_string() */ sprintf(buf+strlen(buf), _("turn in a city, or on a Carrier")); if (unit_type_flag(i, F_MISSILE) && Index: client/packhand.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v retrieving revision 1.209 diff -u -r1.209 packhand.c --- client/packhand.c 2002/02/02 09:21:31 1.209 +++ client/packhand.c 2002/02/04 20:08:43 @@ -275,7 +275,9 @@ if (impr_changed) { *impr_changed = TRUE; } - } else if (!have_impr && pcity->improvements[impr] != I_NONE) { + } + + if (!have_impr && pcity->improvements[impr] != I_NONE) { city_remove_improvement(pcity, impr); if (impr_changed) { @@ -768,10 +770,10 @@ { int where = MW_OUTPUT; /* where to display the message */ - if (packet->event >= E_LAST) { + if (packet->event < 0 || packet->event >= E_LAST) { /* Server may have added a new event; leave as MW_OUTPUT */ freelog(LOG_NORMAL, "Unknown event type %d!", packet->event); - } else if (packet->event >= 0) { + } else { where = messages_where[packet->event]; } if (where & MW_OUTPUT) @@ -865,6 +867,8 @@ punit = fc_malloc(sizeof(struct unit)); unpackage_unit(punit, packet); unit_list_insert(&(pcity->info_units_present), punit); + } else { + assert(0); } /* done with special case */ return; @@ -1122,7 +1126,8 @@ if (game.global_wonders[i] <= 0 && game.improvements[i] != I_NONE) { game.improvements[i] = I_NONE; need_effect_update = TRUE; - } else if (game.global_wonders[i] > 0 && game.improvements[i] == I_NONE) { + } + if (game.global_wonders[i] > 0 && game.improvements[i] == I_NONE) { game.improvements[i] = I_ACTIVE; need_effect_update = TRUE; } Index: client/gui-gtk/cityrep.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/cityrep.c,v retrieving revision 1.47 diff -u -r1.47 cityrep.c --- client/gui-gtk/cityrep.c 2002/02/02 09:21:34 1.47 +++ client/gui-gtk/cityrep.c 2002/02/04 20:08:49 @@ -354,9 +354,13 @@ if (index == CMA_CUSTOM && controlled && cmafec_preset_get_index_of_parameter(¶meter) == -1) { select = 1; - } else if (index == CMA_NONE && !controlled) { + } + + if (index == CMA_NONE && !controlled) { select = 1; - } else if (index >= 0 && controlled && + } + + if (index >= 0 && controlled && cma_are_parameter_equal(¶meter, cmafec_preset_get_parameter(index))) { select = 1; Index: client/gui-gtk/dialogs.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/dialogs.c,v retrieving revision 1.80 diff -u -r1.80 dialogs.c --- client/gui-gtk/dialogs.c 2001/12/21 16:26:38 1.80 +++ client/gui-gtk/dialogs.c 2002/02/04 20:08:51 @@ -2213,7 +2213,9 @@ if(w==races_quit_command) { exit(0); - } else if(w==races_disc_command) { + } + + if(w==races_disc_command) { popdown_races_dialog(); disconnect_from_server(); return; Index: client/gui-gtk/gamedlgs.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/gamedlgs.c,v retrieving revision 1.18 diff -u -r1.18 gamedlgs.c --- client/gui-gtk/gamedlgs.c 2001/04/21 22:37:44 1.18 +++ client/gui-gtk/gamedlgs.c 2002/02/04 20:08:51 @@ -101,6 +101,8 @@ lux=MIN(MAX(100-tax-sci, 0), maxrate); if(!tax_lock) tax=MIN(MAX(100-lux-sci, 0), maxrate); + } else { + assert(0); } if(tax+sci+lux!=100) { Index: client/gui-gtk/gui_main.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/gui_main.c,v retrieving revision 1.95 diff -u -r1.95 gui_main.c --- client/gui-gtk/gui_main.c 2002/01/28 04:41:39 1.95 +++ client/gui-gtk/gui_main.c 2002/02/04 20:08:52 @@ -916,7 +916,7 @@ gtk_widget_show(more_arrow_pixmap); showing = 1; } - else if(onoff == 0 && showing) { + if(onoff == 0 && showing) { gtk_widget_hide(more_arrow_pixmap); showing = 0; } Index: client/gui-gtk/mapctrl.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapctrl.c,v retrieving revision 1.52 diff -u -r1.52 mapctrl.c --- client/gui-gtk/mapctrl.c 2002/02/02 09:21:35 1.52 +++ client/gui-gtk/mapctrl.c 2002/02/04 20:08:52 @@ -404,7 +404,7 @@ if(event->button==1) do_unit_goto(xtile,ytile); - else if(event->button==3) + if(event->button==3) center_tile_mapcanvas(xtile, ytile); return TRUE; } Index: common/city.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/city.c,v retrieving revision 1.132 diff -u -r1.132 city.c --- common/city.c 2002/01/26 19:56:58 1.132 +++ common/city.c 2002/02/04 20:09:04 @@ -257,6 +257,7 @@ char *get_impr_name_ex(struct city *pcity, Impr_Type_id id) { static char buffer[256]; + /* stupid compiler needs this */ char *state = NULL; if (pcity) { @@ -271,6 +272,8 @@ } else { state = Q_("?wonder:w"); } + } else { + state = NULL; } if (state) { Index: common/combat.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/combat.c,v retrieving revision 1.9 diff -u -r1.9 combat.c --- common/combat.c 2001/09/15 15:31:24 1.9 +++ common/combat.c 2002/02/04 20:09:05 @@ -453,18 +453,12 @@ int unit_def = (int) (100000 * (1 - unit_win_chance(attacker, defender))); assert(unit_def >= 0); - if (unit_def > bestvalue) { - change = 1; - } else if (unit_def == bestvalue) { - if (build_cost < best_cost) { - change = 1; - } else if (build_cost == best_cost) { - if (rating_of_best < get_defense_rating(attacker, defender)) { - change = 1; - } - } - } - + change = (unit_def > bestvalue || + (unit_def == bestvalue && + (build_cost < best_cost || + (build_cost == best_cost + && rating_of_best < get_defense_rating(attacker, + defender))))); if (change) { bestvalue = unit_def; bestdef = defender; Index: common/connection.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/connection.c,v retrieving revision 1.17 diff -u -r1.17 connection.c --- common/connection.c 2001/09/20 19:54:33 1.17 +++ common/connection.c 2002/02/04 20:09:05 @@ -140,12 +140,12 @@ freelog(LOG_DEBUG, "didget:%d", didget); return didget; } - else if (didget == 0) { + if (didget == 0) { freelog(LOG_DEBUG, "EOF on socket read"); return -1; } #ifdef NONBLOCKING_SOCKETS - else if (errno == EWOULDBLOCK || errno == EAGAIN) { + if (errno == EWOULDBLOCK || errno == EAGAIN) { freelog(LOG_DEBUG, "EGAIN on socket read"); return 0; } Index: common/genlist.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/genlist.c,v retrieving revision 1.6 diff -u -r1.6 genlist.c --- common/genlist.c 2001/12/11 16:16:38 1.6 +++ common/genlist.c 2002/02/04 20:09:05 @@ -186,9 +186,9 @@ if(pos==0) return pgenlist->head_link; - else if(pos==-1) + if(pos==-1) return pgenlist->tail_link; - else if(pos<-1 || pos>=pgenlist->nelements) + if(pos<-1 || pos>=pgenlist->nelements) return &pgenlist->null_link; if(posnelements/2) /* fastest to do forward search */ Index: common/government.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/government.c,v retrieving revision 1.24 diff -u -r1.24 government.c --- common/government.c 2001/09/08 21:08:40 1.24 +++ common/government.c 2002/02/04 20:09:05 @@ -175,11 +175,13 @@ struct ruler_title *best_match = NULL; int i; + assert(nation != DEFAULT_TITLE); for(i=0; inum_ruler_titles; i++) { struct ruler_title *title = &g->ruler_titles[i]; if (title->nation == DEFAULT_TITLE && best_match == NULL) { best_match = title; - } else if (title->nation == nation) { + } + if (title->nation == nation) { best_match = title; break; } Index: common/idex.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/idex.c,v retrieving revision 1.3 diff -u -r1.3 idex.c --- common/idex.c 2001/12/11 16:16:38 1.3 +++ common/idex.c 2002/02/04 20:09:06 @@ -110,7 +110,9 @@ freelog(LOG_IDEX_ERR, "IDEX: city unreg missing: %d %p %s", pcity->id, (void*)pcity, pcity->name); if (IDEX_DIE) abort(); - } else if (old != pcity) { + } + + if (old != pcity) { /* error */ freelog(LOG_IDEX_ERR, "IDEX: city unreg mismatch: unreg %d %p %s, old %d %p %s", @@ -132,7 +134,9 @@ freelog(LOG_IDEX_ERR, "IDEX: unit unreg missing: %d %p %s", punit->id, (void*)punit, unit_name(punit->type)); if (IDEX_DIE) abort(); - } else if (old != punit) { + } + + if (old != punit) { /* error */ freelog(LOG_IDEX_ERR, "IDEX: unit unreg mismatch: unreg %d %p %s, old %d %p %s", Index: common/map.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/map.c,v retrieving revision 1.103 diff -u -r1.103 map.c --- common/map.c 2001/12/13 19:13:16 1.103 +++ common/map.c 2002/02/04 20:09:08 @@ -816,6 +816,7 @@ enum tile_terrain_type now, result; now = map_get_terrain(x, y); + assert(now != T_LAST); result = tile_types[now].irrigation_result; if (now == result) { @@ -825,7 +826,8 @@ map_set_special(x, y, S_IRRIGATION); } } - else if (result != T_LAST) { + + if (result != T_LAST) { map_set_terrain(x, y, result); if (result == T_OCEAN) { clear_infrastructure(x, y); @@ -846,11 +848,12 @@ enum tile_terrain_type now, result; now = map_get_terrain(x, y); + assert(now != T_LAST); result = tile_types[now].mining_result; if (now == result) map_set_special(x, y, S_MINE); - else if (result != T_LAST) { + if (result != T_LAST) { map_set_terrain(x, y, result); if (result == T_OCEAN) { clear_infrastructure(x, y); Index: common/packets.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/packets.c,v retrieving revision 1.171 diff -u -r1.171 packets.c --- common/packets.c 2002/02/02 08:57:37 1.171 +++ common/packets.c 2002/02/04 20:09:12 @@ -602,7 +602,7 @@ piter->type, piter->len, from); } - if (rem < 0) { + if (rem <= 0) { freelog(LOG_ERROR, "received short packet (type %d, len %d)%s", piter->type, piter->len, from); } else if(rem > 0) { Index: common/rand.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/rand.c,v retrieving revision 1.3 diff -u -r1.3 rand.c --- common/rand.c 2000/08/14 12:42:05 1.3 +++ common/rand.c 2002/02/04 20:09:12 @@ -101,10 +101,10 @@ } while (new_rand > max && size > 1); - if (size > 1) { - new_rand /= divisor; - } else if (size == 1) { + if (size == 1) { new_rand = 0; + } else { + new_rand /= divisor; } /* else leave it "raw" */ Index: server/gotohand.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/gotohand.c,v retrieving revision 1.128 diff -u -r1.128 gotohand.c --- server/gotohand.c 2002/02/02 15:31:55 1.128 +++ server/gotohand.c 2002/02/04 20:09:17 @@ -1114,7 +1114,9 @@ } } return(possible); - } else if (is_sailing_unit(punit) && + } + + if (is_sailing_unit(punit) && (omni || map_get_known_and_seen(x, y, pplayer)) && map_get_terrain(x, y) != T_OCEAN && !map_get_city(x, y) && !is_terrain_near_tile(x, y, T_OCEAN)) { Index: server/ruleset.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/ruleset.c,v retrieving revision 1.86 diff -u -r1.86 ruleset.c --- server/ruleset.c 2002/01/21 10:47:10 1.86 +++ server/ruleset.c 2002/02/04 20:09:19 @@ -413,7 +413,7 @@ { return (T_LAST); } - else if (0 == strcmp(name, "yes")) + if (0 == strcmp(name, "yes")) { return (tthis); } @@ -1423,7 +1423,8 @@ if (nval == 0) { freelog(LOG_FATAL, "No governments!? (%s)", filename); exit(1); - } else if(nval > G_MAGIC) { + } + if(nval > G_MAGIC) { /* upper limit is really about 255 for 8-bit id values, but use G_MAGIC elsewhere as a sanity check, and should be plenty big enough --dwp */ @@ -1771,7 +1772,8 @@ "There must be at least one nation defined; number is %d", game.playable_nation_count); exit(1); - } else if (game.playable_nation_count >= MAX_NUM_NATIONS) { + } + if (game.playable_nation_count >= MAX_NUM_NATIONS) { freelog(LOG_ERROR, "There are too many nations; only using %d of %d available.", MAX_NUM_NATIONS - 1, game.playable_nation_count); @@ -1830,7 +1832,8 @@ freelog(LOG_ERROR, "Nation %s: too many leaders; only using %d of %d", pl->name, MAX_NUM_LEADERS, dim); dim = MAX_NUM_LEADERS; - } else if (dim < 1) { + } + if (dim < 1) { freelog(LOG_FATAL, "Nation %s: number of leaders is %d; at least one is required.", pl->name, dim); Index: server/srv_main.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/srv_main.c,v retrieving revision 1.55 diff -u -r1.55 srv_main.c --- server/srv_main.c 2002/01/23 08:58:29 1.55 +++ server/srv_main.c 2002/02/04 20:09:23 @@ -932,7 +932,7 @@ if(game.players[i].nation==packet->nation_no) { send_select_nation(pplayer); /* it failed - nation taken */ return; - } else + } /* Check to see if name has been taken. * Ignore case because matches elsewhere are case-insenstive. * Don't limit this check to just players with allocated nation: @@ -942,8 +942,8 @@ * times (for server commands etc), including during nation * allocation phase. */ - if (i != pplayer->player_no - && mystrcasecmp(game.players[i].name,packet->name) == 0) { + if (i != pplayer->player_no + && mystrcasecmp(game.players[i].name, packet->name) == 0) { notify_player(pplayer, _("Another player already has the name '%s'. " "Please choose another name."), packet->name); Index: server/stdinhand.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/stdinhand.c,v retrieving revision 1.198 diff -u -r1.198 stdinhand.c --- server/stdinhand.c 2002/01/07 21:13:07 1.198 +++ server/stdinhand.c 2002/02/04 20:09:26 @@ -943,7 +943,8 @@ if (!len) { return PNameEmpty; - } else if (len > MAX_LEN_NAME-1) { + } + if (len > MAX_LEN_NAME - 1) { return PNameTooLong; } @@ -2154,7 +2155,9 @@ _("Error: command access level must be one of" " 'none', 'info', 'ctrl', or 'hack'.")); return; - } else if (caller && level > caller->access_level) { + } + + if (caller && level > caller->access_level) { cmd_reply(CMD_CMDLEVEL, caller, C_FAIL, _("Cannot increase command access level to '%s';" " you only have '%s' yourself."), @@ -3343,6 +3346,8 @@ sz_strlcat(buf, _(" 1 connection:")); } else if (n>1) { cat_snprintf(buf, sizeof(buf), _(" %d connections:"), n); + } else { + cat_snprintf(buf, sizeof(buf), "you should never see this"); } cmd_reply(CMD_LIST, caller, C_COMMENT, "%s", buf); Index: server/unithand.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/unithand.c,v retrieving revision 1.208 diff -u -r1.208 unithand.c --- server/unithand.c 2001/10/30 10:37:17 1.208 +++ server/unithand.c 2002/02/04 20:09:27 @@ -926,7 +926,8 @@ packet.action_type = DIPLOMAT_CLIENT_POPUP_DIALOG; lsend_packet_diplomat_action(player_reply_dest(pplayer), &packet); return 0; - } else if (!can_unit_move_to_tile_with_notify(punit, dest_x, dest_y, igzoc)) { + } + if (!can_unit_move_to_tile_with_notify(punit, dest_x, dest_y, igzoc)) { notify_player_ex(pplayer, punit->x, punit->y, E_NOEVENT, map_get_terrain(punit->x, punit->y) == T_OCEAN ? _("Game: Unit must be on land to " Index: server/unittools.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/unittools.c,v retrieving revision 1.149 diff -u -r1.149 unittools.c --- server/unittools.c 2002/01/21 10:16:24 1.149 +++ server/unittools.c 2002/02/04 20:09:30 @@ -252,6 +252,8 @@ tile_cap += get_transporter_capacity(punit2); } else if (is_ground_unit(punit2)) { tile_ncargo++; + } else { + assert(0); } } } @@ -754,7 +756,8 @@ assign_continent_numbers(); gamelog(GAMELOG_MAP, "(%d,%d) land created from ocean", x, y); return OLC_OCEAN_TO_LAND; - } else if ((oldter != T_OCEAN) && (newter == T_OCEAN)) { + } + if ((oldter != T_OCEAN) && (newter == T_OCEAN)) { /* land to ocean ... */ assign_continent_numbers(); gamelog(GAMELOG_MAP, "(%d,%d) ocean created from land", x, y); @@ -3175,6 +3178,8 @@ notify_player_ex(unit_owner(punit), src_x, src_y, E_NOEVENT, _("Game: %s can only move into your own zone of control."), unit_type(punit)->name); + } else { + assert(0); } return 0; }