Being endothermic itself confers some innate immunity. The human body temperature, nominally 37 °C, is just warm enough to ward off fungal infection. For each 1 °C rise in body temperature, the number of fungal species that can infect an animal declines by an estimated 6%.
There is a trade-off between marginal energy consumption necessary to maintain a body temperature versus fungal protection. Mathematical modeling found 36.7 °C to be optimal for minimizing cost versus protection benefit.
251 mya, in the Great Dying, 95% of the species in the oceans and 70% of those on land were wiped out. Earth become one massive compost pile.
Microbes literally had a field day. A massive fungal bloom swept the planet. Fungi may have been a kingmaker in the species dominance that followed.
Ectotherms, such as reptiles and amphibians, are susceptible to tens of thousands of fungal infestations, whereas mammals are bothered by a few hundred. This innate mammalian immunity may have been an evolutionary edge over reptiles. Meanwhile, dinosaurs developed mesothermy, which may have been partly to ward off fungal infections.