Fix -Wsign-compare warnings from gcc

This commit fixes -Wsign-compare warnings from gcc. No functional changes.