Skip to content

Commit b616be1

Browse files
committed
lib*/version: Use static_assert for static asserts
Also update the checks that guard against inserting a new enum entry in the middle of a range. Signed-off-by: Andreas Rheinhardt <[email protected]>
1 parent 2d38141 commit b616be1

File tree

8 files changed

+36
-22
lines changed

8 files changed

+36
-22
lines changed

libavcodec/version.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1919
*/
2020

21+
#include <assert.h>
22+
2123
#include "config.h"
2224

23-
#include "libavutil/avassert.h"
2425
#include "avcodec.h"
2526
#include "codec_id.h"
2627
#include "version.h"
@@ -30,10 +31,15 @@ const char av_codec_ffversion[] = "FFmpeg version " FFMPEG_VERSION;
3031

3132
unsigned avcodec_version(void)
3233
{
33-
av_assert0(AV_CODEC_ID_PCM_S8_PLANAR==65563);
34-
av_assert0(AV_CODEC_ID_ADPCM_G722==69660);
35-
av_assert0(AV_CODEC_ID_SRT==94216);
36-
av_assert0(LIBAVCODEC_VERSION_MICRO >= 100);
34+
static_assert(AV_CODEC_ID_LEAD == 269 &&
35+
AV_CODEC_ID_PCM_SGA == 65572 &&
36+
AV_CODEC_ID_ADPCM_XMD == 69683 &&
37+
AV_CODEC_ID_CBD2_DPCM == 81928 &&
38+
AV_CODEC_ID_QOA == 86121 &&
39+
AV_CODEC_ID_ARIB_CAPTION == 94233 &&
40+
AV_CODEC_ID_SMPTE_2038 == 98315,
41+
"Don't insert new codec ids in the middle of a list");
42+
static_assert(LIBAVCODEC_VERSION_MICRO >= 100, "micro version starts at 100");
3743

3844
return LIBAVCODEC_VERSION_INT;
3945
}

libavdevice/version.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1919
*/
2020

21+
#include <assert.h>
22+
2123
#include "config.h"
2224

23-
#include "libavutil/avassert.h"
2425
#include "avdevice.h"
2526
#include "version.h"
2627

@@ -29,7 +30,7 @@ const char av_device_ffversion[] = "FFmpeg version " FFMPEG_VERSION;
2930

3031
unsigned avdevice_version(void)
3132
{
32-
av_assert0(LIBAVDEVICE_VERSION_MICRO >= 100);
33+
static_assert(LIBAVDEVICE_VERSION_MICRO >= 100, "micro version starts at 100");
3334
return LIBAVDEVICE_VERSION_INT;
3435
}
3536

libavfilter/version.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1919
*/
2020

21+
#include <assert.h>
22+
2123
#include "config.h"
22-
#include "libavutil/avassert.h"
2324
#include "avfilter.h"
2425
#include "version.h"
2526

@@ -28,7 +29,7 @@ const char av_filter_ffversion[] = "FFmpeg version " FFMPEG_VERSION;
2829

2930
unsigned avfilter_version(void)
3031
{
31-
av_assert0(LIBAVFILTER_VERSION_MICRO >= 100);
32+
static_assert(LIBAVFILTER_VERSION_MICRO >= 100, "micro version starts at 100");
3233
return LIBAVFILTER_VERSION_INT;
3334
}
3435

libavformat/version.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1919
*/
2020

21+
#include <assert.h>
22+
2123
#include "config.h"
2224

23-
#include "libavutil/avassert.h"
2425
#include "avformat.h"
2526
#include "version.h"
2627

@@ -29,7 +30,7 @@ const char av_format_ffversion[] = "FFmpeg version " FFMPEG_VERSION;
2930

3031
unsigned avformat_version(void)
3132
{
32-
av_assert0(LIBAVFORMAT_VERSION_MICRO >= 100);
33+
static_assert(LIBAVFORMAT_VERSION_MICRO >= 100, "micro version starts at 100");
3334
return LIBAVFORMAT_VERSION_INT;
3435
}
3536

libavutil/version.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1919
*/
2020

21+
#include <assert.h>
22+
2123
#include "config.h"
22-
#include "avassert.h"
2324
#include "avutil.h"
2425
#include "samplefmt.h"
2526
#include "version.h"
@@ -34,10 +35,11 @@ const char *av_version_info(void)
3435

3536
unsigned avutil_version(void)
3637
{
37-
av_assert0(AV_SAMPLE_FMT_DBLP == 9);
38-
av_assert0(AVMEDIA_TYPE_ATTACHMENT == 4);
39-
av_assert0(AV_PICTURE_TYPE_BI == 7);
40-
av_assert0(LIBAVUTIL_VERSION_MICRO >= 100);
38+
static_assert(AV_SAMPLE_FMT_S64P == 11 &&
39+
AVMEDIA_TYPE_ATTACHMENT == 4 &&
40+
AV_PICTURE_TYPE_BI == 7,
41+
"Don't insert new sample/media/picture types in the middle of the list");
42+
static_assert(LIBAVUTIL_VERSION_MICRO >= 100, "micro version starts at 100");
4143

4244
return LIBAVUTIL_VERSION_INT;
4345
}

libpostproc/version.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1919
*/
2020

21+
#include <assert.h>
22+
2123
#include "config.h"
22-
#include "libavutil/avassert.h"
2324
#include "postprocess.h"
2425
#include "version.h"
2526

@@ -28,7 +29,7 @@ const char postproc_ffversion[] = "FFmpeg version " FFMPEG_VERSION;
2829

2930
unsigned postproc_version(void)
3031
{
31-
av_assert0(LIBPOSTPROC_VERSION_MICRO >= 100);
32+
static_assert(LIBPOSTPROC_VERSION_MICRO >= 100, "micro version starts at 100");
3233
return LIBPOSTPROC_VERSION_INT;
3334
}
3435

libswresample/version.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1919
*/
2020

21+
#include <assert.h>
22+
2123
#include "config.h"
22-
#include "libavutil/avassert.h"
2324
#include "swresample.h"
2425
#include "version.h"
2526

@@ -28,7 +29,7 @@ const char swr_ffversion[] = "FFmpeg version " FFMPEG_VERSION;
2829

2930
unsigned swresample_version(void)
3031
{
31-
av_assert0(LIBSWRESAMPLE_VERSION_MICRO >= 100);
32+
static_assert(LIBSWRESAMPLE_VERSION_MICRO >= 100, "micro version starts at 100");
3233
return LIBSWRESAMPLE_VERSION_INT;
3334
}
3435

libswscale/version.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@
1818
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1919
*/
2020

21+
#include <assert.h>
22+
2123
#include "config.h"
22-
#include "libavutil/avassert.h"
2324
#include "swscale.h"
2425
#include "version.h"
2526

2627
unsigned swscale_version(void)
2728
{
28-
av_assert0(LIBSWSCALE_VERSION_MICRO >= 100);
29+
static_assert(LIBSWSCALE_VERSION_MICRO >= 100, "micro version starts at 100");
2930
return LIBSWSCALE_VERSION_INT;
3031
}
3132

0 commit comments

Comments
 (0)