build: fix build warnings.

Most of the build warnings are:
- Unused local variables/function arugments/functions
- comparision between signed and unsigned types.