Add casts to avoid warnings about comparison between signed and unsigned
Merge pull request #1450 from mstorsjo/avoid-warnings

Add casts to avoid warnings about comparison between signed and unsigned