Resolve warnings

To keep the build system happy with
 -Wreorder
 -Wsign-compare
 -Wreturn-type
 -Wunused-but-set-variable
 -Wformat