mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 15:06:14 +01:00
[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:
parent
9044744541
commit
ddf82a2576
@ -408,30 +408,26 @@ g_content_type_get_icon_internal (const gchar *type,
|
||||
char *icon_names[3];
|
||||
int n = 0;
|
||||
GIcon *themed_icon;
|
||||
const char *file_template;
|
||||
const char *xdg_icon;
|
||||
const char *suffix;
|
||||
|
||||
g_return_val_if_fail (type != NULL, NULL);
|
||||
|
||||
if (symbolic)
|
||||
{
|
||||
file_template = "%s-symbolic";
|
||||
}
|
||||
suffix = "-symbolic";
|
||||
else
|
||||
{
|
||||
file_template = "%s";
|
||||
}
|
||||
suffix = "";
|
||||
|
||||
G_LOCK (gio_xdgmime);
|
||||
xdg_icon = xdg_mime_get_icon (type);
|
||||
G_UNLOCK (gio_xdgmime);
|
||||
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)
|
||||
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)
|
||||
*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);
|
||||
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)
|
||||
icon_names[n++] = generic_mimetype_icon;
|
||||
|
||||
|
@ -527,26 +527,22 @@ g_resolver_records_from_res_query (const gchar *rrname,
|
||||
|
||||
if (len <= 0)
|
||||
{
|
||||
GResolverError errnum;
|
||||
const gchar *format;
|
||||
|
||||
if (len == 0 || herr == HOST_NOT_FOUND || herr == NO_DATA)
|
||||
{
|
||||
errnum = G_RESOLVER_ERROR_NOT_FOUND;
|
||||
format = _("No DNS record of the requested type for '%s'");
|
||||
g_set_error (error, G_RESOLVER_ERROR, G_RESOLVER_ERROR_NOT_FOUND,
|
||||
_("No DNS record of the requested type for '%s'"), rrname);
|
||||
}
|
||||
else if (herr == TRY_AGAIN)
|
||||
{
|
||||
errnum = G_RESOLVER_ERROR_TEMPORARY_FAILURE;
|
||||
format = _("Temporarily unable to resolve '%s'");
|
||||
g_set_error (error, G_RESOLVER_ERROR, G_RESOLVER_ERROR_TEMPORARY_FAILURE,
|
||||
_("Temporarily unable to resolve '%s'"), rrname);
|
||||
}
|
||||
else
|
||||
{
|
||||
errnum = G_RESOLVER_ERROR_INTERNAL;
|
||||
format = _("Error resolving '%s'");
|
||||
g_set_error (error, G_RESOLVER_ERROR, G_RESOLVER_ERROR_INTERNAL,
|
||||
_("Error resolving '%s'"), rrname);
|
||||
}
|
||||
|
||||
g_set_error (error, G_RESOLVER_ERROR, errnum, format, rrname);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -711,26 +707,22 @@ g_resolver_records_from_DnsQuery (const gchar *rrname,
|
||||
|
||||
if (status != ERROR_SUCCESS)
|
||||
{
|
||||
GResolverError errnum;
|
||||
const gchar *format;
|
||||
|
||||
if (status == DNS_ERROR_RCODE_NAME_ERROR)
|
||||
{
|
||||
errnum = G_RESOLVER_ERROR_NOT_FOUND;
|
||||
format = _("No DNS record of the requested type for '%s'");
|
||||
g_set_error (error, G_RESOLVER_ERROR, G_RESOLVER_ERROR_NOT_FOUND,
|
||||
_("No DNS record of the requested type for '%s'"), rrname);
|
||||
}
|
||||
else if (status == DNS_ERROR_RCODE_SERVER_FAILURE)
|
||||
{
|
||||
errnum = G_RESOLVER_ERROR_TEMPORARY_FAILURE;
|
||||
format = _("Temporarily unable to resolve '%s'");
|
||||
g_set_error (error, G_RESOLVER_ERROR, G_RESOLVER_ERROR_TEMPORARY_FAILURE,
|
||||
_("Temporarily unable to resolve '%s'"), rrname);
|
||||
}
|
||||
else
|
||||
{
|
||||
errnum = G_RESOLVER_ERROR_INTERNAL;
|
||||
format = _("Error resolving '%s'");
|
||||
g_set_error (error, G_RESOLVER_ERROR, G_RESOLVER_ERROR_INTERNAL,
|
||||
_("Error resolving '%s'"), rrname);
|
||||
}
|
||||
|
||||
g_set_error (error, G_RESOLVER_ERROR, errnum, format, rrname);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -188,6 +188,8 @@ test_d (void)
|
||||
* the "0" in "%-03d".) But we need to test that our printf gets
|
||||
* those rules right. So we fool gcc into not warning.
|
||||
*/
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wformat"
|
||||
fmt = "% +d";
|
||||
res = g_snprintf (buf, 128, fmt, 5);
|
||||
g_assert_cmpint (res, ==, 2);
|
||||
@ -197,6 +199,7 @@ test_d (void)
|
||||
res = g_snprintf (buf, 128, fmt, -5);
|
||||
g_assert_cmpint (res, ==, 3);
|
||||
g_assert_cmpstr (buf, ==, "-5 ");
|
||||
#pragma GCC diagnostic pop
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user