[vlc-commits] demux/adaptive: add static_assert related to module options

Filip Roséen git at videolan.org
Fri Oct 14 11:16:12 CEST 2016


vlc | branch: master | Filip Roséen <filip at atch.se> | Wed Oct 12 13:04:36 2016 +0200| [af14332fe615698bf574381827a8190ebb8290a6] | committer: Francois Cartegnie

demux/adaptive: add static_assert related to module options

It is better to be safe than sorry, and as the current implementation assumes
all of the three arrays have the same number of elements without an explicit
check to see that this is the case - a static_assert should prevent future
brainfarts.

Signed-off-by: Francois Cartegnie <fcvlcdev at free.fr>

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

 modules/demux/adaptive/adaptive.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/modules/demux/adaptive/adaptive.cpp b/modules/demux/adaptive/adaptive.cpp
index 1430ee1..3ad44fc 100644
--- a/modules/demux/adaptive/adaptive.cpp
+++ b/modules/demux/adaptive/adaptive.cpp
@@ -98,6 +98,12 @@ static const char *const ppsz_logics[] = { N_("Default"),
                                            N_("Lowest Bandwidth/Quality"),
                                            N_("Highest Bandwidth/Quality")};
 
+static_assert( ARRAY_SIZE( pi_logics ) == ARRAY_SIZE( ppsz_logics ),
+    "pi_logics and ppsz_logics shall have the same number of elements" );
+
+static_assert( ARRAY_SIZE( pi_logics ) == ARRAY_SIZE( ppsz_logics_values ),
+    "pi_logics and ppsz_logics_values shall have the same number of elements" );
+
 vlc_module_begin ()
         set_shortname( N_("Adaptive"))
         set_description( N_("Unified adaptive streaming for DASH/HLS") )



More information about the vlc-commits mailing list