Commit cc5fb824 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Use static_assert()

parent 351690f6
...@@ -915,8 +915,12 @@ static int InitVideo( vlc_object_t *p_obj, int i_fd, demux_sys_t *p_sys, ...@@ -915,8 +915,12 @@ static int InitVideo( vlc_object_t *p_obj, int i_fd, demux_sys_t *p_sys,
if( std == 0 ) if( std == 0 )
{ {
const size_t n = sizeof(standards_vlc) / sizeof(*standards_vlc); 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++ ) for( size_t i = 0; i < n; i++ )
if( strcasecmp( stdname, standards_vlc[i] ) == 0 ) if( strcasecmp( stdname, standards_vlc[i] ) == 0 )
{ {
......
...@@ -43,15 +43,13 @@ void vlc_global_mutex (unsigned n, bool acquire) ...@@ -43,15 +43,13 @@ void vlc_global_mutex (unsigned n, bool acquire)
VLC_STATIC_MUTEX, VLC_STATIC_MUTEX,
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]))); assert (n < (sizeof (locks) / sizeof (locks[0])));
vlc_mutex_t *lock = locks + n;
vlc_mutex_t *lock = locks + n;
if (acquire) if (acquire)
vlc_mutex_lock (lock); vlc_mutex_lock (lock);
else else
vlc_mutex_unlock (lock); vlc_mutex_unlock (lock);
/* Compile-time assertion ;-) */
char enough_locks[(sizeof (locks) / sizeof (locks[0])) - VLC_MAX_MUTEX];
(void) enough_locks;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment