reduce the amount of casting in check_if_fd