Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: fix compiler warnings #6015

Merged
merged 1 commit into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,10 +613,10 @@
}

Character::Character( Character &&source ) noexcept : Creature( std::move( source ) ),
worn( new worn_item_location( this ) ),

Check warning on line 616 in src/character.cpp

View workflow job for this annotation

GitHub Actions / build

missing exception handler for allocation failure at 'new' [bugprone-unhandled-exception-at-new]
inv( new character_item_location( this ) )

Check warning on line 617 in src/character.cpp

View workflow job for this annotation

GitHub Actions / build

missing exception handler for allocation failure at 'new' [bugprone-unhandled-exception-at-new]
{
move_operator_common( std::move( source ) );

Check warning on line 619 in src/character.cpp

View workflow job for this annotation

GitHub Actions / build

'source' used after it was moved [bugprone-use-after-move]
}

Character &Character::operator=( Character &&source )
Expand All @@ -624,7 +624,7 @@
{
move_operator_common( std::move( source ) );

Creature::operator=( std::move( source ) );

Check warning on line 627 in src/character.cpp

View workflow job for this annotation

GitHub Actions / build

'source' used after it was moved [bugprone-use-after-move]
return *this;
}

Expand Down Expand Up @@ -8764,7 +8764,6 @@
bool in_skater_vehicle = in_vehicle && veh_part.part_with_feature( "SEAT_REQUIRES_BALANCE", false );

if( ( worn_with_flag( flag_REQUIRES_BALANCE ) || in_skater_vehicle ) && !is_on_ground() ) {
int rolls = 4;
if( worn_with_flag( flag_ROLLER_ONE ) && !in_skater_vehicle ) {
if( worn_with_flag( flag_REQUIRES_BALANCE ) && !has_effect( effect_downed ) ) {
int rolls = 4;
Expand Down
2 changes: 1 addition & 1 deletion src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@
// Add a timestamp for uniqueness.
char buffer[suffix_len] {};
std::time_t t = std::time( nullptr );
std::strftime( buffer, suffix_len, "%Y-%m-%d-%H-%M-%S", std::localtime( &t ) );

Check warning on line 933 in src/game.cpp

View workflow job for this annotation

GitHub Actions / build

the value returned by this function should not be disregarded; neglecting it may lead to errors [cert-err33-c]
memorial_file_path << buffer;

return memorial_file_path.str();
Expand Down Expand Up @@ -4318,7 +4318,7 @@
targ->apply_damage( source, bodypart_id( "torso" ), dam_mult * force_remaining );
targ->check_dead_state();
}
m.bash( traj[i], 2 * dam_mult * force_remaining );

Check warning on line 4321 in src/game.cpp

View workflow job for this annotation

GitHub Actions / build

performing an implicit widening conversion to type 'std::size_t' (aka 'unsigned long') of a multiplication performed in type 'int' [bugprone-implicit-widening-of-multiplication-result]
break;
} else if( critter_at( traj[i] ) ) {
targ->setpos( traj[i - 1] );
Expand Down Expand Up @@ -4398,7 +4398,7 @@
}
targ->check_dead_state();
}
m.bash( traj[i], 2 * dam_mult * force_remaining );

Check warning on line 4401 in src/game.cpp

View workflow job for this annotation

GitHub Actions / build

performing an implicit widening conversion to type 'std::size_t' (aka 'unsigned long') of a multiplication performed in type 'int' [bugprone-implicit-widening-of-multiplication-result]
break;
} else if( critter_at( traj[i] ) ) {
targ->setpos( traj[i - 1] );
Expand Down Expand Up @@ -4481,7 +4481,7 @@
}
u.check_dead_state();
}
m.bash( traj[i], 2 * dam_mult * force_remaining );

Check warning on line 4484 in src/game.cpp

View workflow job for this annotation

GitHub Actions / build

performing an implicit widening conversion to type 'std::size_t' (aka 'unsigned long') of a multiplication performed in type 'int' [bugprone-implicit-widening-of-multiplication-result]
break;
} else if( critter_at( traj[i] ) ) {
u.setpos( traj[i - 1] );
Expand Down Expand Up @@ -8534,13 +8534,13 @@
disassembly_stacks_res.emplace_back( stack.first->typeId(), stack.second );
}

for( int i = 0; i < disassembly_stacks_res.size(); i++ ) {
for( int i = 0; i < static_cast<int>( disassembly_stacks_res.size() ); i++ ) {
const auto dis = recipe_dictionary::get_uncraft( disassembly_stacks_res[i].first );
time_to_disassemble_rec += dis.time * disassembly_stacks_res[i].second;
//uses default craft materials to estimate recursive disassembly time
const auto components = dis.disassembly_requirements().get_components();
for( const auto &subcomps : components ) {
if( subcomps.size() > 0 ) {

Check warning on line 8543 in src/game.cpp

View workflow job for this annotation

GitHub Actions / build

the 'empty' method should be used to check for emptiness instead of 'size' [readability-container-size-empty]
disassembly_stacks_res.emplace_back( subcomps.front().type,
subcomps.front().count * disassembly_stacks_res[i].second );
}
Expand Down Expand Up @@ -11459,7 +11459,7 @@
void game::autosave()
{
//Don't autosave if the min-autosave interval has not passed since the last autosave/quicksave.
if( time( nullptr ) < last_save_timestamp + 60 * get_option<int>( "AUTOSAVE_MINUTES" ) ) {

Check warning on line 11462 in src/game.cpp

View workflow job for this annotation

GitHub Actions / build

performing an implicit widening conversion to type 'time_t' (aka 'long') of a multiplication performed in type 'int' [bugprone-implicit-widening-of-multiplication-result]
return;
}
quicksave(); //Driving checks are handled by quicksave()
Expand Down
2 changes: 1 addition & 1 deletion src/recipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ std::function<bool( const item & )> recipe::get_component_filter(
};
}

static std::string dump_requirements(
[[maybe_unused]] static std::string dump_requirements(
const requirement_data &reqs,
int move_cost,
const std::map<skill_id, int> &skills )
Expand Down
7 changes: 0 additions & 7 deletions src/vehicle_move.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,13 +656,6 @@ veh_collision vehicle::part_collision( int part, const tripoint &p,
// 0.001 -> 1 meter. Left modifiable so that armor or other parts can affect it.
float deformation_distance = density_factor / 100;

//Calculates mass factor. Depreciated, maintained for stats.
// factor = -25 if mass is much greater than mass2
// factor = +25 if mass2 is much greater than mass
const float weight_factor = mass >= mass2 ?
-25 * ( std::log( mass ) - std::log( mass2 ) ) / std::log( mass ) :
25 * ( std::log( mass2 ) - std::log( mass ) ) / std::log( mass2 );

bool smashed = true;
const std::string snd = _( "smash!" );
float part_dmg = 0;
Expand Down
Loading