From 2490df9b45a2b5c3707436971a8bb5f3538fc006 Mon Sep 17 00:00:00 2001 From: Colomban Wendling Date: Tue, 24 Jun 2014 15:02:31 +0200 Subject: [PATCH] Avoid passing non-literals to string formatting functions Having a string literal allows the compiler to check the arguments match the format, so avoid passing non-literal whenever possible. --- src/filetypes.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/filetypes.c b/src/filetypes.c index aaa2a6611..cb608fa50 100644 --- a/src/filetypes.c +++ b/src/filetypes.c @@ -87,21 +87,17 @@ enum TitleType /* Save adding many translation strings if the filetype name doesn't need translating */ static gchar *filetype_make_title(const char *name, enum TitleType type) { - const gchar *fmt = NULL; - g_return_val_if_fail(name != NULL, NULL); switch (type) { - case TITLE_SOURCE_FILE: fmt = _("%s source file"); break; - case TITLE_FILE: fmt = _("%s file"); break; - case TITLE_SCRIPT: fmt = _("%s script"); break; - case TITLE_DOCUMENT: fmt = _("%s document"); break; + case TITLE_SOURCE_FILE: return g_strdup_printf(_("%s source file"), name); + case TITLE_FILE: return g_strdup_printf(_("%s file"), name); + case TITLE_SCRIPT: return g_strdup_printf(_("%s script"), name); + case TITLE_DOCUMENT: return g_strdup_printf(_("%s document"), name); case TITLE_NONE: /* fall through */ - default: fmt = "%s"; break; + default: return g_strdup(name); } - - return g_strdup_printf(fmt, name); } -- 2.11.4.GIT