libcamera/test/gstreamer
Laurent Pinchart 03526e58d1 tests: gstreamer: Fix compiler error with gcc 8.4.0
The provider g_autoptr variable introduced by commit adb1bbb748
("tests: gstreamer: Test cameras' enumeration from GstDeviceProvider")
is left uninitialized when declared. The cleanup function could thus get
called on an unitialized variable if the scope was exited before the
variable gets initialized. This can't occur here, but gcc 8.4.0 still
complains about it:

/usr/include/glib-2.0/glib/gmacros.h: In member function ‘virtual int GstreamerDeviceProviderTest::run()’:
/usr/include/glib-2.0/glib/gmacros.h:1049:27: error: ‘provider’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
     { if (_ptr) (cleanup) ((ParentName *) _ptr); }                                                              \
                           ^
../test/gstreamer/gstreamer_device_provider_test.cpp:37:32: note: ‘provider’ was declared here
   g_autoptr(GstDeviceProvider) provider;

Silence the error by initializing the variable to NULL at declaration
time. This is a good practice in any case, as later refactoring could
otherwise introduce a scope exit before initialization.

Fixes: adb1bbb748 ("tests: gstreamer: Test cameras' enumeration from GstDeviceProvider")
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-07-11 15:58:06 +01:00
..
gstreamer_device_provider_test.cpp tests: gstreamer: Fix compiler error with gcc 8.4.0 2023-07-11 15:58:06 +01:00
gstreamer_multi_stream_test.cpp test: gstreamer: Fix failure of gstreamer_multistream_test 2022-09-12 22:44:54 +05:30
gstreamer_single_stream_test.cpp test: gstreamer: Remove unnecessary header file includes 2021-10-04 12:55:08 +05:30
gstreamer_test.cpp test: gstreamer: gstreamer_test: Remove redundant word 2022-09-12 22:44:56 +05:30
gstreamer_test.h test: gstreamer: Fix failure of gstreamer_multistream_test 2022-09-12 22:44:54 +05:30
meson.build meson: Fix space around colon issues 2023-07-07 11:39:19 +03:00