Fix logic error -- missing break statement in switch().

Flaw found via Coverity Scan.
Remove unreachable code. Handle errors in command-line arguments
cleanly.
Eliminate potential NULL dereference.
Fix potential divide by zero. (Highly unlikely, but easy defense.)
Fix error with undefined variable, introduced by yesterday's commit.
(Stupid thinko.)
Move default return to clarify function always returns.
(Fixes false positives with Coverity and Clang static checkers.)
Make sure to leave room to null-terminate tmp strings.

Error found via Coverity Scan.