Fix signed/unsigned comparison mismatch