Fix build on Red Hat 6

The RH compiler is a bit more strict about warnings for signed
variables, this just adds some casts to eliminate the warnings.  It's
not so clean to require these casts, but they're just in some
assert()s so I guess it's OK for now.