gio: switch gunixconnection ngettext with g_dngettext calls

This commit changes the use of `ngettext` with `g_dngettext`. The
project defined `g_dngettext` (with domain support) provides the same
functionality as `ngettext` with a NULL domain provided. The purpose of
this change is to help address a build error for certain compilers that
trigger a `format-nonliteral` error-promoted-warning when using
`ngettext` (see also [1][2]). The benefit of switching to use
`g_dngettext` is that the function is defined with `G_GNUC_FORMAT`. This
provides a hint to GNU GCC compilers to still sanity check these
arguments, but not generate a `format-nonliteral`.

[1]: 4ae8606b6f80f9764e1f0a82cea7e23c8af487ae
[2]: 0ca660315a9044696f778da087a6e3dd8910a765

Signed-off-by: James Knight <james.d.knight@live.com>
This commit is contained in:
James Knight 2023-04-25 23:25:38 -04:00 committed by Philip Withnall
parent a47bd14e83
commit aae4df5c6b

View File

@ -177,7 +177,8 @@ g_unix_connection_receive_fd (GUnixConnection *connection,
gint i;
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
ngettext("Expecting 1 control message, got %d",
g_dngettext (NULL,
"Expecting 1 control message, got %d",
"Expecting 1 control message, got %d",
nscm),
nscm);
@ -211,7 +212,8 @@ g_unix_connection_receive_fd (GUnixConnection *connection,
gint i;
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
ngettext("Expecting one fd, but got %d\n",
g_dngettext (NULL,
"Expecting one fd, but got %d\n",
"Expecting one fd, but got %d\n",
nfd),
nfd);
@ -595,7 +597,8 @@ g_unix_connection_receive_credentials (GUnixConnection *connection,
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_FAILED,
ngettext("Expecting 1 control message, got %d",
g_dngettext (NULL,
"Expecting 1 control message, got %d",
"Expecting 1 control message, got %d",
nscm),
nscm);