[iwhd] avoid theoretical integer overflow and -Wsign-compare warning