Fix typecast warnings in HAL