[PATCH] Fix trivial non literal format uses

Based on a patch from Henrique Dante de Almeida <hdante@gmail.com>.

https://bugzilla.gnome.org/show_bug.cgi?id=691608
This commit is contained in:
Ryan Lortie 2013-12-08 14:22:51 -05:00
parent 9044744541
commit ddf82a2576
3 changed files with 21 additions and 30 deletions

View File

@ -408,30 +408,26 @@ g_content_type_get_icon_internal (const gchar *type,
char *icon_names[3]; char *icon_names[3];
int n = 0; int n = 0;
GIcon *themed_icon; GIcon *themed_icon;
const char *file_template;
const char *xdg_icon; const char *xdg_icon;
const char *suffix;
g_return_val_if_fail (type != NULL, NULL); g_return_val_if_fail (type != NULL, NULL);
if (symbolic) if (symbolic)
{ suffix = "-symbolic";
file_template = "%s-symbolic";
}
else else
{ suffix = "";
file_template = "%s";
}
G_LOCK (gio_xdgmime); G_LOCK (gio_xdgmime);
xdg_icon = xdg_mime_get_icon (type); xdg_icon = xdg_mime_get_icon (type);
G_UNLOCK (gio_xdgmime); G_UNLOCK (gio_xdgmime);
if (xdg_icon != NULL) if (xdg_icon != NULL)
xdg_mimetype_icon = g_strdup_printf (file_template, xdg_icon); xdg_mimetype_icon = g_strconcat (xdg_icon, suffix, NULL);
if (xdg_mimetype_icon) if (xdg_mimetype_icon)
icon_names[n++] = xdg_mimetype_icon; icon_names[n++] = xdg_mimetype_icon;
mimetype_icon = g_strdup_printf (file_template, type); mimetype_icon = g_strconcat (type, suffix, NULL);
while ((q = strchr (mimetype_icon, '/')) != NULL) while ((q = strchr (mimetype_icon, '/')) != NULL)
*q = '-'; *q = '-';
@ -439,7 +435,7 @@ g_content_type_get_icon_internal (const gchar *type,
xdg_mimetype_generic_icon = g_content_type_get_generic_icon_name (type); xdg_mimetype_generic_icon = g_content_type_get_generic_icon_name (type);
if (xdg_mimetype_generic_icon) if (xdg_mimetype_generic_icon)
generic_mimetype_icon = g_strdup_printf (file_template, xdg_mimetype_generic_icon); generic_mimetype_icon = g_strconcat (xdg_mimetype_generic_icon, suffix, NULL);
if (generic_mimetype_icon) if (generic_mimetype_icon)
icon_names[n++] = generic_mimetype_icon; icon_names[n++] = generic_mimetype_icon;

View File

@ -527,26 +527,22 @@ g_resolver_records_from_res_query (const gchar *rrname,
if (len <= 0) if (len <= 0)
{ {
GResolverError errnum;
const gchar *format;
if (len == 0 || herr == HOST_NOT_FOUND || herr == NO_DATA) if (len == 0 || herr == HOST_NOT_FOUND || herr == NO_DATA)
{ {
errnum = G_RESOLVER_ERROR_NOT_FOUND; g_set_error (error, G_RESOLVER_ERROR, G_RESOLVER_ERROR_NOT_FOUND,
format = _("No DNS record of the requested type for '%s'"); _("No DNS record of the requested type for '%s'"), rrname);
} }
else if (herr == TRY_AGAIN) else if (herr == TRY_AGAIN)
{ {
errnum = G_RESOLVER_ERROR_TEMPORARY_FAILURE; g_set_error (error, G_RESOLVER_ERROR, G_RESOLVER_ERROR_TEMPORARY_FAILURE,
format = _("Temporarily unable to resolve '%s'"); _("Temporarily unable to resolve '%s'"), rrname);
} }
else else
{ {
errnum = G_RESOLVER_ERROR_INTERNAL; g_set_error (error, G_RESOLVER_ERROR, G_RESOLVER_ERROR_INTERNAL,
format = _("Error resolving '%s'"); _("Error resolving '%s'"), rrname);
} }
g_set_error (error, G_RESOLVER_ERROR, errnum, format, rrname);
return NULL; return NULL;
} }
@ -711,26 +707,22 @@ g_resolver_records_from_DnsQuery (const gchar *rrname,
if (status != ERROR_SUCCESS) if (status != ERROR_SUCCESS)
{ {
GResolverError errnum;
const gchar *format;
if (status == DNS_ERROR_RCODE_NAME_ERROR) if (status == DNS_ERROR_RCODE_NAME_ERROR)
{ {
errnum = G_RESOLVER_ERROR_NOT_FOUND; g_set_error (error, G_RESOLVER_ERROR, G_RESOLVER_ERROR_NOT_FOUND,
format = _("No DNS record of the requested type for '%s'"); _("No DNS record of the requested type for '%s'"), rrname);
} }
else if (status == DNS_ERROR_RCODE_SERVER_FAILURE) else if (status == DNS_ERROR_RCODE_SERVER_FAILURE)
{ {
errnum = G_RESOLVER_ERROR_TEMPORARY_FAILURE; g_set_error (error, G_RESOLVER_ERROR, G_RESOLVER_ERROR_TEMPORARY_FAILURE,
format = _("Temporarily unable to resolve '%s'"); _("Temporarily unable to resolve '%s'"), rrname);
} }
else else
{ {
errnum = G_RESOLVER_ERROR_INTERNAL; g_set_error (error, G_RESOLVER_ERROR, G_RESOLVER_ERROR_INTERNAL,
format = _("Error resolving '%s'"); _("Error resolving '%s'"), rrname);
} }
g_set_error (error, G_RESOLVER_ERROR, errnum, format, rrname);
return NULL; return NULL;
} }

View File

@ -188,6 +188,8 @@ test_d (void)
* the "0" in "%-03d".) But we need to test that our printf gets * the "0" in "%-03d".) But we need to test that our printf gets
* those rules right. So we fool gcc into not warning. * those rules right. So we fool gcc into not warning.
*/ */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat"
fmt = "% +d"; fmt = "% +d";
res = g_snprintf (buf, 128, fmt, 5); res = g_snprintf (buf, 128, fmt, 5);
g_assert_cmpint (res, ==, 2); g_assert_cmpint (res, ==, 2);
@ -197,6 +199,7 @@ test_d (void)
res = g_snprintf (buf, 128, fmt, -5); res = g_snprintf (buf, 128, fmt, -5);
g_assert_cmpint (res, ==, 3); g_assert_cmpint (res, ==, 3);
g_assert_cmpstr (buf, ==, "-5 "); g_assert_cmpstr (buf, ==, "-5 ");
#pragma GCC diagnostic pop
} }
static void static void