diff --git a/.clang-tidy b/.clang-tidy index 107ca7c10dbd2..10777b30780a9 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -19,7 +19,6 @@ performance-*,\ readability-*,\ -bugprone-misplaced-widening-cast,\ -bugprone-narrowing-conversions,\ --bugprone-too-small-loop-variable,\ -bugprone-undefined-memory-manipulation,\ -bugprone-unused-return-value,\ -bugprone-use-after-move,\ diff --git a/src/defense.cpp b/src/defense.cpp index cf043de5e5e58..7cf2b76513a20 100644 --- a/src/defense.cpp +++ b/src/defense.cpp @@ -1023,7 +1023,7 @@ Press %s to buy everything in your cart, %s to buy nothing." ), total_price += caravan_price( g->u, item( tmp_itm, 0 ).price( false ) ); if( category_selected == CARAVAN_CART ) { // Find the item in its category for( int i = 1; i < NUM_CARAVAN_CATEGORIES; i++ ) { - for( unsigned j = 0; j < items[i].size(); j++ ) { + for( size_t j = 0; j < items[i].size(); j++ ) { if( items[i][j] == tmp_itm ) { item_count[i][j]++; } @@ -1055,7 +1055,7 @@ Press %s to buy everything in your cart, %s to buy nothing." ), total_price -= caravan_price( g->u, item( tmp_itm, 0 ).price( false ) ); if( category_selected == CARAVAN_CART ) { // Find the item in its category for( int i = 1; i < NUM_CARAVAN_CATEGORIES; i++ ) { - for( unsigned j = 0; j < items[i].size(); j++ ) { + for( size_t j = 0; j < items[i].size(); j++ ) { if( items[i][j] == tmp_itm ) { item_count[i][j]--; } @@ -1117,7 +1117,7 @@ Press %s to buy everything in your cart, %s to buy nothing." ), if( !cancel ) { g->u.cash -= total_price; bool dropped_some = false; - for( unsigned i = 0; i < items[0].size(); i++ ) { + for( size_t i = 0; i < items[0].size(); i++ ) { item tmp( items[0][i] ); tmp = tmp.in_its_container(); @@ -1456,7 +1456,7 @@ std::string defense_game::special_wave_message( std::string name ) // Capitalize capitalize_letter( name ); - for( unsigned i = 2; i < name.size(); i++ ) { + for( size_t i = 2; i < name.size(); i++ ) { if( name[i - 1] == ' ' ) { capitalize_letter( name, i ); } diff --git a/src/game.cpp b/src/game.cpp index 03a684ef0067e..290fee74d8598 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1086,8 +1086,8 @@ bool game::cleanup_at_end() sfx::fade_audio_group( 3, 2000 ); sfx::fade_audio_group( 4, 2000 ); - for( unsigned int iY = 0; iY < vRip.size(); ++iY ) { - for( unsigned int iX = 0; iX < vRip[iY].length(); ++iX ) { + for( size_t iY = 0; iY < vRip.size(); ++iY ) { + for( size_t iX = 0; iX < vRip[iY].length(); ++iX ) { char cTemp = vRip[iY][iX]; if( cTemp != ' ' ) { nc_color ncColor = c_light_gray; diff --git a/src/map.cpp b/src/map.cpp index 29190dc170133..ac048d2f06613 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -6428,14 +6428,14 @@ std::vector map::get_dir_circle( const tripoint &f, const tripoint &t // 642 864 786 578 357 135 213 421 size_t pos_offset = 0; - for( unsigned int i = 1; i < spiral.size(); i++ ) { + for( size_t i = 1; i < spiral.size(); i++ ) { if( spiral[i] == line[0] ) { pos_offset = i - 1; break; } } - for( unsigned int i = 1; i < spiral.size(); i++ ) { + for( size_t i = 1; i < spiral.size(); i++ ) { if( pos_offset >= pos_index.size() ) { pos_offset = 0; } diff --git a/src/npc.cpp b/src/npc.cpp index 908306c31a4cd..207728913ed75 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -1064,7 +1064,7 @@ float npc::vehicle_danger( int radius ) const int danger = 0; // TODO: check for most dangerous vehicle? - for( unsigned int i = 0; i < vehicles.size(); ++i ) { + for( size_t i = 0; i < vehicles.size(); ++i ) { const wrapped_vehicle &wrapped_veh = vehicles[i]; if( wrapped_veh.v->is_moving() ) { // FIXME: this can't be the right way to do this diff --git a/src/npcmove.cpp b/src/npcmove.cpp index 591a2aa2e08e5..678ebd9227a91 100644 --- a/src/npcmove.cpp +++ b/src/npcmove.cpp @@ -1604,7 +1604,7 @@ bool npc::consume_cbm_items( const std::function &filter ) { invslice slice = inv.slice(); int index = -1; - for( unsigned int i = 0; i < slice.size(); i++ ) { + for( size_t i = 0; i < slice.size(); i++ ) { const item &it = slice[i]->front(); const item &real_item = it.is_container() ? it.contents.front() : it; if( filter( real_item ) ) { @@ -2825,7 +2825,7 @@ void npc::drop_items( int weight, int volume ) // First fill our ratio vectors, so we know which things to drop first invslice slice = inv.slice(); - for( unsigned int i = 0; i < slice.size(); i++ ) { + for( size_t i = 0; i < slice.size(); i++ ) { item &it = slice[i]->front(); double wgt_ratio = 0.0; double vol_ratio = 0.0; @@ -3478,7 +3478,7 @@ bool npc::consume_food() int want_hunger = get_hunger(); int want_quench = get_thirst(); invslice slice = inv.slice(); - for( unsigned int i = 0; i < slice.size(); i++ ) { + for( size_t i = 0; i < slice.size(); i++ ) { const item &it = slice[i]->front(); const item &food_item = it.is_food_container() ? it.contents.front() : it; @@ -3553,7 +3553,7 @@ void npc::mug_player( player &mark ) double best_value = minimum_item_value() * value_mod; int item_index = INT_MIN; invslice slice = mark.inv.slice(); - for( unsigned int i = 0; i < slice.size(); i++ ) { + for( size_t i = 0; i < slice.size(); i++ ) { if( value( slice[i]->front() ) >= best_value && can_pickVolume( slice[i]->front(), true ) && can_pickWeight( slice[i]->front(), true ) ) { diff --git a/src/options.cpp b/src/options.cpp index c6e07aa57b8b6..d112d1990c9eb 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -986,12 +986,12 @@ void options_manager::init() add_options_world_default(); add_options_android(); - for( unsigned i = 0; i < vPages.size(); ++i ) { + for( size_t i = 0; i < vPages.size(); ++i ) { mPageItems[i].resize( mOptionsSort[vPages[i].first] ); } for( auto &elem : options ) { - for( unsigned i = 0; i < vPages.size(); ++i ) { + for( size_t i = 0; i < vPages.size(); ++i ) { if( vPages[i].first == elem.second.getPage() && elem.second.getSortPos() > -1 ) { mPageItems[i][elem.second.getSortPos()] = elem.first; break; @@ -1000,7 +1000,7 @@ void options_manager::init() } //Sort out possible double empty lines after options are hidden - for( unsigned i = 0; i < vPages.size(); ++i ) { + for( size_t i = 0; i < vPages.size(); ++i ) { bool bLastLineEmpty = false; while( mPageItems[i][0].empty() ) { //delete empty lines at the beginning diff --git a/tests/explosion_balance.cpp b/tests/explosion_balance.cpp index 975e59aef9dfd..04f7722c4f58d 100644 --- a/tests/explosion_balance.cpp +++ b/tests/explosion_balance.cpp @@ -112,7 +112,7 @@ static void check_vehicle_damage( const std::string &explosive_id, const std::st // We don't expect any destroyed parts. REQUIRE( before_hp.size() == after_hp.size() ); - for( unsigned int i = 0; i < before_hp.size(); ++i ) { + for( size_t i = 0; i < before_hp.size(); ++i ) { INFO( target_vehicle->parts[ i ].name() ); if( target_vehicle->parts[ i ].info().get_id() == "windshield" || target_vehicle->parts[ i ].info().get_id() == "headlight" ) { diff --git a/tests/new_character_test.cpp b/tests/new_character_test.cpp index 1c90fdf6b3167..cc4bcf520e582 100644 --- a/tests/new_character_test.cpp +++ b/tests/new_character_test.cpp @@ -39,7 +39,7 @@ static std::vector next_subset( const std::vector &set ) ++bitset; // Check each bit position for a match - for( unsigned idx = 0; idx < set.size(); idx++ ) { + for( size_t idx = 0; idx < set.size(); idx++ ) { if( bitset & ( 1 << idx ) ) { ret.push_back( set[idx] ); }