Fixes#8195. This PR doesn't fix all the warnings from #8195, but
fixes many of them (e.g., I didn't get the "string might be truncated"
warnings on my Mac).
This is an adaptation of 14aa5fae3c from
master; it drops some things that aren't relevant here on the v4.1.x
branch and adds a few more warnings fixes that are relevant here on
v4.1.x that aren't relevant on master.
Signed-off-by: Jeff Squyres <jsquyres@cisco.com>
(cherry-picked from 14aa5fae3c)