[v1] libcamera: controls: Check size of enum
diff mbox series

Message ID 20250310170254.185172-1-barnabas.pocze@ideasonboard.com
State New
Headers show
Series
  • [v1] libcamera: controls: Check size of enum
Related show

Commit Message

Barnabás Pőcze March 10, 2025, 5:02 p.m. UTC
Only enums whose sizes match that of `int32_t` can be directly
supported. Otherwise the expected size and the real size would
disagree, leading to an assertion failure in `ControlValue::set()`.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
---
 include/libcamera/controls.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h
index 7c7828ae5..4bfe9615c 100644
--- a/include/libcamera/controls.h
+++ b/include/libcamera/controls.h
@@ -125,7 +125,7 @@  struct control_type<Span<T, N>> : public control_type<std::remove_cv_t<T>> {
 };
 
 template<typename T>
-struct control_type<T, std::enable_if_t<std::is_enum_v<T>>> : public control_type<int32_t> {
+struct control_type<T, std::enable_if_t<std::is_enum_v<T> && sizeof(T) == sizeof(int32_t)>> : public control_type<int32_t> {
 };
 
 } /* namespace details */