Replace C-style cast with static_cast

This was a style warning from Cppcheck. Nothing serious, but the fix is trivial.