Skip to content

Comments

Fix use of uninitialized variable in PowerupManager#5459

Merged
Alayan-stk-2 merged 3 commits intosupertuxkart:masterfrom
nyllet:fix_use_of_uninitialized_variable_in_powerup_manager
Jun 16, 2025
Merged

Fix use of uninitialized variable in PowerupManager#5459
Alayan-stk-2 merged 3 commits intosupertuxkart:masterfrom
nyllet:fix_use_of_uninitialized_variable_in_powerup_manager

Conversation

@nyllet
Copy link
Contributor

@nyllet nyllet commented Jun 15, 2025

Also avoid a potenial null pointer dereference
Remove two unused includes
Minor cleanups

Agreement

By creating a pull request in stk-code, you hereby agree to dual-license your contribution as
GNU General Public License version 3 or any later version and
Mozilla Public License version 2 or any later version.

This includes your previous contribution(s) under the same name of contributor.

Keep the above statement in the pull request comment for agreement.

Also avoid a potenial null pointer dereference
Remove two unused includes
Minor cleanups
Copy link
Member

@Alayan-stk-2 Alayan-stk-2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR!

Please adjust the mentioned stylistic elements and it can be merged.

{
m_num_karts = num_karts;
for (unsigned int i = 0; i < node->getNumNodes(); i++)
for (unsigned int i = 0; i < node->getNumNodes(); ++i)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leave i++ in loops. The vast, vast majority of loops in the STK code base use post-increment notation, so this change creates inconsistencies.

In for loops, both pre-increment and post-increment will generate exactly the same code, so this is purely a stylistic matter.

// Keep a reference for shorter access to the list
std::vector<int> &l = m_weights_for_section.back();
for(unsigned int i=0; i<l_string.size(); i++)
for(unsigned int j=0; j < l_string.size(); ++j)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same remark about ++j vs j++

Switching to j instead of i is definitely good for code clarity.

@Alayan-stk-2 Alayan-stk-2 merged commit f5f767c into supertuxkart:master Jun 16, 2025
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants