Add explicit conversions to avoid warnings from -Wsign-conversion and
-Wshorten-64-to-32. Also avoid runtime errors from -fsanitize=undefined.
Fixes #48121
Change-Id: I29dc8d976884fc42826392c10f1e1759bb1a3989
Reviewed-on: https://go-review.googlesource.com/c/go/+/348739
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>