vlc | branch: master | Rémi Denis-Courmont <[email protected]> | Tue Jan 31 19:16:49 2012 +0200| [cc5fb82459a7ccef27f86120e4881b9203df0626] | committer: Rémi Denis-Courmont
Use static_assert() > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=cc5fb82459a7ccef27f86120e4881b9203df0626 --- modules/access/v4l2/video.c | 8 ++++++-- src/misc/threads.c | 8 +++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/modules/access/v4l2/video.c b/modules/access/v4l2/video.c index f1db053..3314470 100644 --- a/modules/access/v4l2/video.c +++ b/modules/access/v4l2/video.c @@ -915,8 +915,12 @@ static int InitVideo( vlc_object_t *p_obj, int i_fd, demux_sys_t *p_sys, if( std == 0 ) { const size_t n = sizeof(standards_vlc) / sizeof(*standards_vlc); - assert( n == sizeof(standards_v4l2) / sizeof(*standards_v4l2) ); - assert( n == sizeof(standards_user) / sizeof(*standards_user) ); + + static_assert(n == sizeof (standards_v4l2) + / sizeof (*standards_v4l2), "Inconsistent standards tables"); + static_assert(n == sizeof (standards_user) + / sizeof (*standards_user), "Inconsistent standards tables"); + for( size_t i = 0; i < n; i++ ) if( strcasecmp( stdname, standards_vlc[i] ) == 0 ) { diff --git a/src/misc/threads.c b/src/misc/threads.c index da80d0a..e3f2cb2 100644 --- a/src/misc/threads.c +++ b/src/misc/threads.c @@ -43,15 +43,13 @@ void vlc_global_mutex (unsigned n, bool acquire) VLC_STATIC_MUTEX, VLC_STATIC_MUTEX, }; + static_assert (VLC_MAX_MUTEX == (sizeof (locks) / sizeof (locks[0])), + "Wrong number of global mutexes"); assert (n < (sizeof (locks) / sizeof (locks[0]))); - vlc_mutex_t *lock = locks + n; + vlc_mutex_t *lock = locks + n; if (acquire) vlc_mutex_lock (lock); else vlc_mutex_unlock (lock); - - /* Compile-time assertion ;-) */ - char enough_locks[(sizeof (locks) / sizeof (locks[0])) - VLC_MAX_MUTEX]; - (void) enough_locks; } _______________________________________________ vlc-commits mailing list [email protected] http://mailman.videolan.org/listinfo/vlc-commits
