Merge pull request #2659 from swisspol/static_analysis Fixed the most obvious Clang static analyzer warnings