Fix -Werror=type-limits and -Werror=sign-compare

This time hopefully for real

Change-Id: I5bf06a9353ea94aef04d862ab25dfc38129b2b12