C-style casts hide intent and when code changes they can also hide logic errors.
This change converts most of the C-style cast into static_cast and the icky ones are converted to reinterpret_cast and we can deal with fixing those icky cases in another change.
One case was moved to use std::numeric_limits<unsigned>::max() since it was simply using the fact that -1 converted to unsigned results in the maximum unsigned value.
Do we even need this cast? Neither Clang nor GCC complain about unsigned X = -1 for me.