[PATCH next 03/14] media: videobuf2-core: Use static_assert() for sanity check

david.laight.linux@gmail.com posted 14 patches 2 weeks, 3 days ago
[PATCH next 03/14] media: videobuf2-core: Use static_assert() for sanity check
Posted by david.laight.linux@gmail.com 2 weeks, 3 days ago
From: David Laight <david.laight.linux@gmail.com>

Compile-time tests being added to BIT() make it an 'integer constant
expression' rather than a pre-processor expression for W=1 builds.

Change the BIT(PLANE_INDEX_BITS) != VIDEO_MAX_PLANES test to use
static_assert() so the code compiles.

Signed-off-by: David Laight <david.laight.linux@gmail.com>
---
 drivers/media/common/videobuf2/videobuf2-core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c
index 2df566f409b6..90dedab2aeb2 100644
--- a/drivers/media/common/videobuf2/videobuf2-core.c
+++ b/drivers/media/common/videobuf2/videobuf2-core.c
@@ -37,9 +37,9 @@
 #define MAX_BUFFER_INDEX	BIT_MASK(30 - PLANE_INDEX_SHIFT)
 #define BUFFER_INDEX_MASK	(MAX_BUFFER_INDEX - 1)
 
-#if BIT(PLANE_INDEX_BITS) != VIDEO_MAX_PLANES
-#error PLANE_INDEX_BITS order must be equal to VIDEO_MAX_PLANES
-#endif
+
+static_assert(BIT(PLANE_INDEX_BITS) == VIDEO_MAX_PLANES,
+	      "PLANE_INDEX_BITS order must be equal to VIDEO_MAX_PLANES");
 
 static int debug;
 module_param(debug, int, 0644);
-- 
2.39.5