diff options
author | rubidium <rubidium@openttd.org> | 2009-05-26 15:46:24 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2009-05-26 15:46:24 +0000 |
commit | e3c5bc8d2ebb9f8ab8f4cb64002bc3b8d0e10e37 (patch) | |
tree | 65f84aef7bfb97e14166b4b973f182e4c7a6c0f7 | |
parent | 2a5a8f395c0c71146259433a1a4abe7807d2f8ac (diff) | |
download | openttd-e3c5bc8d2ebb9f8ab8f4cb64002bc3b8d0e10e37.tar.xz |
(svn r16434) -Cleanup: remove some dead code; primarily stuff that can't be reached like break after returns or break after functions that never return (i.e. NOT_REACHED)
-rw-r--r-- | src/3rdparty/squirrel/squirrel/sqapi.cpp | 2 | ||||
-rw-r--r-- | src/bmp.cpp | 4 | ||||
-rw-r--r-- | src/depot_gui.cpp | 4 | ||||
-rw-r--r-- | src/gfx.cpp | 2 | ||||
-rw-r--r-- | src/industry_cmd.cpp | 4 | ||||
-rw-r--r-- | src/newgrf.cpp | 4 | ||||
-rw-r--r-- | src/newgrf_spritegroup.cpp | 2 | ||||
-rw-r--r-- | src/saveload/saveload.cpp | 5 | ||||
-rw-r--r-- | src/saveload/vehicle_sl.cpp | 2 | ||||
-rw-r--r-- | src/settings.cpp | 6 | ||||
-rw-r--r-- | src/tree_cmd.cpp | 2 | ||||
-rw-r--r-- | src/unmovable_cmd.cpp | 2 | ||||
-rw-r--r-- | src/vehicle.cpp | 2 | ||||
-rw-r--r-- | src/vehicle_gui.cpp | 23 | ||||
-rw-r--r-- | src/vehiclelist.cpp | 2 |
15 files changed, 30 insertions, 36 deletions
diff --git a/src/3rdparty/squirrel/squirrel/sqapi.cpp b/src/3rdparty/squirrel/squirrel/sqapi.cpp index 34d32ec85..10b3469f4 100644 --- a/src/3rdparty/squirrel/squirrel/sqapi.cpp +++ b/src/3rdparty/squirrel/squirrel/sqapi.cpp @@ -829,7 +829,7 @@ SQRESULT sq_getdelegate(HSQUIRRELVM v,SQInteger idx) } v->Push(SQObjectPtr(_delegable(self)->_delegate)); break; - default: return sq_throwerror(v,_SC("wrong type")); break; + default: return sq_throwerror(v,_SC("wrong type")); } return SQ_OK; diff --git a/src/bmp.cpp b/src/bmp.cpp index ae277d7c8..80500382b 100644 --- a/src/bmp.cpp +++ b/src/bmp.cpp @@ -362,11 +362,11 @@ bool BmpReadBitmap(BmpBuffer *buffer, BmpInfo *info, BmpData *data) case 4: return BmpRead4(buffer, info, data); case 8: return BmpRead8(buffer, info, data); case 24: return BmpRead24(buffer, info, data); - default: NOT_REACHED(); return false; + default: NOT_REACHED(); } case 1: return BmpRead8Rle(buffer, info, data); // 8-bit RLE compression case 2: return BmpRead4Rle(buffer, info, data); // 4-bit RLE compression - default: NOT_REACHED(); return false; + default: NOT_REACHED(); } } diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index 512254c12..06fab5c8f 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -541,7 +541,7 @@ struct DepotWindow : Window { case VEH_ROAD: command = CMD_START_STOP_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_STOP_START_ROAD_VEHICLE); break; case VEH_SHIP: command = CMD_START_STOP_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_STOP_START_SHIP); break; case VEH_AIRCRAFT: command = CMD_START_STOP_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_STOP_START_AIRCRAFT); break; - default: NOT_REACHED(); command = 0; + default: NOT_REACHED(); } DoCommandP(v->tile, v->index, 0, command); } break; @@ -991,7 +991,7 @@ struct DepotWindow : Window { case VEH_ROAD: command = CMD_SELL_ROAD_VEH | CMD_MSG(STR_ERROR_CAN_T_SELL_ROAD_VEHICLE); break; case VEH_SHIP: command = CMD_SELL_SHIP | CMD_MSG(STR_ERROR_CAN_T_SELL_SHIP); break; case VEH_AIRCRAFT: command = CMD_SELL_AIRCRAFT | CMD_MSG(STR_ERROR_CAN_T_SELL_AIRCRAFT); break; - default: NOT_REACHED(); command = 0; + default: NOT_REACHED(); } if (!DoCommandP(v->tile, v->index, sell_cmd, command) && is_engine) _backup_orders_tile = 0; diff --git a/src/gfx.cpp b/src/gfx.cpp index 1648e30b3..e9d7f026b 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -598,7 +598,7 @@ uint32 FormatStringLinebreaks(char *str, int maxw) } } else { switch (c) { - case '\0': return num + (size << 16); break; + case '\0': return num + (size << 16); case SCC_SETX: str++; break; case SCC_SETXY: str += 2; break; case SCC_TINYFONT: size = FS_SMALL; break; diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index 73fc7bb2d..46b183989 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -2038,7 +2038,7 @@ static void ReportNewsProductionChangeIndustry(Industry *ind, CargoID type, int case 0: ns = NS_INDUSTRY_NOBODY; break; case 1: ns = NS_INDUSTRY_OTHER; break; case 2: ns = NS_INDUSTRY_COMPANY; break; - default: NOT_REACHED(); break; + default: NOT_REACHED(); } SetDParam(2, abs(percent)); SetDParam(0, GetCargo(type)->name); @@ -2233,7 +2233,7 @@ static void ChangeIndustryProduction(Industry *i, bool monthly) case 0: ns = NS_INDUSTRY_NOBODY; break; case 1: ns = NS_INDUSTRY_OTHER; break; case 2: ns = NS_INDUSTRY_COMPANY; break; - default: NOT_REACHED(); break; + default: NOT_REACHED(); } } /* Set parameters of news string */ diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 2171a4850..c226d295e 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -5060,7 +5060,7 @@ static void GRFImportBlock(byte *buf, int len) switch (_grf_data_type) { case GDT_SOUND: ImportGRFSound(buf, len - 1); break; - default: NOT_REACHED(); break; + default: NOT_REACHED(); } } @@ -5277,7 +5277,7 @@ static void GRFDataBlock(byte *buf, int len) switch (_grf_data_type) { case GDT_SOUND: LoadGRFSound(buf, len - name_len - 2); break; - default: NOT_REACHED(); break; + default: NOT_REACHED(); } } diff --git a/src/newgrf_spritegroup.cpp b/src/newgrf_spritegroup.cpp index a2dc720e6..b70d0ca1a 100644 --- a/src/newgrf_spritegroup.cpp +++ b/src/newgrf_spritegroup.cpp @@ -157,7 +157,7 @@ const SpriteGroup *DeterministicSpriteGroup::Resolve(ResolverObject *object) con case DSG_SIZE_BYTE: value = EvalAdjustT<uint8, int8> (adjust, object, last_value, value); break; case DSG_SIZE_WORD: value = EvalAdjustT<uint16, int16>(adjust, object, last_value, value); break; case DSG_SIZE_DWORD: value = EvalAdjustT<uint32, int32>(adjust, object, last_value, value); break; - default: NOT_REACHED(); break; + default: NOT_REACHED(); } last_value = value; } diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp index 9735970d9..3412ae218 100644 --- a/src/saveload/saveload.cpp +++ b/src/saveload/saveload.cpp @@ -488,9 +488,6 @@ int64 ReadValue(const void *ptr, VarType conv) case SLE_VAR_NULL:return 0; default: NOT_REACHED(); } - - /* useless, but avoids compiler warning this way */ - return 0; } /** Write the value of a setting @@ -1488,8 +1485,6 @@ static size_t ReferenceToInt(const void *obj, SLRefType rt) case REF_ORDERLIST: return ((const OrderList*)obj)->index + 1; default: NOT_REACHED(); } - - return 0; // avoid compiler warning } /** diff --git a/src/saveload/vehicle_sl.cpp b/src/saveload/vehicle_sl.cpp index 6554baf02..3170bb34a 100644 --- a/src/saveload/vehicle_sl.cpp +++ b/src/saveload/vehicle_sl.cpp @@ -149,7 +149,7 @@ void ConvertOldMultiheadToNew() SetTrainWagon(u); SetFreeWagon(u); break; - default: NOT_REACHED(); break; + default: NOT_REACHED(); } } } diff --git a/src/settings.cpp b/src/settings.cpp index d73e17161..dca90a6ca 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -378,7 +378,7 @@ static void Write_ValidateSetting(void *ptr, const SettingDesc *sd, int32 val) } case SLE_VAR_I64: case SLE_VAR_U64: - default: NOT_REACHED(); break; + default: NOT_REACHED(); } } @@ -451,7 +451,7 @@ static void ini_load_settings(IniFile *ini, const SettingDesc *sd, const char *g *(char**)ptr = p == NULL ? NULL : strdup((const char*)p); break; case SLE_VAR_CHAR: if (p != NULL) *(char*)ptr = *(char*)p; break; - default: NOT_REACHED(); break; + default: NOT_REACHED(); } break; @@ -463,7 +463,7 @@ static void ini_load_settings(IniFile *ini, const SettingDesc *sd, const char *g } break; } - default: NOT_REACHED(); break; + default: NOT_REACHED(); } } } diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp index 2924f238d..4172b54b3 100644 --- a/src/tree_cmd.cpp +++ b/src/tree_cmd.cpp @@ -302,7 +302,7 @@ void GenerateTrees() switch (_settings_game.game_creation.tree_placer) { case TP_ORIGINAL: i = _settings_game.game_creation.landscape == LT_ARCTIC ? 15 : 6; break; case TP_IMPROVED: i = _settings_game.game_creation.landscape == LT_ARCTIC ? 4 : 2; break; - default: NOT_REACHED(); return; + default: NOT_REACHED(); } total = ScaleByMapSize(1000); diff --git a/src/unmovable_cmd.cpp b/src/unmovable_cmd.cpp index c4932d815..90423f935 100644 --- a/src/unmovable_cmd.cpp +++ b/src/unmovable_cmd.cpp @@ -176,7 +176,7 @@ static void DrawTile_Unmovable(TileInfo *ti) { switch (GetUnmovableType(ti->tile)) { - default: NOT_REACHED(); break; + default: NOT_REACHED(); case UNMOVABLE_TRANSMITTER: case UNMOVABLE_LIGHTHOUSE: { const DrawTileSeqStruct *dtu = &_draw_tile_transmitterlighthouse_data[GetUnmovableType(ti->tile)]; diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 5b54c5b2a..5684abcc0 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -1066,7 +1066,7 @@ void VehicleEnterDepot(Vehicle *v) case VEH_ROAD: string = STR_NEWS_ROAD_VEHICLE_IS_WAITING; break; case VEH_SHIP: string = STR_NEWS_SHIP_IS_WAITING; break; case VEH_AIRCRAFT: string = STR_NEWS_AIRCRAFT_IS_WAITING; break; - default: NOT_REACHED(); string = STR_EMPTY; // Set the string to something to avoid a compiler warning + default: NOT_REACHED(); } SetDParam(0, v->index); diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 57bb893b1..455aed43a 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -906,7 +906,7 @@ struct VehicleListWindow : public BaseVehicleListWindow { case VEH_ROAD: this->widget[VLW_WIDGET_CAPTION].data = STR_VEHICLE_LIST_ROAD_CAPTION; break; case VEH_SHIP: this->widget[VLW_WIDGET_CAPTION].data = STR_VEHICLE_LIST_SHIP_CAPTION; break; case VEH_AIRCRAFT: this->widget[VLW_WIDGET_CAPTION].data = STR_VEHICLE_LIST_AIRCRAFT_CAPTION; break; - default: NOT_REACHED(); break; + default: NOT_REACHED(); } break; @@ -920,7 +920,7 @@ struct VehicleListWindow : public BaseVehicleListWindow { case VEH_ROAD: this->widget[VLW_WIDGET_CAPTION].data = STR_SCHEDULED_ROAD_VEHICLES; break; case VEH_SHIP: this->widget[VLW_WIDGET_CAPTION].data = STR_SCHEDULED_SHIPS; break; case VEH_AIRCRAFT: this->widget[VLW_WIDGET_CAPTION].data = STR_SCHEDULED_AIRCRAFT; break; - default: NOT_REACHED(); break; + default: NOT_REACHED(); } break; @@ -930,10 +930,10 @@ struct VehicleListWindow : public BaseVehicleListWindow { case VEH_ROAD: this->widget[VLW_WIDGET_CAPTION].data = STR_VEHICLE_LIST_ROADVEH_DEPOT; break; case VEH_SHIP: this->widget[VLW_WIDGET_CAPTION].data = STR_VEHICLE_LIST_SHIP_DEPOT; break; case VEH_AIRCRAFT: this->widget[VLW_WIDGET_CAPTION].data = STR_VEHICLE_LIST_AIRCRAFT_DEPOT; break; - default: NOT_REACHED(); break; + default: NOT_REACHED(); } break; - default: NOT_REACHED(); break; + default: NOT_REACHED(); } switch (this->vehicle_type) { @@ -963,7 +963,7 @@ struct VehicleListWindow : public BaseVehicleListWindow { case VEH_ROAD: this->sorting = &_sorting.roadveh; break; case VEH_SHIP: this->sorting = &_sorting.ship; break; case VEH_AIRCRAFT: this->sorting = &_sorting.aircraft; break; - default: NOT_REACHED(); break; + default: NOT_REACHED(); } this->vehicles.SetListing(*this->sorting); @@ -1024,7 +1024,7 @@ struct VehicleListWindow : public BaseVehicleListWindow { case VEH_ROAD: SetDParam(0, STR_DEPOT_ROAD_CAPTION); break; case VEH_SHIP: SetDParam(0, STR_DEPOT_SHIP_CAPTION); break; case VEH_AIRCRAFT: SetDParam(0, STR_DEPOT_AIRCRAFT_CAPTION); break; - default: NOT_REACHED(); break; + default: NOT_REACHED(); } if (this->vehicle_type == VEH_AIRCRAFT) { SetDParam(1, index); // Airport name @@ -1033,7 +1033,7 @@ struct VehicleListWindow : public BaseVehicleListWindow { } SetDParam(2, this->vscroll.count); break; - default: NOT_REACHED(); break; + default: NOT_REACHED(); } /* Hide the widgets that we will not use in this window @@ -1393,12 +1393,11 @@ struct VehicleDetailsWindow : Window { { switch (vehicle_type) { default: NOT_REACHED(); - case VEH_TRAIN: return _settings_game.vehicle.servint_trains != 0; break; - case VEH_ROAD: return _settings_game.vehicle.servint_roadveh != 0; break; - case VEH_SHIP: return _settings_game.vehicle.servint_ships != 0; break; - case VEH_AIRCRAFT: return _settings_game.vehicle.servint_aircraft != 0; break; + case VEH_TRAIN: return _settings_game.vehicle.servint_trains != 0; + case VEH_ROAD: return _settings_game.vehicle.servint_roadveh != 0; + case VEH_SHIP: return _settings_game.vehicle.servint_ships != 0; + case VEH_AIRCRAFT: return _settings_game.vehicle.servint_aircraft != 0; } - return false; // kill a compiler warning } /** diff --git a/src/vehiclelist.cpp b/src/vehiclelist.cpp index 38e1b4f67..14d291254 100644 --- a/src/vehiclelist.cpp +++ b/src/vehiclelist.cpp @@ -144,7 +144,7 @@ void GenerateVehicleSortList(VehicleList *list, VehicleType type, Owner owner, u } break; - default: NOT_REACHED(); break; + default: NOT_REACHED(); } list->Compact(); |