Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Subject: [FFmpeg-devel] [PATCH 11/18] lib*/version: Use static_assert for static asserts
Date: Fri, 29 Mar 2024 00:10:40 +0100
Message-ID: <AS8P250MB074405F1FAC3F891E6AFACFD8F3B2@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <GV1P250MB07376DB62F134F911FBD81A18F3B2@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM>

Also update the checks that guard against inserting
a new enum entry in the middle of a range.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/version.c    | 16 +++++++++++-----
 libavdevice/version.c   |  5 +++--
 libavfilter/version.c   |  5 +++--
 libavformat/version.c   |  5 +++--
 libavutil/version.c     | 12 +++++++-----
 libpostproc/version.c   |  5 +++--
 libswresample/version.c |  5 +++--
 libswscale/version.c    |  5 +++--
 8 files changed, 36 insertions(+), 22 deletions(-)

diff --git a/libavcodec/version.c b/libavcodec/version.c
index d7966b2015..27f94323b8 100644
--- a/libavcodec/version.c
+++ b/libavcodec/version.c
@@ -18,9 +18,10 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <assert.h>
+
 #include "config.h"
 
-#include "libavutil/avassert.h"
 #include "avcodec.h"
 #include "codec_id.h"
 #include "version.h"
@@ -30,10 +31,15 @@ const char av_codec_ffversion[] = "FFmpeg version " FFMPEG_VERSION;
 
 unsigned avcodec_version(void)
 {
-    av_assert0(AV_CODEC_ID_PCM_S8_PLANAR==65563);
-    av_assert0(AV_CODEC_ID_ADPCM_G722==69660);
-    av_assert0(AV_CODEC_ID_SRT==94216);
-    av_assert0(LIBAVCODEC_VERSION_MICRO >= 100);
+    static_assert(AV_CODEC_ID_LEAD         ==   269 &&
+                  AV_CODEC_ID_PCM_SGA      == 65572 &&
+                  AV_CODEC_ID_ADPCM_XMD    == 69683 &&
+                  AV_CODEC_ID_CBD2_DPCM    == 81928 &&
+                  AV_CODEC_ID_QOA          == 86121 &&
+                  AV_CODEC_ID_ARIB_CAPTION == 94233 &&
+                  AV_CODEC_ID_SMPTE_2038   == 98315,
+                  "Don't insert new codec ids in the middle of a list");
+    static_assert(LIBAVCODEC_VERSION_MICRO >= 100, "micro version starts at 100");
 
     return LIBAVCODEC_VERSION_INT;
 }
diff --git a/libavdevice/version.c b/libavdevice/version.c
index 92d7f2d159..a058efe46e 100644
--- a/libavdevice/version.c
+++ b/libavdevice/version.c
@@ -18,9 +18,10 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <assert.h>
+
 #include "config.h"
 
-#include "libavutil/avassert.h"
 #include "avdevice.h"
 #include "version.h"
 
@@ -29,7 +30,7 @@ const char av_device_ffversion[] = "FFmpeg version " FFMPEG_VERSION;
 
 unsigned avdevice_version(void)
 {
-    av_assert0(LIBAVDEVICE_VERSION_MICRO >= 100);
+    static_assert(LIBAVDEVICE_VERSION_MICRO >= 100, "micro version starts at 100");
     return LIBAVDEVICE_VERSION_INT;
 }
 
diff --git a/libavfilter/version.c b/libavfilter/version.c
index db1a2511e7..54c286460e 100644
--- a/libavfilter/version.c
+++ b/libavfilter/version.c
@@ -18,8 +18,9 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <assert.h>
+
 #include "config.h"
-#include "libavutil/avassert.h"
 #include "avfilter.h"
 #include "version.h"
 
@@ -28,7 +29,7 @@ const char av_filter_ffversion[] = "FFmpeg version " FFMPEG_VERSION;
 
 unsigned avfilter_version(void)
 {
-    av_assert0(LIBAVFILTER_VERSION_MICRO >= 100);
+    static_assert(LIBAVFILTER_VERSION_MICRO >= 100, "micro version starts at 100");
     return LIBAVFILTER_VERSION_INT;
 }
 
diff --git a/libavformat/version.c b/libavformat/version.c
index 5f321d847e..c0781d3f47 100644
--- a/libavformat/version.c
+++ b/libavformat/version.c
@@ -18,9 +18,10 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <assert.h>
+
 #include "config.h"
 
-#include "libavutil/avassert.h"
 #include "avformat.h"
 #include "version.h"
 
@@ -29,7 +30,7 @@ const char av_format_ffversion[] = "FFmpeg version " FFMPEG_VERSION;
 
 unsigned avformat_version(void)
 {
-    av_assert0(LIBAVFORMAT_VERSION_MICRO >= 100);
+    static_assert(LIBAVFORMAT_VERSION_MICRO >= 100, "micro version starts at 100");
     return LIBAVFORMAT_VERSION_INT;
 }
 
diff --git a/libavutil/version.c b/libavutil/version.c
index baead7c4a0..afab190336 100644
--- a/libavutil/version.c
+++ b/libavutil/version.c
@@ -18,8 +18,9 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <assert.h>
+
 #include "config.h"
-#include "avassert.h"
 #include "avutil.h"
 #include "samplefmt.h"
 #include "version.h"
@@ -34,10 +35,11 @@ const char *av_version_info(void)
 
 unsigned avutil_version(void)
 {
-    av_assert0(AV_SAMPLE_FMT_DBLP == 9);
-    av_assert0(AVMEDIA_TYPE_ATTACHMENT == 4);
-    av_assert0(AV_PICTURE_TYPE_BI == 7);
-    av_assert0(LIBAVUTIL_VERSION_MICRO >= 100);
+    static_assert(AV_SAMPLE_FMT_S64P      == 11 &&
+                  AVMEDIA_TYPE_ATTACHMENT ==  4 &&
+                  AV_PICTURE_TYPE_BI      ==  7,
+                  "Don't insert new sample/media/picture types in the middle of the list");
+    static_assert(LIBAVUTIL_VERSION_MICRO >= 100, "micro version starts at 100");
 
     return LIBAVUTIL_VERSION_INT;
 }
diff --git a/libpostproc/version.c b/libpostproc/version.c
index 494575ae67..304abe08e6 100644
--- a/libpostproc/version.c
+++ b/libpostproc/version.c
@@ -18,8 +18,9 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <assert.h>
+
 #include "config.h"
-#include "libavutil/avassert.h"
 #include "postprocess.h"
 #include "version.h"
 
@@ -28,7 +29,7 @@ const char postproc_ffversion[] = "FFmpeg version " FFMPEG_VERSION;
 
 unsigned postproc_version(void)
 {
-    av_assert0(LIBPOSTPROC_VERSION_MICRO >= 100);
+    static_assert(LIBPOSTPROC_VERSION_MICRO >= 100, "micro version starts at 100");
     return LIBPOSTPROC_VERSION_INT;
 }
 
diff --git a/libswresample/version.c b/libswresample/version.c
index 00f71e3393..40fbbabf96 100644
--- a/libswresample/version.c
+++ b/libswresample/version.c
@@ -18,8 +18,9 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <assert.h>
+
 #include "config.h"
-#include "libavutil/avassert.h"
 #include "swresample.h"
 #include "version.h"
 
@@ -28,7 +29,7 @@ const char swr_ffversion[] = "FFmpeg version " FFMPEG_VERSION;
 
 unsigned swresample_version(void)
 {
-    av_assert0(LIBSWRESAMPLE_VERSION_MICRO >= 100);
+    static_assert(LIBSWRESAMPLE_VERSION_MICRO >= 100, "micro version starts at 100");
     return LIBSWRESAMPLE_VERSION_INT;
 }
 
diff --git a/libswscale/version.c b/libswscale/version.c
index b165e2563e..31135f9cb1 100644
--- a/libswscale/version.c
+++ b/libswscale/version.c
@@ -18,14 +18,15 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <assert.h>
+
 #include "config.h"
-#include "libavutil/avassert.h"
 #include "swscale.h"
 #include "version.h"
 
 unsigned swscale_version(void)
 {
-    av_assert0(LIBSWSCALE_VERSION_MICRO >= 100);
+    static_assert(LIBSWSCALE_VERSION_MICRO >= 100, "micro version starts at 100");
     return LIBSWSCALE_VERSION_INT;
 }
 
-- 
2.40.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  parent reply	other threads:[~2024-03-28 23:12 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-28 22:38 [FFmpeg-devel] [PATCH 01/18] avcodec/mips/ac3dsp_mips: Add missing includes Andreas Rheinhardt
2024-03-28 23:10 ` [FFmpeg-devel] [PATCH 02/18] avcodec/pcm-bluray/dvd: Use correct pointer types on BE Andreas Rheinhardt
2024-07-30  9:18   ` Sebastian Ramacher
2024-03-28 23:10 ` [FFmpeg-devel] [PATCH 03/18] swscale/ppc/swscale_altivec: Fix build with -O0 Andreas Rheinhardt
2024-03-28 23:10 ` [FFmpeg-devel] [PATCH 04/18] swscale/ppc/swscale_altivec: Simplify macro Andreas Rheinhardt
2024-03-28 23:10 ` [FFmpeg-devel] [PATCH 05/18] avcodec, avfilter: Don't use "" for system headers Andreas Rheinhardt
2024-03-28 23:10 ` [FFmpeg-devel] [PATCH 06/18] postproc/postprocess: Don't generally include arch-specific headers Andreas Rheinhardt
2024-03-29 14:54   ` Sean McGovern
2024-03-28 23:10 ` [FFmpeg-devel] [PATCH 07/18] swscale/swscale_internal: Only include altivec header iff HAVE_ALTIVEC Andreas Rheinhardt
2024-03-29 14:55   ` Sean McGovern
2024-03-28 23:10 ` [FFmpeg-devel] [PATCH 08/18] avcodec/msmpeg4: Don't include x86-specific header unconditionally Andreas Rheinhardt
2024-03-28 23:10 ` [FFmpeg-devel] [PATCH 09/18] swscale/swscale_internal: Hoist branch out of loop Andreas Rheinhardt
2024-03-28 23:10 ` [FFmpeg-devel] [PATCH 10/18] swscale/swscale_internal: Don't export internal function Andreas Rheinhardt
2024-03-28 23:10 ` Andreas Rheinhardt [this message]
2024-03-28 23:10 ` [FFmpeg-devel] [PATCH 12/18] avutil/common: Don't auto-include mem.h Andreas Rheinhardt
2024-03-28 23:10 ` [FFmpeg-devel] [PATCH 13/18] avcodec/arm/mpegvideo_arm: Use static_assert to check offsets Andreas Rheinhardt
2024-03-28 23:10 ` [FFmpeg-devel] [PATCH 14/18] avutil/internal: Move libm inclusion to the beginning Andreas Rheinhardt
2024-03-28 23:10 ` [FFmpeg-devel] [PATCH 15/18] avutil/internal: Move FF_MEMORY_POISON to its only user Andreas Rheinhardt
2024-03-28 23:10 ` [FFmpeg-devel] [PATCH 16/18] avutil/hwcontext_vulkan: Include hwcontext.h Andreas Rheinhardt
2024-03-28 23:10 ` [FFmpeg-devel] [PATCH 17/18] avutil/internal: Move avpriv_set_systematic_pal2 decl to imgutils_internal.h Andreas Rheinhardt
2024-03-28 23:10 ` [FFmpeg-devel] [PATCH 18/18] avcodec/arm/vp8: Don't discard const Andreas Rheinhardt
2024-03-30 13:47 ` [FFmpeg-devel] [PATCH 01/18] avcodec/mips/ac3dsp_mips: Add missing includes Andreas Rheinhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AS8P250MB074405F1FAC3F891E6AFACFD8F3B2@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM \
    --to=andreas.rheinhardt@outlook.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git