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

Add casts to avoid warnings about comparison between signed and unsigned