Don't even draw the gun if you don't believe the peril is serious enough that you are in immediate, serious danger of being maimed or killed. Firing a "warning shot" means that you are using deadly force when you don't believe deadly force is really necessary to end the threat.
I can imagine the conversation...
Detective: So, that's when you drew your gun?
Homeowner: That's right, that's when I fired a warning shot.
Detective: Why didn't you shoot him?
Homeowner: I didn't want to hurt him, I just wanted to scare him away.
Detective: So he was not a threat when you drew your gun?
Homeowner: Of course he was, I just don't want to shoot anybody.
Detective: Then why did you pull out a gun in the first place?