Address some compiler warnings and Coverity scan issues in a different way

The previous Coverity scan commit used not so great way of dealing
with certain warnings, which also did not help with compiler warnings,
which this commit tries to change.