src: use static_cast where appropriate

Use static_cast instead of reinterpret_cast when casting from void*
to another type.

This is mostly an aesthetic change but may help catch bugs when the
affected code is modified.