[vlc-commits] [Git][videolan/vlc][master] 3 commits: test: player: don't initialize non static condition with static initializer

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Sun Jun 12 15:57:41 UTC 2022



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


Commits:
814f4cc0 by Steve Lhomme at 2022-06-12T15:41:42+00:00
test: player: don't initialize non static condition with static initializer

- - - - -
027abd31 by Steve Lhomme at 2022-06-12T15:41:42+00:00
core: make config_lock lock static in config/core.c

- - - - -
bc115028 by Steve Lhomme at 2022-06-12T15:41:42+00:00
hw:mmal: don't initialize non static atomic with ATOMIC_VAR_INIT

ATOMIC_VAR_INIT is deprecated and might be removed in the future. We don't need
to use it.

[1] http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2244.htm#dr_485

- - - - -


5 changed files:

- modules/hw/mmal/mmal_cma.c
- src/config/configuration.h
- src/config/core.c
- src/config/file.c
- test/src/player/player.c


Changes:

=====================================
modules/hw/mmal/mmal_cma.c
=====================================
@@ -298,20 +298,15 @@ static cma_buf_t * cma_pool_alloc_cb(cma_buf_pool_t * const v, size_t size)
 {
     cma_buf_pool_t * const cbp = v;
 
-    cma_buf_t * const cb = malloc(sizeof(cma_buf_t));
+    cma_buf_t * const cb = calloc(1, sizeof(cma_buf_t));
     if (cb == NULL)
         return NULL;
 
-    *cb = (cma_buf_t){
-        .ref_count = ATOMIC_VAR_INIT(0),
-        .cbp = cbp,
-        .in_flight = 0,
-        .size = size,
-        .vcsm_h = 0,
-        .vc_h = 0,
-        .fd = -1,
-        .mmap = MAP_FAILED,
-    };
+    atomic_init(&cb->ref_count, 0);
+    cb->cbp = cbp;
+    cb->size = size;
+    cb->fd = -1;
+    cb->mmap = MAP_FAILED;
 
     // 0x80 is magic value to force full ARM-side mapping - otherwise
     // cache requests can cause kernel crashes


=====================================
src/config/configuration.h
=====================================
@@ -64,12 +64,12 @@ int config_LoadConfigFile( vlc_object_t * );
 #define config_LoadCmdLine(a,b,c,d) config_LoadCmdLine(VLC_OBJECT(a),b,c,d)
 #define config_LoadConfigFile(a) config_LoadConfigFile(VLC_OBJECT(a))
 bool config_PrintHelp (vlc_object_t *);
+void config_Lock(void);
+void config_Unlock(void);
 
 int config_SortConfig (void);
 void config_UnsortConfig (void);
 
-extern vlc_mutex_t config_lock;
-
 bool config_IsSafe (const char *);
 
 /**


=====================================
src/config/core.c
=====================================
@@ -39,9 +39,19 @@
 #include "modules/modules.h"
 #include "misc/rcu.h"
 
-vlc_mutex_t config_lock = VLC_STATIC_MUTEX;
+static vlc_mutex_t config_lock = VLC_STATIC_MUTEX;
 static atomic_bool config_dirty = ATOMIC_VAR_INIT(false);
 
+void config_Lock(void)
+{
+    vlc_mutex_lock(&config_lock);
+}
+
+void config_Unlock(void)
+{
+    vlc_mutex_unlock(&config_lock);
+}
+
 int config_GetType(const char *name)
 {
     const struct vlc_param *param = vlc_param_Find(name);


=====================================
src/config/file.c
=====================================
@@ -181,7 +181,7 @@ int config_LoadConfigFile( vlc_object_t *p_this )
     locale_t loc = newlocale (LC_NUMERIC_MASK, "C", NULL);
     locale_t baseloc = uselocale (loc);
 
-    vlc_mutex_lock(&config_lock);
+    config_Lock();
     while ((linelen = getline (&line, &bufsize, file)) != -1)
     {
         line[linelen - 1] = '\0'; /* trim newline */
@@ -252,7 +252,7 @@ int config_LoadConfigFile( vlc_object_t *p_this )
                 break;
         }
     }
-    vlc_mutex_unlock(&config_lock);
+    config_Unlock();
     free (line);
 
     if (ferror (file))


=====================================
test/src/player/player.c
=====================================
@@ -2154,8 +2154,8 @@ REPORT_LIST
         .program_switch_count = 1,
         .extra_start_count = 0,
         .rate = 1.f,
-        .wait = VLC_STATIC_COND,
     };
+    vlc_cond_init(&ctx->wait);
     reports_init(&ctx->report);
 
     /* Force wdummy window */



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8a1f453f3f9560fd8c61c5b7fddeb8d9e5d5c95b...bc115028dbd73aaac1497ef85e9ddc0726cadb90

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8a1f453f3f9560fd8c61c5b7fddeb8d9e5d5c95b...bc115028dbd73aaac1497ef85e9ddc0726cadb90
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list