coverity#736885 Unintended sign extension

and coverity#736886 Unintended sign extension

promote from unsigned short to size_t immediately rather than implicitly to int
and then have the int result widened to size_t

Change-Id: I3156ed9628287a84da35d97caec8d91ce942986d