1From 4ae8606b6f80f9764e1f0a82cea7e23c8af487ae Mon Sep 17 00:00:00 2001
2From: James Knight <james.d.knight@live.com>
3Date: Thu, 20 Apr 2023 23:41:32 -0400
4Subject: [PATCH] Fix error format in gio/gunixconnection.c (part 2)
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9Update a series of error messages to use `g_set_error_literal` instead
10of `g_set_error`. This should prevent `format-nonliteral` compiler
11issues when `-Werror` is configured:
12
13    ../gio/gunixconnection.c: In function ‘g_unix_connection_receive_fd’:
14    ../gio/gunixconnection.c:183:9: error: format not a string literal, argument types not checked [-Werror=format-nonliteral]
15      183 |         nscm);
16          |         ^~~~
17    ../gio/gunixconnection.c:217:20: error: format not a string literal, argument types not checked [-Werror=format-nonliteral]
18      217 |                    nfd);
19          |                    ^~~
20    ../gio/gunixconnection.c: In function ‘g_unix_connection_receive_credentials’:
21    ../gio/gunixconnection.c:601:24: error: format not a string literal, argument types not checked [-Werror=format-nonliteral]
22      601 |                        nscm);
23          |                        ^~~~
24
25This is similar to a previous change [1] made to `gunixconnection.c`.
26
27[1]: 44b3d5d80445234041f6c59feb89645f7102c3a4
28
29Signed-off-by: James Knight <james.d.knight@live.com>
30Upstream: backport from upstream https://gitlab.gnome.org/GNOME/glib/-/commit/4ae8606b6f80f9764e1f0a82cea7e23c8af487ae
31---
32 gio/gunixconnection.c | 31 ++++++++++++++-----------------
33 1 file changed, 14 insertions(+), 17 deletions(-)
34
35diff --git a/gio/gunixconnection.c b/gio/gunixconnection.c
36index b3f2b1c04b0abdf7136918585ae4cea8970a88bb..c012fcbfe00b69e9da609c7b626229db98e931ac 100644
37--- a/gio/gunixconnection.c
38+++ b/gio/gunixconnection.c
39@@ -176,11 +176,10 @@ g_unix_connection_receive_fd (GUnixConnection  *connection,
40     {
41       gint i;
42
43-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
44-        ngettext("Expecting 1 control message, got %d",
45-                 "Expecting 1 control message, got %d",
46-                 nscm),
47-        nscm);
48+      g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
49+                           ngettext ("Expecting 1 control message, got %d",
50+                                     "Expecting 1 control message, got %d",
51+                                     nscm));
52
53       for (i = 0; i < nscm; i++)
54         g_object_unref (scms[i]);
55@@ -210,11 +209,10 @@ g_unix_connection_receive_fd (GUnixConnection  *connection,
56     {
57       gint i;
58
59-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
60-                   ngettext("Expecting one fd, but got %d\n",
61-                            "Expecting one fd, but got %d\n",
62-                            nfd),
63-                   nfd);
64+      g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
65+                           ngettext ("Expecting one fd, but got %d\n",
66+                                     "Expecting one fd, but got %d\n",
67+                                     nfd));
68
69       for (i = 0; i < nfd; i++)
70         close (fds[i]);
71@@ -592,13 +590,12 @@ g_unix_connection_receive_credentials (GUnixConnection      *connection,
72     {
73       if (nscm != 1)
74         {
75-          g_set_error (error,
76-                       G_IO_ERROR,
77-                       G_IO_ERROR_FAILED,
78-                       ngettext("Expecting 1 control message, got %d",
79-                                "Expecting 1 control message, got %d",
80-                                nscm),
81-                       nscm);
82+          g_set_error_literal (error,
83+                               G_IO_ERROR,
84+                               G_IO_ERROR_FAILED,
85+                               ngettext ("Expecting 1 control message, got %d",
86+                                         "Expecting 1 control message, got %d",
87+                                         nscm));
88           goto out;
89         }
90
91--
922.39.1.windows.1
93
94