Commit ea1f77f9 authored by Thomas Haller's avatar Thomas Haller

core: don't use variable length arrays

Let's compile with -Wvla, so that G_STATIC_ASSERT() is really
static. But then we cannot use variable length arrays.
parent c696a226
......@@ -6206,7 +6206,9 @@ _test_find_binary_search_do_uint32 (const int *int_array, gsize len)
const int OFFSET = 100;
const int NEEDLE = 0 + OFFSET;
gssize expected_result = -1;
guint32 array[len];
guint32 array[30];
g_assert (len <= G_N_ELEMENTS (array));
/* the test data has negative values. Shift them... */
for (idx = 0; idx < len; idx++) {
......
......@@ -2879,9 +2879,9 @@ nm_ip4_config_equal (const NMIP4Config *a, const NMIP4Config *b)
{
GChecksum *a_checksum = g_checksum_new (G_CHECKSUM_SHA1);
GChecksum *b_checksum = g_checksum_new (G_CHECKSUM_SHA1);
gsize a_len = g_checksum_type_get_length (G_CHECKSUM_SHA1);
gsize b_len = g_checksum_type_get_length (G_CHECKSUM_SHA1);
guchar a_data[a_len], b_data[b_len];
guchar a_data[20], b_data[20];
gsize a_len = sizeof (a_data);
gsize b_len = sizeof (b_data);
gboolean equal;
if (a)
......@@ -2892,7 +2892,8 @@ nm_ip4_config_equal (const NMIP4Config *a, const NMIP4Config *b)
g_checksum_get_digest (a_checksum, a_data, &a_len);
g_checksum_get_digest (b_checksum, b_data, &b_len);
g_assert (a_len == b_len);
nm_assert (a_len == sizeof (a_data));
nm_assert (b_len == sizeof (b_data));
equal = !memcmp (a_data, b_data, a_len);
g_checksum_free (a_checksum);
......
......@@ -2477,9 +2477,9 @@ nm_ip6_config_equal (const NMIP6Config *a, const NMIP6Config *b)
{
GChecksum *a_checksum = g_checksum_new (G_CHECKSUM_SHA1);
GChecksum *b_checksum = g_checksum_new (G_CHECKSUM_SHA1);
gsize a_len = g_checksum_type_get_length (G_CHECKSUM_SHA1);
gsize b_len = g_checksum_type_get_length (G_CHECKSUM_SHA1);
guchar a_data[a_len], b_data[b_len];
guchar a_data[20], b_data[20];
gsize a_len = sizeof (a_data);
gsize b_len = sizeof (b_data);
gboolean equal;
if (a)
......@@ -2490,7 +2490,8 @@ nm_ip6_config_equal (const NMIP6Config *a, const NMIP6Config *b)
g_checksum_get_digest (a_checksum, a_data, &a_len);
g_checksum_get_digest (b_checksum, b_data, &b_len);
g_assert (a_len == b_len);
nm_assert (a_len == sizeof (a_data));
nm_assert (b_len == sizeof (b_data));
equal = !memcmp (a_data, b_data, a_len);
g_checksum_free (a_checksum);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment