[vlc-commits] [Git][videolan/vlc][master] picture_pool: fix uninitialized warnings

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Sat Oct 23 16:34:01 UTC 2021



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
44c2aa7b by Alexandre Janniaux at 2021-10-23T16:12:35+00:00
picture_pool: fix uninitialized warnings

In the case count=0, the loop is not processed and the picture array's
single element is not initialized, leading to a warning. We don't use
count=0 anyway so remove the case.

Fix the warnings (<unknown> is the VLA):

../../src/misc/picture_pool.c: In function ‘picture_pool_NewFromFormat’:
../../src/misc/picture_pool.c:140:28: warning: ‘<unknown>’ may be used uninitialized [-Wmaybe-uninitialized]
  140 |     picture_pool_t *pool = picture_pool_New(count, picture);
      |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/misc/picture_pool.c:102:17: note: by argument 2 of type ‘picture_t * const*’ to ‘picture_pool_New’ declared here
  102 | picture_pool_t *picture_pool_New(unsigned count, picture_t *const *tab)
      |                 ^~~~~~~~~~~~~~~~

- - - - -


1 changed file:

- src/misc/picture_pool.c


Changes:

=====================================
src/misc/picture_pool.c
=====================================
@@ -128,7 +128,10 @@ picture_pool_t *picture_pool_New(unsigned count, picture_t *const *tab)
 picture_pool_t *picture_pool_NewFromFormat(const video_format_t *fmt,
                                            unsigned count)
 {
-    picture_t *picture[count ? count : 1];
+    if (count == 0)
+        vlc_assert_unreachable();
+
+    picture_t *picture[count];
     unsigned i;
 
     for (i = 0; i < count; i++) {
@@ -151,7 +154,10 @@ error:
 
 picture_pool_t *picture_pool_Reserve(picture_pool_t *master, unsigned count)
 {
-    picture_t *picture[count ? count : 1];
+    if (count == 0)
+        vlc_assert_unreachable();
+
+    picture_t *picture[count];
     unsigned i;
 
     for (i = 0; i < count; i++) {



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/44c2aa7bcb0804880ecd499393034b3185082b8a

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/44c2aa7bcb0804880ecd499393034b3185082b8a
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list