Skip to content

Commit

Permalink
Fix warning: 'naluGlobalId' may be used uninitialized (#1345)
Browse files Browse the repository at this point in the history
  • Loading branch information
marchdf authored Jan 21, 2025
1 parent b1949cc commit c041dc1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/TpetraLinearSystem.C
Original file line number Diff line number Diff line change
Expand Up @@ -1979,9 +1979,10 @@ TpetraLinearSystem::checkForZeroRow(bool useOwned, bool doThrow, bool doPrint)
stk::mesh::EntityId nid = (gid - 1) / numDof_ + 1;
stk::mesh::Entity node =
bulkData.get_entity(stk::topology::NODE_RANK, nid);
stk::mesh::EntityId naluGlobalId;
if (bulkData.is_valid(node))
naluGlobalId = *stk::mesh::field_data(*realm_.naluGlobalId_, node);
const stk::mesh::EntityId naluGlobalId =
bulkData.is_valid(node)
? *stk::mesh::field_data(*realm_.naluGlobalId_, node)
: -1;

int idof = (gid - 1) % numDof_;
GlobalOrdinal GID_check = GID_(nid, numDof_, idof);
Expand Down
7 changes: 4 additions & 3 deletions src/TpetraSegregatedLinearSystem.C
Original file line number Diff line number Diff line change
Expand Up @@ -1763,9 +1763,10 @@ TpetraSegregatedLinearSystem::checkForZeroRow(
stk::mesh::EntityId nid = static_cast<stk::mesh::EntityId>(gid);
stk::mesh::Entity node =
bulkData.get_entity(stk::topology::NODE_RANK, nid);
stk::mesh::EntityId naluGlobalId;
if (bulkData.is_valid(node))
naluGlobalId = *stk::mesh::field_data(*realm_.naluGlobalId_, node);
const stk::mesh::EntityId naluGlobalId =
bulkData.is_valid(node)
? *stk::mesh::field_data(*realm_.naluGlobalId_, node)
: -1;

if (doPrint) {

Expand Down

0 comments on commit c041dc1

Please sign in to comment.