added clang static analysis to Makefile & fixed few warnings
added cppcheck makefile options and fixed harmless off-by-1 bug