Fix sparse warnings.

Mainly making a lot of local functions and variables be marked "static",
but there was a "zero as NULL" warning in there too.
9 files changed