static code analysis

Fixed some small bugs found by static code analysis. Most of it is signed/unsigned mismatch in printf() calls.