build: fix build warnings.

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