Skip to content

Commit

Permalink
Fixed|Client|World: Result of operation is garbage or undefined
Browse files Browse the repository at this point in the history
Static analysis reveals that the return value of clipBlock() could be
undefined, as didClipMin and didClipMax were uninitialized.
  • Loading branch information
skyjake committed Apr 20, 2014
1 parent 28d45b5 commit 7fbc222
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions doomsday/client/src/world/blockmap.cpp
Expand Up @@ -272,8 +272,10 @@ DENG2_PIMPL(Blockmap)
return uint((y - bounds.minY) / cellSize);
}

void clipCell(Cell &cell, bool &didClip)
/// @return @c true, if clipped; otherwise @c false.
bool clipCell(Cell &cell) const
{
bool didClip = false;
if(cell.x > dimensions.x)
{
cell.x = dimensions.x;
Expand All @@ -284,6 +286,7 @@ DENG2_PIMPL(Blockmap)
cell.y = dimensions.y;
didClip = true;
}
return didClip;
}

/**
Expand All @@ -296,9 +299,8 @@ DENG2_PIMPL(Blockmap)
*/
bool clipBlock(CellBlock &block)
{
bool didClipMin, didClipMax;
clipCell(block.min, didClipMin);
clipCell(block.max, didClipMax);
bool const didClipMin = clipCell(block.min);
bool const didClipMax = clipCell(block.max);
return didClipMin | didClipMax;
}

Expand Down

0 comments on commit 7fbc222

Please sign in to comment.