From 985cab7737a10ea67e9b56e19a0423cd519bd41d Mon Sep 17 00:00:00 2001 From: Luca Bacci Date: Thu, 12 Oct 2023 09:57:46 +0200 Subject: [PATCH 1/9] gio/gregistrysettingsbackend.c: Use unsigned data type for bitfields that are only one-bit wide Fixes the following warnings on CLang: ../glib/gio/gregistrysettingsbackend.c:1503:32: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion] child_item->readable = TRUE; ^ ~~~~ ../glib/gio/gregistrysettingsbackend.c:1567:28: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion] child_item->readable = TRUE; ^ ~~~~ --- gio/gregistrysettingsbackend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gio/gregistrysettingsbackend.c b/gio/gregistrysettingsbackend.c index 88ae913ce..3ed384fbc 100644 --- a/gio/gregistrysettingsbackend.c +++ b/gio/gregistrysettingsbackend.c @@ -443,7 +443,7 @@ typedef struct gint32 ref_count : 9; - gint32 readable : 1; + guint32 readable : 1; RegistryValue value; } RegistryCacheItem; From f075db637aaa1c63535bc4dbce5a9552c7d1816e Mon Sep 17 00:00:00 2001 From: Luca Bacci Date: Thu, 12 Oct 2023 10:08:27 +0200 Subject: [PATCH 2/9] glib/giowin32.c: Add G_GNUC_FALLTHROUGH annotation Fixes the following warning on CLang: ../glib/glib/giowin32.c:1665:7: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough] default: ^ ../glib/glib/giowin32.c:1665:7: note: insert '__attribute__((fallthrough));' to silence this warning default: ^ __attribute__((fallthrough)); ../glib/glib/giowin32.c:1665:7: note: insert 'break;' to avoid fall-through default: ^ break; --- glib/giowin32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glib/giowin32.c b/glib/giowin32.c index f0e025d4a..ecc337aec 100644 --- a/glib/giowin32.c +++ b/glib/giowin32.c @@ -1661,7 +1661,7 @@ g_io_channel_new_file (const gchar *filename, mode_num |= MODE_PLUS; break; } - /* Fall through */ + G_GNUC_FALLTHROUGH; default: g_warning ("Invalid GIOFileMode %s.", mode); return NULL; From 5400f4e128b01339b4ae50d8ec52b2182ffa6974 Mon Sep 17 00:00:00 2001 From: Luca Bacci Date: Thu, 12 Oct 2023 10:14:06 +0200 Subject: [PATCH 3/9] glib/gmessages.c: Remove unused function Fixes the follwing warning on CLang: ../glib/glib/gmessages.c:433:1: warning: unused function 'dowrite' [-Wunused-function] dowrite (int fd, ^ --- glib/gmessages.c | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/glib/gmessages.c b/glib/gmessages.c index 79183d04f..d0d38c925 100644 --- a/glib/gmessages.c +++ b/glib/gmessages.c @@ -426,27 +426,6 @@ static gboolean win32_keep_fatal_message = FALSE; * called with huge strings, is it? */ static gchar fatal_msg_buf[1000] = "Unspecified fatal error encountered, aborting."; -static gchar *fatal_msg_ptr = fatal_msg_buf; - -#undef write -static inline int -dowrite (int fd, - const void *buf, - unsigned int len) -{ - if (win32_keep_fatal_message) - { - memcpy (fatal_msg_ptr, buf, len); - fatal_msg_ptr += len; - *fatal_msg_ptr = 0; - return len; - } - - write (fd, buf, len); - - return len; -} -#define write(fd, buf, len) dowrite(fd, buf, len) #endif From 107311afce3acfbd7a899b3cede20c6ace2a1131 Mon Sep 17 00:00:00 2001 From: Luca Bacci Date: Thu, 12 Oct 2023 10:21:55 +0200 Subject: [PATCH 4/9] glib/gtimezone.c: Declare Unix-only functions under G_OS_UNIX Fixes the following warnings on CLang when compiling for Windows: ../glib/glib/gtimezone.c:95:22: warning: unused function 'gint64_from_be' [-Wunused-function] static inline gint64 gint64_from_be (const gint64_be be) { ^ ../glib/glib/gtimezone.c:99:22: warning: unused function 'gint32_from_be' [-Wunused-function] static inline gint32 gint32_from_be (const gint32_be be) { ^ ../glib/glib/gtimezone.c:103:23: warning: unused function 'guint32_from_be' [-Wunused-function] static inline guint32 guint32_from_be (const guint32_be be) { ^ --- glib/gtimezone.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/glib/gtimezone.c b/glib/gtimezone.c index fc6c46d17..e64528a0a 100644 --- a/glib/gtimezone.c +++ b/glib/gtimezone.c @@ -92,6 +92,8 @@ typedef struct { gchar bytes[8]; } gint64_be; typedef struct { gchar bytes[4]; } gint32_be; typedef struct { gchar bytes[4]; } guint32_be; +#ifdef G_OS_UNIX + static inline gint64 gint64_from_be (const gint64_be be) { gint64 tmp; memcpy (&tmp, &be, sizeof tmp); return GINT64_FROM_BE (tmp); } @@ -104,6 +106,8 @@ static inline guint32 guint32_from_be (const guint32_be be) { guint32 tmp; memcpy (&tmp, &be, sizeof tmp); return GUINT32_FROM_BE (tmp); } +#endif + /* The layout of an IANA timezone file header */ struct tzhead { From 8264b1373756e526b67d497abd57141229e97c3a Mon Sep 17 00:00:00 2001 From: Luca Bacci Date: Thu, 12 Oct 2023 10:29:18 +0200 Subject: [PATCH 5/9] tests/cxx: Do not assume that NULL is a pointer type starting with C++11 Many toolchain did not change the definition of NULL to avoid introducing breaking changes in existing codebases. For example, on Windows NULL is 0 (int) regardless of the C++ standard in use. Fixes the following warnings on CLang when compiling for Windows: ../glib/glib/tests/cxx.cpp:539:34: warning: missing sentinel in function call [-Wsentinel] g_test_init (&argc, &argv, NULL); ^ , nullptr ../glib/glib/gtestutils.h:298:9: note: function has been explicitly marked sentinel here void g_test_init (int *argc, ^ ../glib/gio/tests/cxx.cpp:62:34: warning: missing sentinel in function call [-Wsentinel] g_test_init (&argc, &argv, NULL); ^ , nullptr ../glib/glib/gtestutils.h:298:9: note: function has been explicitly marked sentinel here void g_test_init (int *argc, ^ --- gio/tests/cxx.cpp | 2 +- glib/tests/cxx.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gio/tests/cxx.cpp b/gio/tests/cxx.cpp index 630eeab99..7aba3516e 100644 --- a/gio/tests/cxx.cpp +++ b/gio/tests/cxx.cpp @@ -59,7 +59,7 @@ int main (int argc, char **argv) { #if G_CXX_STD_CHECK_VERSION (11) - g_test_init (&argc, &argv, NULL); + g_test_init (&argc, &argv, nullptr); #else g_test_init (&argc, &argv, static_cast(NULL)); #endif diff --git a/glib/tests/cxx.cpp b/glib/tests/cxx.cpp index bc7967cce..5198621dc 100644 --- a/glib/tests/cxx.cpp +++ b/glib/tests/cxx.cpp @@ -536,7 +536,7 @@ int main (int argc, char *argv[]) { #if G_CXX_STD_CHECK_VERSION (11) - g_test_init (&argc, &argv, NULL); + g_test_init (&argc, &argv, nullptr); #else g_test_init (&argc, &argv, static_cast(NULL)); #endif From dfeb671c36d72b55133721be405dd6843124acbe Mon Sep 17 00:00:00 2001 From: Luca Bacci Date: Thu, 12 Oct 2023 10:39:03 +0200 Subject: [PATCH 6/9] tests/win32: Initialize DWORD with the right constant We were initializing a DWORD (unsigned 32 bit) with a constant of bigger rank (G_MAXSIZE) on 64 bit systems. Fixes the following warnings on CLang when compiling for x64: ../glib/glib/tests/win32.c:47:14: warning: implicit conversion from 'unsigned long long' to 'DWORD' (aka 'unsigned long') changes value from 18446744073709551615 to 4294967295 [-Wconstant-conversion] DWORD bp = G_MAXSIZE; ~~ ^~~~~~~~~ glib/glibconfig.h:88:19: note: expanded from macro 'G_MAXSIZE' #define G_MAXSIZE G_MAXUINT64 ^~~~~~~~~~~ ../glib/glib/gtypes.h:107:21: note: expanded from macro 'G_MAXUINT64' #define G_MAXUINT64 G_GUINT64_CONSTANT(0xffffffffffffffff) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ glib/glibconfig.h:69:52: note: expanded from macro 'G_GUINT64_CONSTANT' #define G_GUINT64_CONSTANT(val) (G_GNUC_EXTENSION (val##ULL)) ^~~~~~~~ :96:1: note: expanded from here 0xffffffffffffffffULL ^~~~~~~~~~~~~~~~~~~~~ --- glib/tests/win32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glib/tests/win32.c b/glib/tests/win32.c index 748692d65..18772c131 100644 --- a/glib/tests/win32.c +++ b/glib/tests/win32.c @@ -44,7 +44,7 @@ test_subst_pid_and_event (void) char *debugger_big_utf8; gchar *output; guintptr be = (guintptr) 0xFFFFFFFF; - DWORD bp = G_MAXSIZE; + DWORD bp = MAXDWORD; /* %f is not valid */ g_assert_false (_g_win32_subst_pid_and_event_w (debugger_3, G_N_ELEMENTS (debugger_3), From 4aa051cafb389c5b0896217abb9740af8bac8495 Mon Sep 17 00:00:00 2001 From: Luca Bacci Date: Thu, 5 Oct 2023 16:43:43 +0200 Subject: [PATCH 7/9] valgrind.h: Fix macro definition for Windows x64 The Windows x64 ABI follows the LLP64 model, so unsigned long int is 32 bits Fixes the following warnings when compiling for Windows x64: ../glib/gobject/gatomicarray.c:85:3: warning: cast to smaller integer type 'unsigned long' from 'gpointer' (aka 'void *') [-Wvoid-pointer-to-int-cast] VALGRIND_MALLOCLIKE_BLOCK (mem, real_size - sizeof (GAtomicArrayMetadata), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../glib/glib/valgrind.h:6479:5: note: expanded from macro 'VALGRIND_MALLOCLIKE_BLOCK' VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__MALLOCLIKE_BLOCK, \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../glib/glib/valgrind.h:203:15: note: expanded from macro 'VALGRIND_DO_CLIENT_REQUEST_STMT' do { (void) VALGRIND_DO_CLIENT_REQUEST_EXPR(0, \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../glib/glib/valgrind.h:417:20: note: expanded from macro 'VALGRIND_DO_CLIENT_REQUEST_EXPR' _zzq_args[1] = (unsigned long int)(_zzq_arg1); \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ See https://bugs.kde.org/show_bug.cgi?id=427146 --- glib/valgrind.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/glib/valgrind.h b/glib/valgrind.h index a7f1f5655..6f1c45297 100644 --- a/glib/valgrind.h +++ b/glib/valgrind.h @@ -93,6 +93,7 @@ #include +#include /* Nb: this file might be included in a file compiled with -ansi. So we can't use C++ style "//" comments nor the "asm" keyword (instead @@ -411,14 +412,14 @@ typedef _zzq_default, _zzq_request, \ _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5) \ __extension__ \ - ({ volatile unsigned long int _zzq_args[6]; \ + ({ volatile uintptr_t _zzq_args[6]; \ volatile unsigned long int _zzq_result; \ - _zzq_args[0] = (unsigned long int)(_zzq_request); \ - _zzq_args[1] = (unsigned long int)(_zzq_arg1); \ - _zzq_args[2] = (unsigned long int)(_zzq_arg2); \ - _zzq_args[3] = (unsigned long int)(_zzq_arg3); \ - _zzq_args[4] = (unsigned long int)(_zzq_arg4); \ - _zzq_args[5] = (unsigned long int)(_zzq_arg5); \ + _zzq_args[0] = (uintptr_t)(_zzq_request); \ + _zzq_args[1] = (uintptr_t)(_zzq_arg1); \ + _zzq_args[2] = (uintptr_t)(_zzq_arg2); \ + _zzq_args[3] = (uintptr_t)(_zzq_arg3); \ + _zzq_args[4] = (uintptr_t)(_zzq_arg4); \ + _zzq_args[5] = (uintptr_t)(_zzq_arg5); \ __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE \ /* %RDX = client_request ( %RAX ) */ \ "xchgq %%rbx,%%rbx" \ From ee4aaed516f9b827aa23fe2b9311d9542eacffa7 Mon Sep 17 00:00:00 2001 From: Luca Bacci Date: Thu, 5 Oct 2023 16:52:53 +0200 Subject: [PATCH 8/9] CI: Enable --Werror in MSYS2 CLANG64 job --- .gitlab-ci/test-msys2.sh | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci/test-msys2.sh b/.gitlab-ci/test-msys2.sh index aaeff165e..20032c4b4 100755 --- a/.gitlab-ci/test-msys2.sh +++ b/.gitlab-ci/test-msys2.sh @@ -32,14 +32,8 @@ PATH="$(cygpath "$USERPROFILE")/.local/bin:$HOME/.local/bin:$PATH" DIR="$(pwd)" export PATH CFLAGS -if [[ "$MSYSTEM" == "CLANG64" ]]; then - # FIXME: fix the clang build warnings - # shellcheck disable=SC2086 - meson setup ${MESON_COMMON_OPTIONS} _build -else - # shellcheck disable=SC2086 - meson setup ${MESON_COMMON_OPTIONS} --werror _build -fi +# shellcheck disable=SC2086 +meson setup ${MESON_COMMON_OPTIONS} --werror _build meson compile -C _build From e56bb89b834d78a7ccdc72c28d431e9cff904d34 Mon Sep 17 00:00:00 2001 From: Luca Bacci Date: Thu, 5 Oct 2023 16:53:39 +0200 Subject: [PATCH 9/9] CI: Remove workaround for Python in MSYS2 jobs It was added in 13fe2e0c, but it's now unnecessary since the issue has been fixed. See https://github.com/msys2/MINGW-packages/issues/17415 --- .gitlab-ci.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c4ca25709..0a316fde9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -341,10 +341,6 @@ msys2-mingw32: CHERE_INVOKING: "yes" CFLAGS: -coverage -ftest-coverage -fprofile-arcs PYTHONUTF8: "1" - # FIXME: For some reason enabling jit debugging "fixes" random python crashes - # see https://github.com/msys2/MINGW-packages/issues/11864 and - # https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3280#note_1678973 - MSYS: "winjitdebug" script: - C:\msys64\usr\bin\pacman --noconfirm -Syyuu --ask 20 - C:\msys64\usr\bin\bash .gitlab-ci/show-execution-environment.sh @@ -371,10 +367,6 @@ msys2-clang64: MSYSTEM: "CLANG64" CHERE_INVOKING: "yes" PYTHONUTF8: "1" - # FIXME: For some reason enabling jit debugging "fixes" random python crashes - # see https://github.com/msys2/MINGW-packages/issues/11864 and - # https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3280#note_1678973 - MSYS: "winjitdebug" script: - C:\msys64\usr\bin\pacman --noconfirm -Syyuu --ask 20 - C:\msys64\usr\bin\bash .gitlab-ci/show-execution-environment.sh