Clang static analyzer

these are some trivial fixes spotted by my experiments with clang's code analyzer - `scan-build`

I guess @scottpurdy was once interested in an analyzer, this one seems quite capable - you can see results (takes some time to compile) here https://github.com/breznak/nupic/blob/analyzer-dev/reports/scan-build-2013-10-23-1/index.html 

Later, I'd like we work on the list and reduce these, maybe some "warnings" are actually important - eg the clang problem with loggingException - I see some notes there.

This is ready to merge.