YOU SHOULD NEVER FIRE WARNING SHOTS.
Think of a "warning shot" from the other guys' perspective. The law always looks at events from all litigants' sides. Your shots put the other guy in reasonable fear of imminent death or serious bodily injury. Thus, the other guy may reasonably use deadly force to stop the attack, ie, shoot at you and kill you.
Firing a "warning shot" is doing what? Making noise? Trying to scare somebody? If you are in fear for your life, or the life of others, why are you making noise, and not addressing the threat? Isn't that an admission that you were not in reasonable fear of imminent death or serious bodily injury? If you feared for your life, you would shoot at the threat, not shoot to make noise.
Your "warning shot" might harm a bystander. Shoot down, you might have a ricochet. Shoot up into the air, the bullet can fall on somebody's head. Shoot to the side, you might hit a person.
IMHO, firing warning shot(s) is like signing your own death warrant. Do not do it.
Also, if you are under attack, why would you want to expend part of your limited supply of ammo. You may need your ammo to save you from the threat.
YOU SHOULD NEVER FIRE WARNING SHOTS.