glib/messages: Avoid warning on potentially uninitialized value

In function ‘memmem_with_end_pointer’,
    inlined from ‘domain_found’ at ../glib/gmessages.c:2695:16,
    inlined from ‘should_drop_message’ at ../glib/gmessages.c:2802:35:
../glib/gmessages.c:2674:19: warning: ‘log_domain_length’ may be used
    uninitialized [-Wmaybe-uninitialized]
 2674 | #define my_memmem memmem
      |                   ^
../glib/gmessages.c:2683:10: note: in expansion of macro ‘my_memmem’
 2683 |   return my_memmem (haystack, (const char *) haystack_end - (const char *) haystack, needle, needle_len);
      |          ^~~~~~~~~
../glib/gmessages.c: In function ‘should_drop_message’:
../glib/gmessages.c:2760:13: note: ‘log_domain_length’ was declared here
 2760 |       gsize log_domain_length;
      |             ^~~~~~~~~~~~~~~~~
This commit is contained in:
Marco Trevisan (Treviño) 2025-04-03 14:01:20 +02:00
parent 31c9dbbc73
commit 03dcf4cdc3

View File

@ -2778,6 +2778,8 @@ should_drop_message (GLogLevelFlags log_level,
if (log_domain == NULL)
{
log_domain_length = 0;
for (i = 0; i < n_fields; i++)
{
if (g_strcmp0 (fields[i].key, "GLIB_DOMAIN") == 0)