[glib/glib-2-72: 24/39] Fix array-bounds compiler warnings with GCC 12
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/glib-2-72: 24/39] Fix array-bounds compiler warnings with GCC 12
- Date: Tue, 20 Sep 2022 19:07:39 +0000 (UTC)
commit 8fb03af05d83481482b3610b8765c387248b5768
Author: Emmanuele Bassi <ebassi gnome org>
Date: Fri Sep 2 12:46:57 2022 +0100
Fix array-bounds compiler warnings with GCC 12
GCC isn't smart enough to recognise that the assertion on the size of
N_PROPERTIES also affects the assertion on the GParamSpec array access,
so we need to coalesce the two checks into one to avoid an array-bounds
compiler warning.
(cherry-picked from commit 903c004b37d723972b07ecbdd880ae0d2c8b767d)
gobject/tests/properties.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
---
diff --git a/gobject/tests/properties.c b/gobject/tests/properties.c
index 3695ee123d..208d5f1450 100644
--- a/gobject/tests/properties.c
+++ b/gobject/tests/properties.c
@@ -104,8 +104,7 @@ test_object_set_property (GObject *gobject,
TestObject *tobj = (TestObject *) gobject;
g_assert_cmpint (prop_id, !=, 0);
- g_assert_cmpint (prop_id, !=, N_PROPERTIES);
- g_assert (pspec == properties[prop_id]);
+ g_assert_true (prop_id < N_PROPERTIES && pspec == properties[prop_id]);
switch (prop_id)
{
@@ -139,8 +138,7 @@ test_object_get_property (GObject *gobject,
TestObject *tobj = (TestObject *) gobject;
g_assert_cmpint (prop_id, !=, 0);
- g_assert_cmpint (prop_id, !=, N_PROPERTIES);
- g_assert (pspec == properties[prop_id]);
+ g_assert_true (prop_id < N_PROPERTIES && pspec == properties[prop_id]);
switch (prop_id)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]