[vlc-devel] commit: Deprecate ugly and unsafe vlc_object_find_name() ( Rémi Denis-Courmont )

git version control git at videolan.org
Wed Aug 19 23:05:46 CEST 2009


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Aug 19 23:45:45 2009 +0300| [b6c76ecf1a1b2c87d8dc91e0a636291339d96c28] | committer: Rémi Denis-Courmont 

Deprecate ugly and unsafe vlc_object_find_name()

psz_object_name can only be read from the thread calling module_need()
for the current object. As an alternative, module_need() would have to
be called before vlc_object_attach(), which would break var_CreateGet*.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b6c76ecf1a1b2c87d8dc91e0a636291339d96c28
---

 include/vlc_objects.h |    3 +++
 src/misc/objects.c    |    3 +++
 2 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/include/vlc_objects.h b/include/vlc_objects.h
index e2fda54..804fc20 100644
--- a/include/vlc_objects.h
+++ b/include/vlc_objects.h
@@ -75,6 +75,9 @@ VLC_EXPORT( void, __vlc_object_detach, ( vlc_object_t * ) );
 __attribute__((deprecated))
 #endif
 VLC_EXPORT( void *, __vlc_object_find, ( vlc_object_t *, int, int ) );
+#if defined (__GNUC__) && !defined __cplusplus
+__attribute__((deprecated))
+#endif
 VLC_EXPORT( vlc_object_t *, vlc_object_find_name, ( vlc_object_t *, const char *, int ) );
 VLC_EXPORT( void *, __vlc_object_hold, ( vlc_object_t * ) );
 VLC_EXPORT( void, __vlc_object_release, ( vlc_object_t * ) );
diff --git a/src/misc/objects.c b/src/misc/objects.c
index eea00ba..d10f61b 100644
--- a/src/misc/objects.c
+++ b/src/misc/objects.c
@@ -477,6 +477,9 @@ vlc_object_t *vlc_object_find_name( vlc_object_t *p_this,
 {
     vlc_object_t *p_found;
 
+    /* Reading psz_object_name from a separate inhibits thread-safety.
+     * Use a libvlc address variable instead for that sort of things! */
+    msg_Warn( p_this, "%s(%s) is not safe!", __func__, psz_name );
     /* If have the requested name ourselves, don't look further */
     if( !(i_mode & FIND_STRICT)
         && p_this->psz_object_name




More information about the vlc-devel mailing list