GCC: Fixed all conversion warnings.

-Wall -Wextra -pedantic -Wconversion.
A tricky detail is that the product of two chars or shorts gets
promoted to 'int', so some extra logic was required.