Fix lots of compiler warnings (casts, unused vars, etc.)
As a preparation for a patch to create a spec file for the project (and
be able to generate RPM's for Fedora-like systems), this commit fixes
lots of warnings generated by the compiler when using more strict
flags.
Fedora, by default, uses the following flags to compile the program:
-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
-fstack-protector-strong --param=ssp-buffer-size=4
-grecord-gcc-switches -m%ARCH -mtune=generic
This generated lots of warnings (like missing casts, or unused
variables). It is good to fix those in order to keep a sane codebase.