Fix some issues detected by scan-build

It is just minor changes and it should not have any impact