fix issues when using -Werror=format-security

This change applies the necessary fixes for the code to compile cleanly with -Werror=format-security.