Cast to the right data type to avoid comparison warnings in gcc
Merge pull request #1528 from mstorsjo/fix-warnings

Cast to the right data type to avoid comparison warnings in gcc