[vlc-devel] [PATCH] modules: Use a typedef for deactivate function pointer

Hugo Beauzée-Luyssen hugo at beauzee.fr
Thu Dec 10 19:55:14 CET 2020


Using va_arg with the function pointer type spelled out can be
considered ill-formed as per C11 §7.16.1.1
---
 src/modules/entry.c   | 4 ++--
 src/modules/modules.h | 5 ++++-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/modules/entry.c b/src/modules/entry.c
index fc7f3cdbb6..1d921d5af0 100644
--- a/src/modules/entry.c
+++ b/src/modules/entry.c
@@ -273,7 +273,7 @@ static int vlc_plugin_desc_cb(void *ctx, void *tgt, int propid, ...)
 
         case VLC_MODULE_CB_CLOSE:
             module->deactivate_name = va_arg(ap, const char *);
-            module->deactivate = va_arg(ap, void (*)(vlc_object_t *));
+            module->deactivate = va_arg(ap, vlc_deactivate_cb);
             break;
 
         case VLC_MODULE_NO_UNLOAD:
@@ -498,7 +498,7 @@ static int vlc_plugin_gpa_cb(void *ctx, void *tgt, int propid, ...)
 
             va_start(ap, propid);
             name = va_arg(ap, const char *);
-            addr = va_arg(ap, void (*)(vlc_object_t *));
+            addr = va_arg(ap, vlc_deactivate_cb);
             va_end(ap);
             break;
         }
diff --git a/src/modules/modules.h b/src/modules/modules.h
index 93cc1ca289..34d6b81dd9 100644
--- a/src/modules/modules.h
+++ b/src/modules/modules.h
@@ -66,6 +66,9 @@ extern struct vlc_plugin_t *vlc_plugins;
 /** Plugin entry point prototype */
 typedef int (*vlc_plugin_cb) (int (*)(void *, void *, int, ...), void *);
 
+/** Plugin deactivation callback */
+typedef void (*vlc_deactivate_cb)(vlc_object_t*);
+
 /** Core module */
 int vlc_entry__core (int (*)(void *, void *, int, ...), void *);
 
@@ -95,7 +98,7 @@ struct module_t
     const char *activate_name;
     const char *deactivate_name;
     void *pf_activate;
-    void (*deactivate)(vlc_object_t *);
+    vlc_deactivate_cb deactivate;
 };
 
 vlc_plugin_t *vlc_plugin_create(void);
-- 
2.29.2



More information about the vlc-devel mailing list