warning: ‘map’ may be used uninitialized in this function
I get this compiler warning when building current master:
[7/17] Compiling C object libgweather/libgweather.a.p/gweather-private.c.o
In file included from /usr/lib/x86_64-linux-gnu/glib-2.0/include/glibconfig.h:9,
from /usr/include/glib-2.0/glib/gtypes.h:32,
from /usr/include/glib-2.0/glib/galloca.h:32,
from /usr/include/glib-2.0/glib.h:30,
from /usr/include/glib-2.0/gobject/gbinding.h:28,
from /usr/include/glib-2.0/glib-object.h:22,
from /usr/include/glib-2.0/gio/gioenums.h:28,
from /usr/include/glib-2.0/gio/giotypes.h:28,
from /usr/include/glib-2.0/gio/gio.h:26,
from ../libgweather/gweather-private.h:12,
from ../libgweather/gweather-private.c:9:
../libgweather/gweather-private.c: In function ‘ensure_world’:
/usr/include/glib-2.0/glib/gmacros.h:1212:17: warning: ‘map’ may be used uninitialized in this function [-Wmaybe-uninitialized]
1212 | { if (_ptr) (cleanup) ((ParentName *) _ptr); } \
| ^
../libgweather/gweather-private.c:47:29: note: ‘map’ was declared here
47 | g_autoptr (GMappedFile) map;
Possible simple change:
- g_autoptr (GMappedFile) map;
+ g_autoptr (GMappedFile) map = NULL;
As it can cause crashes, unexpected behavior, I label this as a Crash
.