[vlc-commits] playlist: playlist_Create: prevent compilation if public-data is not first member

Filip Roséen git at videolan.org
Thu May 18 17:51:49 CEST 2017


vlc | branch: master | Filip Roséen <filip at atch.se> | Thu May 18 12:01:18 2017 +0200| [204ce10550c072a8cc2417ceec0e69575888604e] | committer: Rémi Denis-Courmont

playlist: playlist_Create: prevent compilation if public-data is not first member

As offsetof is usuable in a constant-expression, the usage of assert
has been replaced with static_assert.

Signed-off-by: Rémi Denis-Courmont <remi at remlab.net>

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

 src/playlist/engine.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/playlist/engine.c b/src/playlist/engine.c
index fce5d6879e..f83651c55e 100644
--- a/src/playlist/engine.c
+++ b/src/playlist/engine.c
@@ -203,7 +203,9 @@ playlist_t *playlist_Create( vlc_object_t *p_parent )
     if( !p )
         return NULL;
 
-    assert( offsetof( playlist_private_t, public_data ) == 0 );
+    static_assert( offsetof( playlist_private_t, public_data ) == 0,
+                   "playlist_private_t.public_data must be at offset 0" );
+
     p_playlist = &p->public_data;
 
     p->input_tree = NULL;



More information about the vlc-commits mailing list