Resolved all warnings reported by clang-analyzer

The code has been modified to resolve all the warnings reported by
clang-analyzer. Nothing serious was detected. All the warnings were related to
unused variables or set-but-unused variables.