From 2f35c32c34020d2dad311758d02500e35ff2619c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Sat, 11 May 2024 01:23:34 +0200 Subject: [PATCH 1/3] vsaprintf: Use proper size for mp_limb_t to please msys2-mingw32 CI --- glib/gnulib/vasnprintf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glib/gnulib/vasnprintf.c b/glib/gnulib/vasnprintf.c index a5b68db8c..7e151b462 100644 --- a/glib/gnulib/vasnprintf.c +++ b/glib/gnulib/vasnprintf.c @@ -379,7 +379,7 @@ multiply (mpn_t src1, mpn_t src2, mpn_t *dest) { /* src1 or src2 is zero. */ dest->nlimbs = 0; - dest->limbs = (mp_limb_t *) malloc (1); + dest->limbs = (mp_limb_t *) malloc (sizeof (mp_limb_t)); } else { From 8714b87dbe14dfc0c76a339c92e77c6f2b21981f Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Wed, 15 May 2024 10:33:35 +0100 Subject: [PATCH 2/3] tests: Ignore -Wdiscarded-qualifiers with volatile atomics tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GCC 14 now emits this warning with the tests: ``` In file included from ../glib/gthread.h:34, from ../glib/gasyncqueue.h:34, from ../glib/glib.h:34, from ../glib/tests/atomic.c:14: ../glib/tests/atomic.c: In function 'test_types': ../glib/gatomic.h:140:5: error: argument 2 of '__atomic_store' discards 'volatile' qualifier [-Werror=discarded-qualifiers] 140 | __atomic_store (gaps_temp_atomic, &gaps_temp_newval, __ATOMIC_SEQ_CST); \ | ^~~~~~~~~~~~~~ ../glib/tests/atomic.c:139:3: note: in expansion of macro 'g_atomic_pointer_set' 139 | g_atomic_pointer_set (&vp_str_vol, NULL); | ^~~~~~~~~~~~~~~~~~~~ cc1.exe: all warnings being treated as errors ``` I can’t think of a way to cast around this in the definition of `g_atomic_pointer_set()` without making the behaviour worse (less type safe) for modern non-volatile atomic variables. We would like to strongly nudge users of GLib away from declaring atomic variables as `volatile`, so letting another compiler warning be emitted when they do is not the end of the world. As long as it doesn’t stop old code compiling (without `-Werror`). Signed-off-by: Philip Withnall --- glib/tests/atomic.c | 1 + 1 file changed, 1 insertion(+) diff --git a/glib/tests/atomic.c b/glib/tests/atomic.c index 9d57d2114..82c5c9e14 100644 --- a/glib/tests/atomic.c +++ b/glib/tests/atomic.c @@ -136,6 +136,7 @@ test_types (void) * to make sure that we don’t warn when built against older third party code. */ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wincompatible-pointer-types" +#pragma GCC diagnostic ignored "-Wdiscarded-qualifiers" g_atomic_pointer_set (&vp_str_vol, NULL); g_atomic_pointer_set (&vp_str, str); res = g_atomic_pointer_compare_and_exchange (&vp_str_vol, NULL, str); From 88e0dca208564c3d100d88f2045b4c834ad311e4 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Wed, 15 May 2024 10:51:50 +0100 Subject: [PATCH 3/3] tests: Fix transposed arguments to g_aligned_alloc() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Spotted by GCC 14’s `-Werror=calloc-transposed-args`. Thanks, GCC 14. Signed-off-by: Philip Withnall --- glib/tests/mem-overflow.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/glib/tests/mem-overflow.c b/glib/tests/mem-overflow.c index f19534102..b8b65c17a 100644 --- a/glib/tests/mem-overflow.c +++ b/glib/tests/mem-overflow.c @@ -71,11 +71,11 @@ MEM_OVERFLOW_TEST (new0_b, p = g_new0 (X, b)) MEM_OVERFLOW_TEST (renew_a, p = g_malloc (1); p = g_renew (X, p, a)) MEM_OVERFLOW_TEST (renew_b, p = g_malloc (1); p = g_renew (X, p, b)) -MEM_OVERFLOW_TEST_FULL (aligned_alloc_a, p = g_aligned_alloc (sizeof(X), a, 16), g_aligned_free) -MEM_OVERFLOW_TEST_FULL (aligned_alloc_b, p = g_aligned_alloc (sizeof(X), b, 16), g_aligned_free) +MEM_OVERFLOW_TEST_FULL (aligned_alloc_a, p = g_aligned_alloc (a, sizeof(X), 16), g_aligned_free) +MEM_OVERFLOW_TEST_FULL (aligned_alloc_b, p = g_aligned_alloc (b, sizeof(X), 16), g_aligned_free) -MEM_OVERFLOW_TEST_FULL (aligned_alloc0_a, p = g_aligned_alloc0 (sizeof(X), a, 16), g_aligned_free) -MEM_OVERFLOW_TEST_FULL (aligned_alloc0_b, p = g_aligned_alloc0 (sizeof(X), b, 16), g_aligned_free) +MEM_OVERFLOW_TEST_FULL (aligned_alloc0_a, p = g_aligned_alloc0 (a, sizeof(X), 16), g_aligned_free) +MEM_OVERFLOW_TEST_FULL (aligned_alloc0_b, p = g_aligned_alloc0 (b, sizeof(X), 16), g_aligned_free) static void mem_overflow_malloc_0 (void)