diff options
author | James Knight <james.d.knight@live.com> | 2023-04-25 23:21:58 -0400 |
---|---|---|
committer | James Knight <james.d.knight@live.com> | 2023-04-25 23:21:58 -0400 |
commit | 0ca660315a9044696f778da087a6e3dd8910a765 (patch) | |
tree | d1725c0df252e64079bf1f02c79540b1e11215f8 | |
parent | c176fcf2eb3a20e989cd1c4439f76779f276f418 (diff) | |
download | glib-0ca660315a9044696f778da087a6e3dd8910a765.tar.gz |
Revert "Fix error format in gio/gunixconnection.c (part 2)"
This reverts commit 4ae8606b6f80f9764e1f0a82cea7e23c8af487ae. The idea
for the change [1] was to address a build error for certain compilers
that trigger a `format-nonliteral` error-promoted-warning since these
compilers do not gracefully support `ngettext` usage. The changes
following a pattern from an old commit [2]; however, James Hilliard has
pointed out these changes do not work as intended. A deeper inspection
of the commit showed that the commit was from an old merge request that
was not pulled in, detailing why the changes did not work (see also
[3][4]).
Manipulating the sockets unit test confirms that the format values no
longer get a proper value:
...
ok 9 /socket/address
ok 10 /socket/unix-from-fd
ok 11 /socket/unix-connection
**
GLib-GIO:ERROR:../gio/tests/socket.c:1493:test_unix_connection_ancillary_data: assertion failed (err == NULL): Expecting one fd, but got %d
(g-io-error-quark, 0)
...
And reverting this change restores the original functionality:
...
ok 9 /socket/address
ok 10 /socket/unix-from-fd
ok 11 /socket/unix-connection
**
GLib-GIO:ERROR:../gio/tests/socket.c:1493:test_unix_connection_ancillary_data: assertion failed (err == NULL): Expecting 1 control message, got 0 (g-io-error-quark, 0)
...
[1]: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3390
[2]: 44b3d5d80445234041f6c59feb89645f7102c3a4
[3]: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/770
[4]: https://gitlab.gnome.org/GNOME/glib/-/issues/1744
Signed-off-by: James Knight <james.d.knight@live.com>
-rw-r--r-- | gio/gunixconnection.c | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/gio/gunixconnection.c b/gio/gunixconnection.c index c012fcbfe..b3f2b1c04 100644 --- a/gio/gunixconnection.c +++ b/gio/gunixconnection.c @@ -176,10 +176,11 @@ g_unix_connection_receive_fd (GUnixConnection *connection, { gint i; - g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, - ngettext ("Expecting 1 control message, got %d", - "Expecting 1 control message, got %d", - nscm)); + g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, + ngettext("Expecting 1 control message, got %d", + "Expecting 1 control message, got %d", + nscm), + nscm); for (i = 0; i < nscm; i++) g_object_unref (scms[i]); @@ -209,10 +210,11 @@ g_unix_connection_receive_fd (GUnixConnection *connection, { gint i; - g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, - ngettext ("Expecting one fd, but got %d\n", - "Expecting one fd, but got %d\n", - nfd)); + g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, + ngettext("Expecting one fd, but got %d\n", + "Expecting one fd, but got %d\n", + nfd), + nfd); for (i = 0; i < nfd; i++) close (fds[i]); @@ -590,12 +592,13 @@ g_unix_connection_receive_credentials (GUnixConnection *connection, { if (nscm != 1) { - g_set_error_literal (error, - G_IO_ERROR, - G_IO_ERROR_FAILED, - ngettext ("Expecting 1 control message, got %d", - "Expecting 1 control message, got %d", - nscm)); + g_set_error (error, + G_IO_ERROR, + G_IO_ERROR_FAILED, + ngettext("Expecting 1 control message, got %d", + "Expecting 1 control message, got %d", + nscm), + nscm); goto out; } |