0002-Fix-error-format-in-gio-gunixconnection.c-part-2.patch 4.0 KB

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