Fix g++ compiler warnings

warning: suggest parentheses around assignment used as truth value [-Wparentheses]

warning: comparison between signed and unsigned integer expressions [-Wsign-compare]