Skip to content

Conversation

@victorapm
Copy link
Contributor

Cleans the code for the build: cmake -B build -S src -DCMAKE_C_FLAGS=-Wshadow

Resolving -Wshadow warnings is important to:

  1. Preventing silent logic errors (such as using a local variable when we meant to use a global or outer-scope variable)
  2. Improve readability: Removes ambiguity so developers know exactly which variable is being referenced at a glance.
  3. Safeguard refactoring: Prevents bugs where moving code blocks into new scopes silently changes variable references.

HYPRE_MEMORY_HOST);
}

HYPRE_Int i;
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to stay in, but with a new name like li. It's inside an outer loop that is already using i. In general, this simple renaming approach is the most reliable way to make these changes. I'll try to look for other potential issues like this, but you might want to take a second look as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for catching! This one was a real bug! Fixed

}
if (grid_relax_type)
{
HYPRE_Int num_levels = hypre_ParAMGDataNumLevels(amg_data);
Copy link
Contributor

Choose a reason for hiding this comment

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

This one might need to stay in as well. I would have to look at the logic here to be sure, but num_levels is initialized at the top of the routine so it's value may be needed outside of this if section.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I double checked this one and the current change is fine. We're in the destructor, so num_levels cannot change in that function. We can rely on the value initialized at the beginning

@rfalgout
Copy link
Contributor

rfalgout commented Dec 3, 2025

Hi @victorapm . I will wait until you take another look through your changes before looking through this some more. We want to be careful not to potentially change the behavior of the code. It is a good idea to test for this stuff, though. Thanks!

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.

3 participants