enable -Wall and fix compiler warnings

Enable buildoption `-Wall` by default and fix the following warnings (gcc):
`-Wunused-but-set-variable`
`-Wunused-function`
`-Wreorder`
`-Wnarrowing`