Fix a bunch of clang reported issues.
Merge pull request #3772 from ktf/fix-clang-issues

Fix a bunch of clang reported issues.