Combine two identical cases in a switch block.
strcpy → Q_strncopyz & strcat → strncat.

(Some are left unchanged.)