Fix clang issues.
Actually use calculated value
Merge pull request #3572 from ktf/fix-unused-variable

Clang -- Fix misc bugs discovered by clang.